简体   繁体   English

R Igraph子图给出节点索引和要包含在图中的节点数

[英]R Igraph subgraph given node index and number of nodes to include in the graph

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. 我想根据特定节点绘制图形的一部分,并且理想地是距该节点或多个节点的距离作为子图的一部分。

The data.frame that I am graphing is as follows: 我正在绘制的data.frame如下:

Column 1   Column 2   Sequence
   A          B           1
   A          D           2
   D          B           3
   Z          E           4
   E          D           5

this is the code: 这是代码:

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)

I would like, by specifying an element of column 1 to plot a graph at a certain distance from that node. 我想通过指定第1列的元素来绘制距离该节点一定距离的图形。

Thanks 谢谢

Dario. 达里奥。

This is the answer: 这就是答案:

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.

相关问题 字图-标识节点与子图的联系,而与该子图的从属关系无关 - r igraph - Identify ties of nodes to a subgraph regardless of affiliation to said subgraph R和igraph:基于入射在边缘的其他节点的属性的子图节点 - R and igraph: subgraph nodes based on attributes of other nodes that are incident on edge 使用R中的igraph更快地向图中的节点添加边 - adding edges to nodes in a graph faster with igraph in R 在R中使用igraph创建子图 - Creating Subgraph using igraph in R R中的子图文本分析(igraph) - subgraph text analysis in R (igraph) 子图 igraph 根据特定属性仅包含前 N 个“最大”节点 - Subgraph an igraph to only include the top N "largest" nodes according to a specific attribute 使用igraph可从图中的每个节点到达的最大节点数 - Maximum number of nodes which can be reached from each node in a graph using igraph 根据节点数iGraph / R选择集群 - Selecting clusters based on number of nodes iGraph/R R igraph 从顶点列表中的 igraph object 创建“子图”,如果原始节点中有连接的节点,则推断所选顶点之间的边 - R igraph make “subgraph” from igraph object from list of vertices, infer edges between selected vertices if there are connected nodes in original 如何使用具有 NA 值的顶点属性对 igraph object(图)进行子图化 - R - how to subgraph an igraph object (graph) using vertices attribute that has NA values - R
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM