在Python-IGraph中获得带有和不带有边缘权重的最短路径

时间:2019-03-20 22:45:55

标签: python igraph shortest-path

我想问一个关于python-igraph中“ get_shortest_paths”函数的问题。您能解释一下在计算路径长度时增加边缘权重的影响吗?我发生了一个非常有趣的事件,无法解释原因:

情况1::边缘权重非零(边缘的属性):"no"
结果weights='weights'

情况2:边缘权重为None:[[], [0, 1], [0, 2], [0, 1, 3]]
结果weights=None

为什么第一个条目会这样改变?= O

我的代码在这里:

[[0], [0, 1], [0, 2], [0, 1, 3]]

其中,案例之间仅更改clust = g1.clusters() for c in clust: print("subgraph:") gcomponent=g1.subgraph(c) u=next(iter(gcomponent.vs)) paths=gcomponent.get_shortest_paths(u,to=None,weights=None,mode=ig.ALL,output="vpath") print(paths) 部分。 如果您能为此提供含义,我将不胜感激!

非常感谢您!

0 个答案:

没有答案
相关问题