[英]r igraph - Identify ties of nodes to a subgraph regardless of affiliation to said subgraph
[英]R Igraph subgraph given node index and number of nodes to include in the graph
我想根据特定节点绘制图形的一部分,并且理想地是距该节点或多个节点的距离作为子图的一部分。
我正在绘制的data.frame如下:
Column 1 Column 2 Sequence
A B 1
A D 2
D B 3
Z E 4
E D 5
这是代码:
network <- graph.data.frame(data_to_graph[,c(1,2)])
subnetwork <- induced.subgraph(network, vids = 30, impl = 'copy_and_delete', eids = c(5,6,7,8,9,10,11,12,13,14,15))
plot(subnetwork)
我想通过指定第1列的元素来绘制距离该节点一定距离的图形。
谢谢
达里奥。
这就是答案:
distan <- 3
node <- "node name"
subnetwork <- induced.subgraph(network, vids = as.vector(unlist(neighborhood(network, distan, nodes = node, mode = 'all'))))
plot.igraph(subnetwork, vertex.size=10)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.