 GraphTheory - Maple Programming Help

Home : Support : Online Help : Mathematics : Packages : GraphTheory

GraphTheory

 Calling Sequence GraphTheory[command](arguments) command(arguments)

Description

 • The GraphTheory package is a collection of routines for creating graphs, drawing graphs, manipulating graphs, and testing graphs for properties. The graphs are sets of vertices (nodes) connected by edges. The package supports both directed and undirected graphs but not multigraphs or graphs with loops (self-incident vertices). The edges in the graphs can be weighted or unweighted.
 • The main command for creating undirected graphs is the Graph command. The main command for creating directed graphs is the Digraph command.
 • To draw a graph in Maple use the DrawGraph command.  The output is a Maple plot.
 • To include a graph in a TeX or LaTeX document as a figure use the Latex command.
 • To test if a Maple object G is a graph use the test: type(G,Graph).
 • The ImportGraph and ExportGraph commands are for reading a graph from, and writing a graph to, a file in one of the supported data formats.
 • The following commands are essential for working with large graphs: HasEdge, HasArc, AddEdge, AddArc, DeleteEdge, DeleteArc.
 • The GraphTheory examples worksheet has a guided tour of the package.
 • For details on the implementation of the GraphTheory package and its graph data structure, consult GraphTheory[Details].

List of GraphTheory Subpackages

 • The SpecialGraphs package contains a library of predefined graphs.
 • The RandomGraphs package has routines for randomly generating graphs.

List of GraphTheory Package Commands

 • The following is a list of the commands in the main GraphTheory package.
 Constructing Graphs

 Modifying Graphs

 Properties of Graphs

 Importing and Exporting Graphs

 Traversing Graphs

 Visualizing Graphs

 Other Commands

Accessing the GraphTheory Package Commands

 • Each command in the GraphTheory package can be accessed by using either the long form or the short form of the command name in the command calling sequence.  For example, if G is a graph you can use either GraphTheory[IsPlanar](G) or with(GraphTheory); then IsPlanar(G).
 • Because the underlying implementation of the GraphTheory package is a module, it is possible to use the form GraphTheory:-command to access a command from the package. For more information, see Module Members.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$

An undirected graph on 5 vertices labeled 1 to 5.

 > $G≔\mathrm{Graph}\left(\left\{\left\{1,2\right\},\left\{2,3\right\},\left\{3,1\right\},\left\{4,5\right\}\right\}\right)$
 ${G}{≔}{\mathrm{Graph 1: an undirected unweighted graph with 5 vertices and 4 edge\left(s\right)}}$ (1)
 > $\mathrm{DrawGraph}\left(G\right)$ A directed graph on 4 vertices a, b, c, and d.

 > $H≔\mathrm{Digraph}\left(\left[a,b,c,d\right],\left\{\left[a,b\right],\left[b,c\right],\left[c,d\right],\left[d,a\right]\right\}\right)$
 ${H}{≔}{\mathrm{Graph 2: a directed unweighted graph with 4 vertices and 4 arc\left(s\right)}}$ (2)
 > $\mathrm{DrawGraph}\left(H\right)$ A weighted directed graph (a network) on 4 vertices 1, 2, 3, and 4.

 > $N≔\mathrm{Digraph}\left(\left\{\left[\left[1,2\right],3\right],\left[\left[1,3\right],3\right],\left[\left[2,4\right],4\right],\left[\left[3,4\right],4\right]\right\}\right)$
 ${N}{≔}{\mathrm{Graph 3: a directed weighted graph with 4 vertices and 4 arc\left(s\right)}}$ (3)
 > $\mathrm{WeightMatrix}\left(N\right)$
 $\left[\begin{array}{cccc}{0}& {3}& {3}& {0}\\ {0}& {0}& {0}& {4}\\ {0}& {0}& {0}& {4}\\ {0}& {0}& {0}& {0}\end{array}\right]$ (4)

A example of a special graph, a dodecahedron, on 20 vertices.

 > $\mathrm{with}\left(\mathrm{SpecialGraphs}\right):$
 > $G≔\mathrm{DodecahedronGraph}\left(\right)$
 ${G}{≔}{\mathrm{Graph 4: an undirected unweighted graph with 20 vertices and 30 edge\left(s\right)}}$ (5)
 > $\mathrm{DrawGraph}\left(G\right)$ 