igraph - Neighbors as subgraph - make_ego_graph() as single graph

拟墨画扇 提交于 2019-11-30 13:26:42

Indeed make_ego_graph returns a graph for the neighbourhood for each of the vertices in the list nodes.

I suggest you to solve it using the list of edges you need to include in your subgraph, instead of the list of vertices. Assuming your list of vertices is resolved like list_of_vertices <- V(Grph)$year == "1952" or whatever it is your condition, you would do something like,

list_of_edges <- E(your_graph)[from(list_of_vertices) | to(list_of_vertices)]
your_subgraph <- subgraph.edges(your_graph, list_of_edges)

(I'm using a directed graph.)

Hope it helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!