如何使用igraph获取最短路径上的顶点?


问题内容

igraph用来生成成对的顶点之间的最短路径距离的矩阵,但是我不知道如何返回顶点。到目前为止,我有:

path_length_matrix = ig_graph.shortest_paths_dijkstra(None,None,"distance", "ALL")

我正在寻找一个返回路径矩阵(例如距离矩阵)的函数,但是在igraph文档中看不到任何显示如何获取路径的函数


问题答案:

get_shortest_paths我相信您需要的功能。参见http://packages.python.org/python-
igraph/igraph.GraphBase-
class.html#get_shortest_paths

您需要为每个源顶点分别调用它,并且它将为每对节点仅提供一条(任意)最短路径。如果您需要所有最短路径,请参见get_all_shortest_pathshttp :
//packages.python.org/python-igraph/igraph.GraphBase-
class.html#get_all_shortest_paths