graphAM-class: Class "graphAM"

Description Details Objects from the Class Slots Extends Constructor Methods Author(s) See Also Examples

Description

A graph class where node and edge information is represented as an adjacency matrix. The adjacency matrix is square and element adjMat[i, j] is one if there is an edge from node i to node j and zero otherwise.

Details

The non-zero matrix values can be used to initialize an edge attribute. If this is desired, use the values argument in the call to new and provide a list with a single named element. The name determines the attributes and the value provides the default value for that attribute.

Objects from the Class

Objects can be created by calls of the form graphAM(adjMat, edgemode, values).

Slots

adjMat:

An adjacency "matrix" describing the graph structure. The colnames of the matrix will be used as node names for the graph if present.

edgeData:

Storage for edge attributes.

nodeData:

Storage for node attributes.

Extends

Class "graph", directly.

Constructor

graphAM(adjMat=matrix(integer(), 0, 0), edgemode='undirected', values=NA) creates a graphAM instance.

adjMat

An integer matrix specifying which nodes have edges between them.

edgemode

Either "directed" or "undirected".

values

A named list of length 1, used (rather obscurely) to specify that non-zero adjMat values initialize an edge attribute. The name of the single element in that list becomes the name of that attribute, with the specified default value. This default value is, however, never used: the specified edge attribute always has the value contained in the adjacency matrix, which is traditionally 1, but can be any positive number.

Methods

addEdge

signature(from = "character", to = "character", graph = "graphAM", weights = "missing"): ...

addNode

signature(object = "graphAM", nodes = "character"): ...

clearNode

signature(node = "character", object = "graphAM"): ...

coerce

signature(from = "graphAM", to = "graphNEL"): ...

coerce

signature(from = "graphAM", to = "graphBAM"): ...

coerce

signature(from = "graphAM", to = "matrix"): In converting to a matrix, if an edge attribute named "weight" is defined, the non-zero elements of the matrix will contain the corresponding attribute value. For more flexible matrix conversion, see toMatrix.

coerce

signature(from = "matrix", to = "graphAM"): This coerce method exists for symmetry. In most cases, creating a new graphAM instance using new gives one more control over the resulting graph.

edges

signature(object = "graphAM", which = "missing"): ...

edges

signature(object = "graphAM", which = "character"): ...

initialize

signature(.Object = "graphAM"): ...

inEdges

signature(node = "character", object = "graphNEL"): Return the incoming edges for the specified nodes. See inEdges.

isAdjacent

signature(object = "graphAM", from = "character", to = "character"): ...

nodes<-

signature(object = "graphAM", value = "character"): ...

nodes

signature(object = "graphAM"): ...

numEdges

signature(graph = "graphAM"): ...

numNodes

signature(object = "graphAM"): ...

removeEdge

signature(from = "character", to = "character", graph = "graphAM"): ...

removeNode

signature(node = "character", object = "graphAM"): ...

Author(s)

Seth Falcon

See Also

graph-class, graphNEL-class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
mat <- rbind(c(0, 0, 1, 1),
             c(0, 0, 1, 1),
             c(1, 1, 0, 1),
             c(1, 1, 1, 0))
rownames(mat) <- colnames(mat) <- letters[1:4]
g1 <- graphAM(adjMat=mat)
stopifnot(identical(mat, as(g1, "matrix")), validObject(g1))

## now with weights:
mat[1,3] <- mat[3,1] <- 10
gw <- graphAM(adjMat=mat, values=list(weight=1))

## consistency check:
stopifnot(identical(mat, as(gw, "matrix")),
          validObject(gw),
          identical(gw, as(as(gw, "graphNEL"), "graphAM")))

pshannon-bioc/graph documentation built on May 26, 2019, 10:32 a.m.