【问题标题】:R Igraph subgraph given node index and number of nodes to include in the graphR Igraph 子图给定节点索引和要包含在图中的节点数
【发布时间】:2019-03-28 05:35:19
【问题描述】:

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

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

谢谢

达里奥。

【问题讨论】:

  • neighborhood 将返回锚节点一定距离内的顶点 ID。

标签: r dynamic igraph subgraph


【解决方案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)

【讨论】:

    猜你喜欢
    • 2014-10-19
    • 1970-01-01
    • 2018-07-25
    • 1970-01-01
    • 2021-06-09
    • 1970-01-01
    • 2015-06-28
    • 1970-01-01
    • 2021-09-14
    相关资源
    最近更新 更多