2013-12-16 173 views
1

我在R中使用igraph遇到了奇怪的行为。 shortest.paths命令返回正确结果,get.shortest.paths返回警告并且没有结果。igraph in R:error with get.shortest.paths but not with 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 

有谁知道,最新的问题是什么?

感谢, 兹比涅克

回答

1

我的猜测是,你有向图。 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 vertices 
+0

太棒了!谢谢,那就是问题所在 – Zbynek

相关问题