graphAM-class | R Documentation |
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.
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 can be created by calls of the form graphAM(adjMat,
edgemode, values)
.
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.
Class "graph"
, directly.
graphAM(adjMat=matrix(integer(), 0, 0), edgemode='undirected', values=NA)
creates a graphAM instance.
An integer
matrix specifying which nodes have
edges between them.
Either "directed" or "undirected".
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.
signature(from = "character", to = "character", graph = "graphAM", weights = "missing")
: ...
signature(object = "graphAM", nodes = "character")
: ...
signature(node = "character", object = "graphAM")
: ...
signature(from = "graphAM", to = "graphNEL")
: ...
signature(from = "graphAM", to = "graphBAM")
: ...
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
.
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.
signature(object = "graphAM")
: ...
signature(.Object = "graphAM")
: ...
signature(node = "character", object =
"graphNEL")
: Return the incoming edges for the specified
nodes. See inEdges
.
signature(object = "graphAM", from = "character", to = "character")
: ...
signature(object = "graphAM", value = "character")
: ...
signature(object = "graphAM")
: ...
signature(graph = "graphAM")
: ...
signature(object = "graphAM")
: ...
signature(from = "character", to = "character", graph = "graphAM")
: ...
signature(node = "character", object = "graphAM")
: ...
Seth Falcon
graph-class
, graphNEL-class
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")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.