My problem is all simple paths problem on hallucinogens. I need to find all the paths between two nodes on the basis of the edges and not nodes
I found this as a solution but this approach is way too slow considering the size of my actual graph.
I would like to know what are the optimizations that could be done to better this.
I have modified the code given in the link to use deque()
This is not of too much help either
The Answer for all_path(1,4):
g=nx.MultiGraph()
g.add_edge(1,1,key='a')
g.add_edge(1,2,key='b')
g.add_edge(2,4,key='c')
g.add_edge(2,4,key='d')
g.add_edge(3,2,key='e')
g.add_edge(3,3,key='f')
g.add_edge(1,3,key='g')
g.add_edge(1,5,key='h')
g.add_edge(5,5,key='i')
Path: 0 --> [(1, 1, 'a'), (1, 2, 'b'), (2, 4, 'c')] Path: 1 --> [(1, 1, 'a'), (1, 2, 'b'), (2, 4, 'd')] Path: 2 --> [(1, 1, 'a'), (1, 3, 'g'), (3, 2, 'e'), (2, 4, 'c')] Path: 3 --> [(1, 1, 'a'), (1, 3, 'g'), (3, 2, 'e'), (2, 4, 'd')] Path: 4 --> [(1, 1, 'a'), (1, 3, 'g'), (3, 3, 'f'), (3, 2, 'e'), (2, 4, 'c')] Path: 5 --> [(1, 1, 'a'), (1, 3, 'g'), (3, 3, 'f'), (3, 2, 'e'), (2, 4, 'd')] Path: 6 --> [(1, 2, 'b'), (2, 4, 'c')] Path: 7 --> [(1, 2, 'b'), (2, 4, 'd')] Path: 8 --> [(1, 3, 'g'), (3, 2, 'e'), (2, 4, 'c')] Path: 9 --> [(1, 3, 'g'), (3, 2, 'e'), (2, 4, 'd')] Path: 10 --> [(1, 3, 'g'), (3, 3, 'f'), (3, 2, 'e'), (2, 4, 'c')] Path: 11 --> [(1, 3, 'g'), (3, 3, 'f'), (3, 2, 'e'), (2, 4, 'd')]