graph-class: Class "graph"

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

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

A virtual Class: No objects may be created from it.

Slots

edgeData:

An attrData instance for edge attributes.

nodeData:

An attrData instance for node attributes.

graphData:

A list for graph-level attributes. Only mandatory list item is edgemode which indicates whether edges are "directed" or "undirected"

renderInfo:

A list of graph rendering information.

Methods

nodes

return a character vector containing the names of the nodes of the graph

nodes<-

rename the nodes of the graph

show

signature(object = "graph"):A print method for the graph.

acc

signature(object = "graph"): find all nodes accessible from the specified node.

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.

connComp

signature(object = "graph"): find the connected components of a graph.

degree

signature(object = "graph"): find the degree of a node (number of coincident edges).

degree

signature(object = "MultiGraph"): find the degree of a node (number of coincident edges).

dfs

signature(object = "graph"): execute a depth first search on a graph starting with the specified node.

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.

edgeDataDefaults

Get and set default attributes for the edges in the graph.

edgeData

Get and set attributes for edges in the graph

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.

edgeWeights

Return a list of edge weights in a list format similar to the edges method.

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.

isAdjacent

signature(from="character", to="character"): Determine if edges exists between nodes.

isConnected

signature(object = "graph"): A boolean that details if a graph is fully connected or not.

isDirected

Return TRUE if the graph object has directed edges and FALSE otherwise.

join

signature(x = "graph", y = "graph"): returns the joining of two graphs. Nodes which are shared by both graphs will have their edges merged. Note that edgeWeights for the resulting graph are all set to 1. Users wishing to preserve weights in a join operation must perform addEdge operations on the resulting graph to restore weights.

nodes<-

A generic function that allows different implementations of the graph class to reset the node labels

nodeDataDefaults

Get/set default attributes for nodes in the graph.

nodeData

Get/set attributes for nodes in the graph.

numEdges

signature(object = "graph"): compute the number of edges in a graph.

numNodes

signature(object = "graph"): compute the number of nodes in a graph.

plot

Please see the help page for the plot,graph-method method in the Rgraphviz package

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.

edgeNames

signature(object = "graph"): Returns a vector of the edge names for this graph, using the format tail\~head, where head is the name of the tail node and head is the name of the head node.

updateGraph

signature(object = "graph"): Updates old instances of graph objects.

Author(s)

R. Gentleman and E. Whalen.

References

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

See Also

graphNEL-class, graphAM-class, distGraph-class.

Examples

1
2
3
4
5
6
  set.seed(123)
  g1 <- randomGraph(letters[1:10], 1:4, p= 0.3)
  numEdges(g1)
  edgeNames(g1)
  edges(g1)
  edges(g1, c("a","d")) # those incident to 'a' or 'd'

Example output

Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, basename, cbind, colMeans, colSums, colnames,
    dirname, do.call, duplicated, eval, evalq, get, grep, grepl,
    intersect, is.unsorted, lapply, lengths, mapply, match, mget,
    order, paste, pmax, pmax.int, pmin, pmin.int, rank, rbind,
    rowMeans, rowSums, rownames, sapply, setdiff, sort, table, tapply,
    union, unique, unsplit, which, which.max, which.min

[1] 21
 [1] "a~g" "a~i" "a~b" "a~d" "a~e" "a~f" "a~h" "b~f" "b~j" "b~d" "b~e" "b~h"
[13] "c~h" "d~e" "d~f" "d~h" "e~f" "e~h" "f~j" "f~h" "g~i"
$a
[1] "g" "i" "b" "d" "e" "f" "h"

$b
[1] "f" "j" "a" "d" "e" "h"

$c
[1] "h"

$d
[1] "a" "b" "e" "f" "h"

$e
[1] "a" "b" "d" "f" "h"

$f
[1] "b" "j" "a" "d" "e" "h"

$g
[1] "a" "i"

$h
[1] "c" "a" "b" "d" "e" "f"

$i
[1] "a" "g"

$j
[1] "b" "f"

$a
[1] "g" "i" "b" "d" "e" "f" "h"

$d
[1] "a" "b" "e" "f" "h"

graph documentation built on Nov. 8, 2020, 6:02 p.m.