首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >R中的图形: get.shortest.paths错误,而shortest.paths错误

R中的图形: get.shortest.paths错误,而shortest.paths错误
EN

Stack Overflow用户
提问于 2013-12-16 08:16:45
回答 1查看 2K关注 0票数 1

我在R. shortest.paths命令中遇到了使用i图形返回正确结果、get.shortest.paths返回警告而没有结果的奇怪行为。

代码语言:javascript
复制
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

有人知道吗,有什么问题吗?

谢谢你,兹比尼克

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-16 09:40:48

我猜你有一个有向图。shortest.paths函数将告诉您最短无向路径的长度。get.shortest.paths函数告诉您,顶点之间没有有向路径。下面是似乎正在发生的最简单的例子:

代码语言:javascript
复制
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
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20606174

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档