Learn R Programming

gRbase (version 1.3.9)

edgeList: Find edges in a graph and edges not in a graph.

Description

Returns the edges of a graph (or edges not in a graph) where the graph can be either a graphNEL object or an adjacency matrix.

Usage

edgeList(object, matrix = FALSE)
## S3 method for class 'graphNEL':
edgeList(object, matrix = FALSE)
## S3 method for class 'matrix':
edgeList(object, matrix = FALSE)
nonEdgeList(object, matrix = FALSE)
## S3 method for class 'graphNEL':
nonEdgeList(object, matrix = FALSE)
## S3 method for class 'matrix':
nonEdgeList(object, matrix = FALSE)
edgeListMAT(adjmat, matrix = FALSE, edgemode="undirected")
nonEdgeListMAT(adjmat, matrix = FALSE)

Arguments

object
A graphNEL object or an adjacency matrix.
adjmat
An adjacency matrix.
matrix
If TRUE the result is a matrix; otherwise the result is a list.
edgemode
Can be "directed" or "undirected".

Value

  • A list or a matrix with edges.

Details

If object is a matrix, then edgeList() checks if object is symmetrical. If so it is assumed that the graph is undirected; otherwise the graph is assumed to be directed. The workhorse is edgeListMAT.

See Also

as.adjMAT mcs rip moralize jTree

Examples

Run this code
## A graph with edges
g  <- ug(~a:b+b:c+c:d)
gm <- as.adjMAT(g)

edgeList(g)
edgeList(gm)
edgeListMAT(gm)

edgeList(g, matrix=TRUE)
edgeList(gm, matrix=TRUE)
edgeListMAT(gm, matrix=TRUE)

nonEdgeList(g)
nonEdgeList(gm)
nonEdgeListMAT(gm)

## A graph without edges
g  <- ug(~a+b+c)
gm <- as.adjMAT(g)

edgeList(g)
edgeList(gm)
edgeListMAT(gm)

edgeList(g, matrix=TRUE)
edgeList(gm, matrix=TRUE)
edgeListMAT(gm, matrix=TRUE)

nonEdgeList(g)
nonEdgeList(gm)
nonEdgeListMAT(gm)

Run the code above in your browser using DataLab