graph-class {graph}R Documentation

Class "graph"

Description

A virtual class that all graph classes should extend.

Details

degree returns either a named vector (names correspond to the nodes in the graph) containing the degree for undirected graphs or a list with two components, inDegree and outDegree for directed graphs.

connComp returns a list of the connected components. Each element of this list contains the labels of all nodes in that component.

For a directed graph or digraph the underlying graph is the graph that results from removing all direction from the edges. This can be achieved using the function ugraph.

A weakly connected component of a digraph is one that is a connected component of the underlying graph. This is the default for connComp. A digraph is strongly connected if every two vertices are mutually reachable. A strongly connected component of a digraph, D, is a maximal strongly connected subdigraph of D. See the RBGL package for an implementation of Trajan's algorithm to find strongly connected components (strongComp).

In the graph implementation of connComp weak connectivity is used. If the argument to connComp is a directed graph then ugraph is called to create the underlying undirected graph and that is used to compute connected components. Users who want different behavior are encouraged to use RBGL.

Objects from the Class

Slots

edgemode:
Indicates whether edges are "directed" or "undirected"

Methods

connComp
signature(object = "graph"): find the connected components of a graph.
isConnected
signature(object = "graph"): A boolean that details if a graph is fully connected or not.
acc
signature(object = "graph"): find all nodes accessible from the specified node.
degree
signature(object = "graph", Nodes = "missing"): find the degree of a node (number of coincident edges).
degree
signature(object = "graph", Nodes = "ANY"): as above.
dfs
signature(object = "graph"): execute a depth first search on a graph starting with the specified node.
intersection
signature(x = "graph", y = "graph"): compute the intersection of the two supplied graphs. They must have identical nodes. Currently this returns an object of class graphNEL. With edge weights of 1 for any matching edge.
join
signature(x = "graph", y = "graph"): returns the joining of two graphs. Nodes which are shared by both graphs will have their edges merged.
union
signature(x = "graph", y = "graph"): compute the union of the two supplied graphs. They must have identical nodes. Currently this returns an object of class graphNEL.
complement
signature(x = "graph"): compute the complement of the supplied graph. The complement is defined with respect to the complete graph on the nodes in x. Currently this returns an object of class graphNEL.
numNodes
signature(object = "graph"): compute the number of nodes in a graph.
edges
signature(object="graph", which="character"): return the edges indicated by which. which can be missing in which case all edges are returned or it can be a character vector with the node labels indicating the nodes whose edge lists are wanted.
nodes<-
A generic function that allows different implementations of the graph class to reset the node labels
plot
Please see the help page for the plot.graph method in the Rgraphviz package
edgemode
signature(object="graph"): return the edgemode for the graph. Currently this can be either directed or undirected.
edgemode<-
signature(object="graph", value="character"): set the edgemode for the graph. Currently this can be either directed or undirected.

Author(s)

R. Gentleman and E. Whalen.

References

Graph Theory and its Applications, J. Gross and J. Yellen.

See Also

graphNEL-class, distGraph-class

Examples

  set.seed(123)
  g1 <- randomGraph(letters[1:10], 1:4, p=.3)
  edges(g1)
  edges(g1, "a")


[Package Contents]