我有一个由3个子图组成的图表:
person1 <- c(0, 0, 1, 3, 6)
person2 <- c(1, 2, 4, 5, 7)
id <- c(0,1, 2, 3, 4, 5, 6, 7)
person <- c("Marc", "Marc","Eric", "Alan", "Henri", "Adele", "Wil", "Marc")
nodes <- data.frame(id, person, stringsAsFactors = FALSE)
union_edges <- data.frame(person1, person2)
library(igraph)
family_tree <- graph_from_data_frame(union_edges)
plot(family_tree)
如何根据节点ID选择所有连接节点的子图?例如,选择一个节点(1,2,4或0)将为我提供这个子图: