graphNEL-class {graph}R Documentation

Class "graphNEL"

Description

This is a class of graphs that are represented in terms of nodes and an edge list. This is a suitable representation for a graph with a large number of nodes and relatively few edges.

Details

The graphNEL class provides a very general structure for representing graphs. It will be reasonably efficient for lists with relatively more nodes than edges. The class is currently able to handle multi-edges and edges of any type.

The edgeL is a named list of the same length as the node vector. The names are the names of the nodes. Each element of edgeL is itself a list. Each element of this (sub)list is a vector (all must be the same length) and each element represents an edge to another node. The sublist named edges holds index values into the node vector. And each such entry represents an edge from the node which has the same name as the component of edgeL to the node with index provided. Another component that is often used is named weights. It represents edge weights. The user can specify any other edge attributes (such as types etc). They are responsible for any special handling that these might require.

Multi-edges are represented by multiple entries. For an undirected instance all edges are reciprocated (there is an edge from A to B and from B to A).

Note that the reason for using indices to represent the to end of a node is so that we can easily support permutation of the node labels as a way to generate randomizations of the graph.

Objects from the Class

Objects can be created by calls of the form new("graphNEL",...).

Slots

nodes:
Object of class "vector".
edgeL:
Object of class "list". The edgeL must be the same length as nodes. The elements of this vector correspond to the same element in nodes. The elements are themselves lists. If the node has any edges then this list will have an element named edges. If edge weights are used then there must be an element named weights and it must be the same length as the edges element.

Extends

Class "graph", directly.

Methods

adj
signature(object = "graphNEL"): A method for finding nodes adjacent to the suplied node.
edgeL
signature(graph = "graphNEL"): A mehtod for obtaining the edge list.
edgeWeights
signature(object = "graphNEL"): A method for obtaining the edge weights.
edges
signature(object = "graphNEL"): A method for obtaining the edges.
nodes
signature(object = "graphNEL"): A method for obtaining the nodes.
numNodes
signature(object = "graphNEL"):A method for determining how many nodes are in the graph.
subGraph
signature(subgraph="character", graph = "graphNEL"):A method for obtaining the induced subgraph based on the set of supplied nodes and the supplied graph.
plot
Please see the help page for plot.graphNEL in the Rgraphviz package
graph2graphviz
signature(object = "graphNEL"): A method that will convert a graphNEL object into a matrix suitable for interaction with Rgraphviz. Not intended to be called directly. This function will insure that no NA's (or other undesired values) are in the graph, or created by coersion.
nodes<-
signature(object="graphNEL", value="character"): A method for replacing the nodes in a graph object. It checks to be sure the values are the right length and unique.

Author(s)

R. Gentleman

See Also

distGraph-class, clusterGraph-class

Examples

   set.seed(123)
   V <- LETTERS[1:4]
   edL <- vector("list", length=4)
   names(edL) <- V
   toE <- LETTERS[4:1]
   for(i in 1:4) 
      edL[[i]] <- list(edges=5-i, weights=runif(1))
   gR <- new("graphNEL", nodes=V, edgeL=edL)
   edges(gR)
   edgeWeights(gR)


[Package graph version 1.8.0 Index]