I am trying to find the common neighbor of a node from a graph. But, I am getting the wrong neighbor for node 8. From the dataset, we can say the common neighbor for the node 8 are node 5 and 6 but I am getting node 4 and 5!
Code:
graph <- graph_from_data_frame(df_graph, directed = FALSE)
plot(graph, vertex.label = V(graph)$name)
neighbors(graph, 8, mode="all")
Output:
+ 3/8 vertices, named, from a32ba25:
[1] 4 5 8
Graph:
Could you tell me why I am getting the wrong neighbor?
Reproducible Data:
structure(list(To = c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 4L, 5L, 8L,
8L), From = c(7L, 3L, 4L, 7L, 4L, 5L, 4L, 6L, 6L, 5L, 6L)), class = "data.frame", row.names = c(NA,
-11L))
