GraphTheory/Multigraph - Maple Help

GraphTheory

 Multigraph
 construct a multigraph

 Calling Sequence Multigraph(V, E, opts) Multigraph(T, opts) Multigraph(A, opts) Multigraph(V, E, A, opts)

Parameters

 V - (optional) list of vertices (integers, symbols, or strings) or integer specifying the vertices 1,2,...,V E - (optional) list of edges T - (optional) function of the form Trail(a,b,c,,...) or Trail([a,b,c,...]) A - (optional) Matrix (of edge multiplicities) opts - (optional) one or more options as specified below

Options

 The opts parameter is used to specify one or more additional properties of the graph.
 • directed = true or false
 Specifies that this graph has directed edges.
 • selfloops=true or false
 Specifies whether self-loops should be permitted in the graph. If false, an error will be issued if the edge information provided with parameters E, T, or A contains a self-loop. The default is true.
 • vertexcolor=c
 Specifies a color or list of colors to associate with the vertices in vertex order.
 • vertexpositions=p
 Specifies coordinate positions for the vertices for use with DrawGraph.

Description

 • The Multigraph command constructs a GraphTheory graph object from the given parameters.
 • The type of each argument determines what it is.  Because of this the arguments can appear in any order.
 • An integer n specifies the number of vertices and implicitly the vertex labels 1 through n.
 • A list V of integers, symbols or strings specifies the vertices. Each vertex must be an integer, symbol or string.
 • A list E specifies the edges of G.
 An undirected edge between vertices i and j is input as a set of two vertices $\left\{i,j\right\}$.  A directed edge from vertex a to vertex b is input as a list $\left[a,b\right]$.  A weighted edge is input as either $\left[e,w\right]$ where e is an edge (directed or undirected) and w, the edge weight, is a number (integer or decimal). The same edge may appear in E more than once, and multiple appearances are interpreted as multiple edges in the resulting multigraph.
 • A function T of the form Trail(a,b,c,...) or Trail([a,b,c,...]) specifies a trail of edges from a to b to c ....  By default the edges are undirected.  If the symbol directed is specified as an option then they are directed.  More than one trail can be specified.  This is often the easiest way to enter a graph interactively.
 • A matrix A specifies an edge multiplicity matrix. Its entries must be nonnegative integers.
 If A is symmetric, the resulting graph will be undirected unless the edge direction is stated otherwise.
 If A is has nonzero entries on the diagonal, the resulting graph will have self-loops.
 Any entries whose values other than 0 or 1 correspond to pairs of edges for which there are multiple edges.
 • Note that IsMultigraph will return true on the output G only if it actually contains multiple edges, that is, there exist vertices u and v such that EdgeMultiplicity(G, {u, v}) returns a number greater than 1.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $\mathrm{G1}≔\mathrm{Multigraph}\left(4,\left[\left\{1,2\right\},\left\{1,2\right\},\left\{2,3\right\},\left\{3,4\right\}\right]\right)$
 ${\mathrm{G1}}{≔}{\mathrm{Graph 1: an undirected multigraph with 4 vertices and 4 edge\left(s\right)}}$ (1)
 > $\mathrm{IsMultigraph}\left(\mathrm{G1}\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{EdgeMultiplicity}\left(\mathrm{G1}\right)$
 $\left[\begin{array}{cccc}{0}& {2}& {0}& {0}\\ {2}& {0}& {1}& {0}\\ {0}& {1}& {0}& {1}\\ {0}& {0}& {1}& {0}\end{array}\right]$ (3)
 > $M≔\mathrm{Matrix}\left(\left[\left[0,6,0\right],\left[5,0,3\right],\left[2,4,0\right]\right]\right)$
 ${M}{≔}\left[\begin{array}{ccc}{0}& {6}& {0}\\ {5}& {0}& {3}\\ {2}& {4}& {0}\end{array}\right]$ (4)
 > $\mathrm{G2}≔\mathrm{Multigraph}\left(\left["A","B","C"\right],M\right)$
 ${\mathrm{G2}}{≔}{\mathrm{Graph 2: a directed multigraph with 3 vertices and 20 arc\left(s\right)}}$ (5)
 > $\mathrm{ShortestPath}\left(\mathrm{G2},"A","C"\right)$
 $\left[{"A"}{,}{"B"}{,}{"C"}\right]$ (6)

Compatibility

 • The GraphTheory[Multigraph] command was introduced in Maple 2023.