本文整理汇总了Python中igraph.Graph.get_shortest_paths方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.get_shortest_paths方法的具体用法?Python Graph.get_shortest_paths怎么用?Python Graph.get_shortest_paths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类igraph.Graph
的用法示例。
在下文中一共展示了Graph.get_shortest_paths方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import get_shortest_paths [as 别名]
graph=np.loadtxt('data/I210/graph.csv', delimiter=',')
od=np.loadtxt('data/I210/od.csv', delimiter=',')
#vertices = [i for i in range(7)]
#edges = [(0,2),(0,1),(0,3),(1,0),(1,2),(1,3),(2,0),(2,1),(2,3),(3,0),(3,1),(3,2),(2,4),(4,5),(4,6),(5,4),(5,6),(6,4),(6,5)]
#g = Graph(vertex_attrs={"label":vertices}, edges=edges, directed=True)
vertices = range(int(np.max(graph[:,1:3]))+1)
#print vertices
edges = graph[:,1:3].astype(int).tolist()
weights = graph[:,3].tolist()
#print edges
#print weights
g = Graph(vertex_attrs={"label":vertices}, edges=edges, directed=True)
out = g.get_shortest_paths(18, to=19, weights=weights, output="vpath")
print out
out = g.get_shortest_paths(18, to=[11,19], weights=weights, output="epath")
print out
print len(g.es)
#print [e for e in g.es]
g.es["weight"] = weights
out = g.get_shortest_paths(18, to=19, weights="weight", output="vpath")
print out
out = g.get_shortest_paths(18, to=[11,19], weights="weight", output="epath")
print out
vertices = range(int(np.max(graph[:,1:3]))+2)
print vertices
print edges