| graphH-class {graph} | R Documentation |
This is a class of graphs that are represented in terms of nodes, a list of in-edge identifiers and a list of out-edge identifiers for the nodes. and a hashtable for the edges. This is a suitable representation for a graph with a large number of nodes and relatively few edges.
Objects can be created by calls of the form
new("graphH", graphID, nodes, edges, edgemode, ...).
graphID:"Ruuid". This is an
unique identifier for the graph. Modifying the graph results in a
modification of the graph ID.nodes:"list" with each element
an object of class "gNode". The name of each element is its
node ID.label2nodeID:"character", this
is used internally to map between the node labels and the node IDs.edges:"environment", this is
used as hashtable to store the edges (with edge IDs as keys).edgemode:"directed" or "undirected"
Class "graph", directly.
signature(object = "graphH", Nodes = "missing"):
find the degree of the graph nodes (number of coincident edges).signature(object = "graphH", Nodes = "character"):
find the degree of the specified graph nodes.signature(object = "graphNEL", which="missing"):
A method for obtaining the out edges of the nodes as list, each
element of the list representing the out edges for a particular
node. Each such element is a character vector of end node labels
of the out edges for the corresponding begin nodes.signature(object = "graphNEL", which="character"):
A method for obtaining the out edges of the specified nodes.signature(x = "graphH", which = "missing"): A
method for obtaining all the nodes of a graph as a list of
"gNode" objects.signature(x = "graphH", which = "character"): A
method for obtaining the specified nodes of a graph as a list of
"gNode" objects.signature(x = "graphH"): A method that returns
the graph identifier as a character string.signature(.Object = "graphH"): Initializer
for "graphH" objects.signature(object = "graphH"): A method for
obtaining the node labels of a graph. signature(object="graphH",
value="character"): A method for replacing the node labels in a graph
object. It checks to be sure the values are the right length and
unique. Saikat DebRoy
v <- lapply(letters[1:5], function(l) new("gNode", label=l))
e <- vector("list", 2)
e[[1]] <- new("gEdge", bNode=v[[1]], eNode=v[[2]])
e[[2]] <- new("gEdge", bNode=v[[2]], eNode=v[[3]])
g <- new("graphH", nodes=v, edges=e)
nodes(g)
edges(g)