Am2Al {RBGL} | R Documentation |
Let NV be the number of nodes of a graph and NE be the number of edges. This function converts such an NVxNV adjacency matrix B to a 2 X NE matrix L where NE = sum(B). The kth column of the matrix represents the edge L[1,k]->L[2,k]
Am2Al(mat)
mat |
a binary square matrix with nc cols representing a graph with nc vertices |
Note that the resulting matrix has zero-based entries for convenient use in the Boost library edgelist representation.
2 x NE matrix
set.seed(223) V <- 1:10 M <- 1:4 Gm <- randomGraph(V,M,.3) cat("as adjacency matrix:\n") print(GmM <- adjMat(Gm)) Gl <- Am2Al(GmM) cat("as edge list:\n") print(Gl)