mathgraph: Create Mathematical Graph

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Create an object of class "mathgraph" which represents a mathematical graph.

Usage

1
2
3
4
5
6
7
mathgraph(formula, directed = FALSE, data = sys.parent())
## S3 method for class 'mathgraph'
length(x)
## S3 method for class 'mathgraph'
c(...)

is.mathgraph(x)

Arguments

formula

a formula containing just the right-side.
Special operators in the formula are + which separates terms, / which puts an edge between corresponding elements of the two vectors on which it is operating, and * which puts an edge between every pair of elements in the two vectors on which it is operating.

directed

logical flag: if TRUE, then all edges that are created are directed, otherwise they are undirected.

data

the frame in which to find objects referenced in the formula. This can be either the number of a memory frame, or a list or data frame containing the data.

...

objects to be concatenated.

x

object of class "mathgraph".

Details

Mathematical graphs consist of a set of nodes (vertices) and edges. Edges go between two nodes. An edge that is directed is often called an arc.

Terms in the formula (delimited by +) may be either calls to * or /, or objects that are already of class "mathgraph".

Two other representations of graphs are adjacency matrices and incidence matrices. The functions to convert "mathgraph" objects to these are adjamat and incidmat, respectively. Most algorithms for mathematical graphs are in terms of incidence matrices or adjacency matrices.

The generic functions that have a method for class "mathgraph" include: [, c, length, names, plot, print, unique.

is.mathgraph is the membership function for this class.

Value

an object of class mathgraph which is a two-column matrix of nodes along with an additional attribute called "directed" which is a logical vector stating whether or not each edge is directed.
An edge (row of the matrix) that is directed goes from the node in the first column to the node in the second column.

Note

S Poetry, Patrick J. Burns, http://www.burns-stat.com/pages/spoetry.html

Author(s)

Nick Efthymiou

References

Chachra, V., Ghare, P. M. and Moore, J. M. (1979). Applications of Graph Theory Algorithms. Elvesier North Holland, New York.

See Also

adjamat, incidmat, getpath

Examples

1
2
3
4
5
6
7
mathgraph(~ 1:3 / 2:4) # graph with 3 edges
mathgraph(~ 1:3 * 2:4) # graph with 9 edges

mathgraph(~ 1:3 / 2:4, dir=TRUE) # directed graph with 3 edges

# graph with some edges directed, some not
c(mathgraph(~ 1:3 * 2:4), mathgraph(~ c(3,1) / c(2,4), dir=TRUE))

mathgraph documentation built on May 2, 2019, 11:04 a.m.