Am2Al {RBGL}R Documentation

Convert adjacency matrix to adjacency 'list' in 2xNE format

Description

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]

Usage

Am2Al(mat)

Arguments

mat a binary square matrix with nc cols representing a graph with nc vertices

Details

Note that the resulting matrix has zero-based entries for convenient use in the Boost library edgelist representation.

Value

2 x NE matrix

Examples

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)

[Package Contents]