繁体   English   中英

R中的igraph:get.shortest.paths错误,但shortsts.paths错误

[英]igraph in R: error with get.shortest.paths but not with shortest.paths

我曾经遇到过在使用R. IGRAPH奇怪的行为shortest.paths命令返回正确的结果, 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

有谁知道,问题是什么?

谢谢,Zbynek

我的猜测是你有一个有向图。 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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM