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
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"))