Вы можете попробовать это,
startnodes = [0, 1, 2, 3, 4]
endnodes = [0, 1, 2, 3, 4]
import itertools
arb = []
for x, y in itertools.product(startnodes, endnodes):
if x != y and (y, x) not in arb:
arb.append((x, y))
print(arb)
Вывод,
[(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]