tags:

views:

52

answers:

1

Say I have this example graph, i want to find the edges connected to vertex 'a'

 d <- data.frame(p1=c('a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'd'),
                 p2=c('b', 'c', 'd', 'c', 'd', 'e', 'd', 'e', 'e'))

library(igraph)
g <- graph.data.frame(d, directed=FALSE)
print(g, e=TRUE, v=TRUE)

I can easily find a vertex:

 V(g)[V(g)$name == 'a' ]

But i need to reference all the edges connected to the vertex 'a'.

+4  A: 

See the documentation on igraph iterators; in particular the from() and to() functions.

In your example, "a" is V(g)[0], so to find all edges connected to "a":

E(g) [ from(0) ]

Result:

[0] b -- a
[1] c -- a
[2] d -- a
neilfws