Igraph get edge from - to value

I have a graphic graph and just want to get every edge from_idand to_id. For example:

g <- erdos.renyi.game(4, 1, type="gnm", directed=FALSE)
E(g)[1] # will return some edge, possibly not the same one
# Edge sequence:
# e       
# e [1] 3 -- 1

I want to get two variables v1, v2where v1 = 3and v2 = 1(equivalent v1 = 1and v2 = 3). I want to do this for all edges in a graph E(g)[x], where x is the loop variable. Is there any way to do this?

thanks

+4
source share
3 answers

get.edges()returns all edges, get.edge()returns one edge. If you need to iterate over all edges, then call get.edges()and go through all the rows of the matrix with two columns, using the apply()or for loop.

+7
source

get.edgelist(g) - , , , :

#     [,1] [,2]
#[1,]    3    1
+4

g - igraph, (g, es = E (g))

0

All Articles