簡體   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