mathgraph {mathgraph} | R Documentation |
Create an object of class "mathgraph"
which represents a
mathematical graph.
mathgraph(formula, directed = FALSE, data = sys.parent()) length.mathgraph(x) c.mathgraph(...) is.mathgraph(x)
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" . |
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.
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.
S Poetry, Patrick J. Burns, http://www.burns-stat.com/pages/spoetry.html
Nick Efthymiou
Chachra, V., Ghare, P. M. and Moore, J. M. (1979). Applications of Graph Theory Algorithms. Elvesier North Holland, New York.
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))