Darwin Help

Back to Index

Graph

Class Graph - Data structure for storing a graph

Calling Sequence  Graph(Edges,Nodes)
Parameters
NameTypeDescription

Edges Edgesdescription of edges
Nodes Nodesdescription of nodes (vertices)
Selectors
NameTypeDescription

Degrees list(integer)a list containing the degree of each node
Adjacencies list(list)an array with lists of adjacent nodes,

 indexed by node number
Incidences list(list)an array with lists of incident edge

 numbers, indexed by node number.
Distances matrix(numeric)a square matrix containing the distance

 between pairs of nodes (assuming that the

 edges label is a distance or a list with

 first element being a distance).

 Disconnected nodes are at dist DBL_MAX.
Labels matrixa square matrix containing the labels of

 edges between pairs of nodes.

 Disconnected nodes get the label DBL_MAX.
AdjacencyMatrix matrixa square matrix containing 1s for each

 edge and zeros otherwise. The matrix is

 symmetric. The diagonal is zeroed.
Methods dimacs, display, minus, plus, Rand, select, Tree, type, union
Synopsis A graph is represented by
 

Graph( Edges( Edge(lab1,n1,n2), ... ), Nodes( lab1, lab2, ... ) )
 

Where Edges describes the set of edges and Nodes describes the set of nodes. Alternatively, and only as input, graphs can be represented with the standard notation of set of vertices and sets of edges. In this case an edge is represented as a set of two vertices. A node (or vertex) can be represented by any valid object in Darwin. Usually integers are used. Notice that the values of Edge must correspond to a node, hence if you use complicated objects as nodes, these have to be replicated every time you include them in an Edge.


If Graph is used with only a set of Edges, it deduces which are the Nodes from the Edges.

Examples
> Graph({a,b,c},{{a,b},{a,c},{b,c}});
Graph(Edges(Edge(0,a,b),Edge(0,a,c),Edge(0,b,c)),Nodes(a,b,c))
> Graph(Edges(Edge(0,10,20),Edge(0,10,35)), Nodes(0,10,20,35));
Graph(Edges(Edge(0,10,20),Edge(0,10,35)),Nodes(0,10,20,35))
> Graph(Edges(Edge(0,10,20),Edge(0,10,35)));
Graph(Edges(Edge(0,10,20),Edge(0,10,35)),Nodes(10,20,35))
See also BipartiteGraph,   Clique,   DrawGraph,   Edge,   EdgeComplement,   Edges,   FindConnectedComponents,   Graph_Rand,   InduceGraph,   MaxCut,   MaxEdgeWeightClique,   MST,   Nodes,   Path,   RegularGraph,   ShortestPath,   TetrahedronGraph,   VertexCover