I am sorry. I try it again.
I wish to subset a graph by an arry of vertex ids ( in my example this is zu). My subset should comprise my vertices of interest (zu) and the next neighouring vertices.
Example:
a-----b-----c------d-------e
| |
f g
vertices of interest: c and d
I get: b-c-d-e
|
g
Typing
induced.subgraph (g, zu)
generates a graph with the vertices (of zu) and with edges only between the (subsetted) vertices (of zu). I want a subset that includes the vertices (of zu) and all the edges of the vertices (of zu) and the corresponding vertices.
I tried:
idx <- unique (as.vector (g[zu, edges=TRUE])) # get edges ids for vertices of interest
idx <- idx[-1] # remove 0
ggzu <- subgraph.edges (g, idx)
And the results are okay but I guess its is very clumsy.
Thanks
dput (ggzu)
structure(list(3, FALSE, c(1, 2, 2), c(0, 0, 1), c(0, 1, 2),
c(0, 1, 2), c(0, 0, 1, 3), c(0, 2, 3, 3), list(c(1, 0, 1),
structure(list(), .Names = character(0)), structure(list(
name = c("16052513", "16052618", "rs3013006"), x = c(16052513L,
16052618L, 16054667L), y = c(2.547104, 1.587586,
1.543943)), .Names = c("name", "x", "y")), structure(list(
weight = c(0.725426, 0.681783, 0.86216), color = c("blue",
"grey", "red")), .Names = c("weight", "color")))), class = "igraph")