R Igraph子图给出了要包含在图中的节点索引和节点数 [英] R Igraph subgraph given node index and number of nodes to include in the graph

查看:79
本文介绍了R Igraph子图给出了要包含在图中的节点索引和节点数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据特定节点绘制图的一部分,理想情况下是作为子图的一部分到该节点或多个节点的距离.

I want to plot a portion of a graph according to a specific node and ideally a distance from that node or a number of nodes as part of the sub graph.

我正在绘制的data.frame如下:

The data.frame that I am graphing is as follows:

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列的元素在距该节点一定距离处绘制图形.

I would like, by specifying an element of column 1 to plot a graph at a certain distance from that node.

谢谢

达里奥.

推荐答案

这是答案:

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)

这篇关于R Igraph子图给出了要包含在图中的节点索引和节点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆