有没有一种简单的方法可以转换或获取all_shortest_paths返回的vpath的路径?
library(igraph)
g <- make_ring(10)
# Returns epaths
shortest_paths(g, 1, 6, output="epath")
# Does not return epaths
all_shortest_paths(g, 1, 6)发布于 2016-04-01 03:14:52
您可以使用path=参数使用E()函数将一系列验证转换为边缘列表。
lapply(all_shortest_paths(g, 1, 6)$res, function(x) E(g, path=x))
# [[1]]
# + 5/10 edges:
# [1] 1--10 9--10 8-- 9 7-- 8 6-- 7
#
# [[2]]
# + 5/10 edges:
# [1] 1--2 2--3 3--4 4--5 5--6https://stackoverflow.com/questions/36341526
复制相似问题