I use the igraph package, and I'm not sure if this is an error or not, but the output of $ father sometimes makes no sense. In particular, when I rename the vertex attributes.
h<-make_tree(10)
graph.bfs(h, root="1", neimode='out', order=TRUE, father=TRUE,unreachable=FALSE)
plot(h,layout=layout_as_tree)
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)
I get output as below
#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 renamed vertex attributes
$order
+ 10/10 vertices, named, from 170f7a0:
[1] 3 4 5 7 2 8 9 6 10 1
$rank
NULL
$father
+ 10/10 vertices, named, from 170f7a0:
[1] 3 4 5 7 2 8 9 6 10 1
I don’t understand why the father is mistaken for the case of renamed vertex attributes. For example, the first element must be NA, but it is not.
Can someone explain what is happening? If so, how to do it so that my father’s elements reflect something similar to the first case.
source
share