简体   繁体   English

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

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

I have encountered strange behavior using igraph in R. shortest.paths command returns correct results, get.shortest.paths returns warning and no results. 我曾经遇到过在使用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

Does anyone know, whats the problem? 有谁知道,问题是什么?

Thanks, Zbynek 谢谢,Zbynek

My guess is that you have a directed graph. 我的猜测是你有一个有向图。 The shortest.paths function will tell you the length of the shortest undirected path. shortest.paths函数将告诉您最短的无向路径的长度。 The get.shortest.paths function tells you that there is no directed path between the vertices. get.shortest.paths函数告诉您顶点之间没有有向路径。 Below is the simplest example of what seems to be happening: 以下是似乎正在发生的事情的最简单的例子:

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