Creating Subgraph using igraph in R

后端 未结 2 1928
遇见更好的自我
遇见更好的自我 2021-01-06 08:48

I need to obtain a subgraph of the seed nodes (the input list of nodes; file.txt) and their first interactors (neighbours) from a graph (g) using igraph. Unfortunately, I am

2条回答
  •  孤城傲影
    2021-01-06 08:57

    There is a built-in igraph function for that. Try make_ego_graph():

    library(igraph)
    graph <- make_ring(7)
    V(graph)$name <- c("A", "B", "C", "D", "E", "F", "G")
    
    # Get the list of induced subgraphs
    subgraph <- make_ego_graph(graph, order=1, c("A", "D", "F"))
    

提交回复
热议问题