AddArc - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

# Online Help

###### All Products    Maple    MapleSim

GraphTheory

 AddArc
 add arc to graph

 Calling Sequence AddArc(G, E) AddArc(G, E, ip)

Parameters

 G - directed graph E - arc, trail, or set of arcs ip - (optional) equation of the form inplace=true or false

Description

 • The AddArc command adds one or more arcs to a directed graph. By default, the original digraph is changed to a digraph containing the specified set of arc(s).  By setting inplace=false, the original digraph remains unchanged and a new digraph containing the specified set of arcs is created.
 • If the graph is weighted, then a weighted arc can be added by calling AddArc with one or more arcs in the form $\left[\mathrm{arc},\mathrm{weight}\right]$, where the arc is just the from/to vertex pair, and the weight represents the value of the arc weight.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $G≔\mathrm{Digraph}\left(\left[a,b,c,d,e\right],\left\{\left[a,b\right],\left[b,c\right],\left[c,d\right],\left[d,e\right]\right\}\right)$
 ${G}{≔}{\mathrm{Graph 1: a directed graph with 5 vertices and 4 arc\left(s\right)}}$ (1)
 > $\mathrm{AddArc}\left(G,\left[a,c\right],\mathrm{inplace}=\mathrm{false}\right)$
 ${\mathrm{Graph 2: a directed graph with 5 vertices and 5 arc\left(s\right)}}$ (2)
 > $G$
 ${\mathrm{Graph 1: a directed graph with 5 vertices and 4 arc\left(s\right)}}$ (3)
 > $\mathrm{AddArc}\left(G,\left\{\left[a,c\right],\left[b,d\right]\right\},\mathrm{inplace}=\mathrm{false}\right)$
 ${\mathrm{Graph 3: a directed graph with 5 vertices and 6 arc\left(s\right)}}$ (4)
 > $\mathrm{AddArc}\left(G,\left\{\left[a,c\right],\left[b,d\right]\right\}\right)$
 ${\mathrm{Graph 1: a directed graph with 5 vertices and 6 arc\left(s\right)}}$ (5)
 > $G$
 ${\mathrm{Graph 1: a directed graph with 5 vertices and 6 arc\left(s\right)}}$ (6)
 > $\mathrm{Gw}≔\mathrm{Graph}\left(\mathrm{Matrix}\left(\left[\left[0,1,1,0\right],\left[1,0,0,3\right],\left[0$4\right]$2\right]\right),'\mathrm{weighted}','\mathrm{directed}'\right)$
 ${\mathrm{Gw}}{≔}{\mathrm{Graph 4: a directed weighted graph with 4 vertices and 4 arc\left(s\right)}}$ (7)
 > $\mathrm{Edges}\left(\mathrm{Gw},\mathrm{weights}\right)$
 $\left\{\left[\left[{1}{,}{2}\right]{,}{1}\right]{,}\left[\left[{1}{,}{3}\right]{,}{1}\right]{,}\left[\left[{2}{,}{1}\right]{,}{1}\right]{,}\left[\left[{2}{,}{4}\right]{,}{3}\right]\right\}$ (8)
 > $\mathrm{AddArc}\left(\mathrm{Gw},\left[\left[1,4\right],2\right]\right)$
 ${\mathrm{Graph 4: a directed weighted graph with 4 vertices and 5 arc\left(s\right)}}$ (9)
 > $\mathrm{Edges}\left(\mathrm{Gw},\mathrm{weights}\right)$
 $\left\{\left[\left[{1}{,}{2}\right]{,}{1}\right]{,}\left[\left[{1}{,}{3}\right]{,}{1}\right]{,}\left[\left[{1}{,}{4}\right]{,}{2}\right]{,}\left[\left[{2}{,}{1}\right]{,}{1}\right]{,}\left[\left[{2}{,}{4}\right]{,}{3}\right]\right\}$ (10)
 > $G≔\mathrm{Digraph}\left(\left[1,3,5,7\right]\right)$
 ${G}{≔}{\mathrm{Graph 5: a directed graph with 4 vertices and 0 arc\left(s\right)}}$ (11)
 > $\mathrm{AddArc}\left(G,\mathrm{Trail}\left(1,5,3,7,1\right)\right)$
 ${\mathrm{Graph 5: a directed graph with 4 vertices and 4 arc\left(s\right)}}$ (12)
 > $\mathrm{Edges}\left(G\right)$
 $\left\{\left[{1}{,}{5}\right]{,}\left[{3}{,}{7}\right]{,}\left[{5}{,}{3}\right]{,}\left[{7}{,}{1}\right]\right\}$ (13)

 See Also