Path finder for network link wiring
If you want to work with graphs in Python, you should have a look at the excellent module networkx. It has (usually fast) implementations of the most common (and many not so common) operations on directed and undirected graphs.
Your case in particular, finding all simple paths (i.e. paths without repeating nodes) between two nodes, is already implemented:
import networkx as nx

g = nx.Graph()  # bi-directional edges. Use nx.DiGraph() if you want to explicitly specify directions
g.add_edges_from([(&quot;A&quot;, &quot;B&quot;), (&quot;B&quot;, &quot;C&quot;), (&quot;C&quot;, &quot;D&quot;), (&quot;C&quot;, &quot;E&quot;), (&quot;E&quot;, &quot;A&quot;)])
g.add_edge(&quot;E&quot;, &quot;D&quot;)  # can also add individual edges

for path in nx.all_simple_paths(g, source=&quot;A&quot;, target=&quot;B&quot;):
    print(path)

# ['A', 'B']
# ['A', 'E', 'C', 'B']
# ['A', 'E', 'D', 'C', 'B']

If you want to associate data with each edge and get back only this data, this is also possible:
g = nx.Graph()  # bi-directional edges. Use nx.DiGraph() if you want to explicitly specify directions
g.add_edges_from([(&quot;A&quot;, &quot;B&quot;, {&quot;sku&quot;: &quot;SEGMENT1&quot;}),
                  (&quot;B&quot;, &quot;C&quot;, {&quot;sku&quot;: &quot;SEGMENT2&quot;}),
                  (&quot;C&quot;, &quot;D&quot;, {&quot;sku&quot;: &quot;SEGMENT3&quot;}),
                  (&quot;C&quot;, &quot;E&quot;, {&quot;sku&quot;: &quot;SEGMENT4&quot;}),
                  (&quot;E&quot;, &quot;A&quot;, {&quot;sku&quot;: &quot;SEGMENT5&quot;})])
g.add_edge(&quot;E&quot;, &quot;D&quot;, sku=&quot;SEGMENT6&quot;)  # can also add individual edges

paths = nx.all_simple_paths(g, source=&quot;A&quot;, target=&quot;B&quot;)
for path in map(nx.utils.pairwise, paths):
    for edge in path:
        print(edge, g.edges[edge][&quot;sku&quot;])
    print()

# ('A', 'B') SEGMENT1
# 
# ('A', 'E') SEGMENT5
# ('E', 'C') SEGMENT4
# ('C', 'B') SEGMENT2
# 
# ('A', 'E') SEGMENT5
# ('E', 'D') SEGMENT6
# ('D', 'C') SEGMENT3
# ('C', 'B') SEGMENT2

It even allows you to easily visualize the graph:
import matplotlib.pyplot as plt

nx.draw(g, with_labels=True, node_color=&quot;white&quot;)
plt.show()


Or, more fancy:
pos = nx.spring_layout(g)
labels = dict(zip(g.edges, [g.edges[e][&quot;sku&quot;] for e in g.edges]))
nx.draw(g, with_labels=True, node_color=&quot;white&quot;, pos=pos)
nx.draw_networkx_edge_labels(g, pos=pos, edge_labels=labels)
plt.show()