>
> vv <- neighborhood(g, order=1, nodes=mynodes, mode="in")
> subgraph(g, unique(unlist(vv)))
>
The problem with this solution is that it doesn't keep the edges.
Subgraph returns only the vertices. I cannot think of a case where I'd
need the vertices and not the edges.
Is there any way to do what subgraph does, but keeping the edges?
I am not sure what you mean about not keeping the edges. 'subgraph' calculates in fact the induced subgraph of the given vertices, and it certainly keeps the edges:
> library(igraph)
> g <- graph.full(10)
> g2 <- subgraph(g, 0:4)
> summary(g2)
Vertices: 5
Edges: 10
Directed: FALSE
No graph attributes.
No vertex attributes.
No edge attributes.
G.
[...]