for this graph:
import igraph
G = ig.Graph()
#ring
G.add_vertices(4)
G.add_edges([(0,1), (1,2),(2,3),(3,0)])
G = G.as_directed()
print G.is_directed()
print G
If I apply the function from above https://stackoverflow.com/a/29324009/2772305
like
for p in find_all_paths(G,0,0):
print p
I get only
[0]
as a result, whereas there should be a second path [0,1,2,3,0]
imho
How do i find all paths if there are such rings in a graph?
in networkx, it is possible to get the desired result with all_simple_paths:
import networkx as nx
G = nx.MultiDiGraph()
G.add_path(['a','b','c','d','a'])
G.add_path(['a','e','f','g'])
G.add_path(['a','a'])
for p in nx.all_simple_paths(G,'a','a'):
print p
Result:
['a', 'a']
['a', 'b', 'c', 'd', 'a']
As said in above comments , the all_simple_paths function exists only in networkx, which is not suitable to process huge graphs due to performance issues. Is there any way to bring the all_simple_paths from networkx to igraph ?