edgeMatrix {graph}R Documentation

Compute an Edge Matrix for a Graph

Description

For our purposes an edge matrix is a matrix with two rows and as many columns as there are edges. The entries in the first row are the index of the node the edge is from, those in the second row indicate the node the edge is to.

If the graph is “undirected” then the duplicates option can be used to indicate whether reciprocal edges are wanted. The default is to leave them out. In this case the notions of from and to are not relevant.

Usage

edgeMatrix(object, duplicates=FALSE)
edgeWeightVector(g, ...)

Arguments

object An object that inherits from graph.
g An object that inherits from graph.
duplicates Whether or not duplicate edges should be produced for “undirected” graphs.
... arguments passed to edgeMatrix.

Details

Implementations for both graphNEL and clusterGraph are available.

Value

A matrix with two rows, from and to, and as many columns as there are edges. Entries indicate the index in the node vector that corresponds to the appropriate end of the edge.

Author(s)

R. Gentleman

See Also

edges

Examples

  set.seed(123)
  g1 <- randomGraph(letters[1:10], 1:4, p=.3)
  edgeMatrix(g1)
  g2 <- new("clusterGraph", clusters=list(a=c(1,2,3), b=c(4,5,6)))
  edgeMatrix(g2)
  edgeWeightVector(g2)

[Package Contents]