Python igraph: get all possible paths in a directed graph

后端 未结 6 1093
星月不相逢
星月不相逢 2021-01-06 12:49

I am using igraph (Python) and would like to get all possible paths between two nodes in a directed graph. I am aware of the function get_all_shortest_paths, wh

6条回答
  •  一向
    一向 (楼主)
    2021-01-06 13:28

    There is a function called get_all_simple_paths(v, to=None, mode=OUT). Perhaps when the question was asked this was not a feature, but it does exactly what you asked.

    You said:

    would like to get all possible paths between two nodes in a directed graph

    So, if the graph object is g, the start node is source_vertex and the end node is target_vertex you could obtain all the possible paths with:

    g.get_all_simple_paths(source_vertex, target_vertex)
    

    Function documentation in python

提交回复
热议问题