小编dex*_*ter的帖子

igraph 中的 BFS 父属性错误

我正在使用 igraph 包,我不确定它是否是一个错误,但 $father 输出有时没有意义。具体来说,当我重命名顶点属性时。

h<-make_tree(10)

#with normal vertex attributes
graph.bfs(h, root="1", neimode='out', order=TRUE, father=TRUE,unreachable=FALSE) #father output seems correct
plot(h,layout=layout_as_tree)

#with renamed vertex attributes
set.seed(1)
h<-set.vertex.attribute(h, "name", value=sample(1:10,10))
plot(h,layout=layout_as_tree)
graph.bfs(h, root="3", neimode='out', order=TRUE, father=TRUE,unreachable=FALSE)  #father output seems wrong
Run Code Online (Sandbox Code Playgroud)

我获得如下输出

#with normal vertex attributes
$order
+ 10/10 vertices, from ff55a96:
 [1]  1  2  3  4  5  6  7  8  9 10

$rank
NULL

$father
+ 10/10 vertices, from ff55a96:
 [1] NA  1  1  2  2  3  3  4  4  5

#with …
Run Code Online (Sandbox Code Playgroud)

r igraph

5
推荐指数
1
解决办法
185
查看次数

标签 统计

igraph ×1

r ×1