igraph 패키지를 사용하고 있으며 버그인지 여부는 확실하지 않지만 $ father 출력은 때때로 의미가 없습니다. 특히, 내가 꼭지점 속성의 이름을 바꿀 때.igraph의 BFS 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
나는 이름을 바꾼 정점의 아버지는 경우 잘못된 속성을 왜 이해가 안
#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
아래와 같은 출력을 얻을 수 있습니다. 예를 들어, 첫 번째 요소는 NA이지만 그렇지 않아야합니다.
누군가 무슨 일이 일어 났는지 설명 할 수 있습니까? 그렇다면 어떻게하면 내 아버지 요소가 첫 번째 경우와 비슷한 것을 반영하도록이 문제를 해결할 수 있습니다.
감사합니다. 그러나이 예제를 시도하십시오. 코드에 버그가 있습니다. 'tree <-graph_from_literal (3 + 5 : 6,6- + 2,3-3-4); obj <-graph.bfs (tree, root = 3, neimode = "out", father = TRUE, order = TRUE, unreachable = FALSE); obj $ order; obj $ father'. 출력은'obj $ order = 6 2'및'obj $ father = 3 5 6 2 4'입니다. 그러나 나는 그것이'obj $ order = 3 5 6 4 2'와'obj $ father = NA 3 3 3 2'라고 기대합니다. 결과는 변경되지 않는다 –
dexter
'graph_from_literal'을 사용하면 문자로 저장되는 정점 이름이 자동으로 할당되기 때문입니다. 이 예에서,'root = 3' 인자는 노드 "6"('V (tree) $ name [3]') 인 세 번째 노드를 호출합니다. 인수를'bfs (tree, root = '3', neimode = "out", father = TRUE, order = TRUE, unreachable = FALSE)'로 변경하십시오. – paqmo
'order' 결과와'father' 결과가 정확히 일치하지 않기 때문에 여전히 이상한 것들이 있습니다. 그것은 6이 2가 아니라 4의 아버지임을 나타냅니다. 버그 일 수 있습니다. – paqmo