Maps adjacency matrix to edgelist

adj2el(adj, directed = TRUE, names = NULL)

Arguments

adj

matrix or sparse matrix object, the adjacency matrix

directed

boolean, is the graph directed?

names

optional vector with node names. When `NULL` row- and column names of `adj` are used.

Value

a dataframe containing the edgelist

Examples

el <- data.frame(from= c('a','b','b','c','d','d'), to = c('b','c','d','a','b','a'), attr= c( 12, 6, 12 , 6 , 6 , 6 )) adj <- el2adj(el) el1 <- adj2el(adj, directed = TRUE)