Learn R Programming

gRbase (version 1.7-1)

glist2adjMAT: Creates adjacency matrix for a graph from a list of generators

Description

Creates adjacency matrix for a graph from a list of generators. The graph is assumed to be undirected.

Usage

glist2adjMAT(glist, vn = unique(unlist(glist)), result="matrix")
vpaList2adjMAT(glist, vn = unique(unlist(glist)), result="matrix")

Arguments

glist
A list of generators where a generator is a vector of nodes. For glist2adjMAT a vector (v1,...,vn) means that there are undirected edges between all nodes. For vpaList2adjMAT, (v1,...,vn) means that there will be a
vn
The names of the vertices in the graphs. These will be the row and column names of the matrix
result
Either "matrix" or "Matrix" (for a sparse matrix representation)

Value

  • An adjacency matrix (or NULL if glist has length 0)

See Also

ug dag

Examples

Run this code
glist <- list(1:3,2:4,4:5)
am1 <- glist2adjMAT(glist)
am2 <- vpaList2adjMAT(glist)
if (interactive()){
 plot(as(am1, "graphNEL"))
 plot(as(am2, "graphNEL"))
}

Run the code above in your browser using DataLab