Learn R Programming

gRbase (version 1.6-4)

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 = uniquePrim(c(glist, recursive = TRUE)), result="matrix")
vpaL2adjMAT(vpaL, vn=uniquePrim(c(vpaL, recursive=TRUE)), result="matrix")

Arguments

glist
A list of generators for an undirected graph.
vpaL
A list of the form (v,pa(v)) specifying a directed acyclic graph.
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 <- vpaL2adjMAT(glist)
## plot(coerceGraph(am1, "igraph"))
## plot(coerceGraph(am2, "igraph"))

Run the code above in your browser using DataLab