【发布时间】:2020-04-13 16:49:28
【问题描述】:
假设我使用 igraph 包创建了一个随机图:
n=6 # number of vertices
F <- erdos.renyi.game(n, p.or.m=0.7, directed=FALSE)
m=ecount(F)
min = 1 # 1 km
max = 50 # 50 km
F <- set.edge.attribute(F, name="distance", value=runif(m , min , max))
plot(F, layout=layout.fruchterman.reingold)
distances(F)
distances(F, weights = E(F)$distance)
distances(F, v = 1, to = 6, weights = E(F)$distance)
get.all.shortest.paths(F, 1, to = V(F))
我们知道distances(F, weights = E(F)$distance) 给出了与图中最短路径相关的流的三次矩阵。
我想要与以下行相同:
distances(F, weights = E(F)$distance) # matrix of shortests paths flows between any two vertices
distances(F, v = 1, to = 6, weights = E(F)$distance)
get.all.shortest.paths(F, 1, to = V(F)) # gives the shortests paths between 1 and other vertices
这次我需要矩阵中关联流的最长路径。 我不知道“igraph”是否可以做到这一点。
感谢您的帮助!
【问题讨论】:
标签: r