【问题标题】:subset igraph object to just 2nd order ego graph of certain vertices将 igraph 对象子集到某些顶点的二阶自我图
【发布时间】:2017-06-23 02:16:34
【问题描述】:

this question here 的基础上,有没有办法扩展这个子图以包括以两度连接到顶点子集的顶点?我正在考虑一个类似于 make_ego_graph() 中 order=2 和 mode="in" 中的函数的命令。我正在使用有向图对象。

到目前为止,我已经想出了以下内容,但它没有生成我正在寻找的图表。

first_degree <- V(graph)$condition == "something"
second_degree <- V(graph)[to(first_degree)]
edges_subset <- E(graph)[to(first_degree) | to(second_degree)]
desired_subset <- subgraph.edges(graph, edges_subset)

感谢您给我的任何建议!

【问题讨论】:

    标签: r igraph subgraph network-analysis


    【解决方案1】:

    这不是最优雅的解决方案,但它似乎有效。

     ego.list <- make_ego_graph(graph, order=2, nodes=V(graph)$condition=="something")
    
       desired_subset <- NULL
       for (i in seq_along(ego.list)){
       x <- ego.list[[i]]
       desired_subset <- graph.union(desired_subset, x)
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多