如何使用igraph获取最短路径上的顶点?
问题内容:
我igraph
用来生成成对的顶点之间的最短路径距离的矩阵,但是我不知道如何返回顶点。到目前为止,我有:
path_length_matrix = ig_graph.shortest_paths_dijkstra(None,None,"distance", "ALL")
问题答案:
get_shortest_paths
我相信您需要的功能。参见http://packages.python.org/python-
igraph/igraph.GraphBase-
class.html#get_shortest_paths
您需要为每个源顶点分别调用它,并且它将为每对节点仅提供一条(任意)最短路径。如果您需要所有最短路径,请参见get_all_shortest_paths
:http :
//packages.python.org/python-igraph/igraph.GraphBase-
class.html#get_all_shortest_paths