GraphTheory
Multigraph
construct a multigraph
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
Multigraph(V, E, opts)
Multigraph(T, opts)
Multigraph(A, opts)
Multigraph(V, E, A, opts)
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
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.
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 i,j. A directed edge from vertex a to vertex b is input as a list a,b. A weighted edge is input as either e,w 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.
with⁡GraphTheory:
G1≔Multigraph⁡4,1,2,1,2,2,3,3,4
G1≔Graph 1: an undirected multigraph with 4 vertices and 4 edge(s)
IsMultigraph⁡G1
true
EdgeMultiplicity⁡G1
0200201001010010
M≔Matrix⁡0,6,0,5,0,3,2,4,0
M≔060503240
G2≔Multigraph⁡A,B,C,M
G2≔Graph 2: a directed multigraph with 3 vertices and 20 arc(s)
ShortestPath⁡G2,A,C
A,B,C
The GraphTheory[Multigraph] command was introduced in Maple 2023.
For more information on Maple 2023 changes, see Updates in Maple 2023.
See Also
Digraph
EdgeMultiplicity
Graph
IsMultigraph
Trail
Download Help Document