I have a directed graph as follows:
I created it with networkx and plotted it with ipycytoscape. The graph is a directed graph. All the edges have One and only one direction.
The question is how to find from a particular node all the paths between that node and node one. Since the graph is directed only paths in which ALL THE DIRECTIONS OF THE EDGES is the same are valid. IN the figure there are two paths between 6 and one. It would be possible at a first glace to thing about the blue path but in that case the direction of the edge 4-6 is different than the other ones.
nodes = [1,2,3,4,5,6,7,8]
children = [[2],[3,4],[5,6],[6,7],[8],[],[8],[]]
G2 = nx.Graph()
G2.add_nodes_from(nodes)
for i,child in enumerate(children):
for c in child:
G2.add_edge(i+1, c)
cyto = CytoscapeWidget()
cyto.graph.add_graph_from_networkx(G2, directed=True)
cyto.set_layout(name='dagre', nodeSpacing=10, edgeLengthVal=10)
display(cyto)
What I am looking for is the networks method that gives me the list of paths between two nodes. pseudocode:
for node1 in G.nodes:
for node2 in G.nodes:
list_of_paths = networks_method???(node1,node2)
NOTE: The graph is such that the arrows (directionality) go always from a smaller number to a higher one. 2 can be parent of 3 but never the other way around.