我在R. shortest.paths命令中遇到了使用i图形返回正确结果、get.shortest.paths返回警告而没有结果的奇怪行为。
shortest.paths(g, v=2795, to=2839) # correct
[,1]
[1,] 3930.4
get.shortest.paths(g, from=2795, to=2839) # warning and no results
[[1]]
numeric(0)
Warning message:
In get.shortest.paths(g_novy, from = 2795, to = 2839) :
At structural_properties.c:5296 :Couldn't reach some vertices有人知道吗,有什么问题吗?
谢谢你,兹比尼克
发布于 2013-12-16 09:40:48
我猜你有一个有向图。shortest.paths函数将告诉您最短无向路径的长度。get.shortest.paths函数告诉您,顶点之间没有有向路径。下面是似乎正在发生的最简单的例子:
g <- graph(1:2)
plot(g)
shortest.paths(g, v=2, to=1)
# [,1]
# [1,] 1
get.shortest.paths(g, from=2, to=1)
# [[1]]
# numeric(0)
#
# Warning message:
# In get.shortest.paths(g, from = 2, to = 1) :
# At structural_properties.c:706 :Couldn't reach some verticeshttps://stackoverflow.com/questions/20606174
复制相似问题