GraphTheory
AddArc
add arc to graph
Calling Sequence
Parameters
Description
Examples
AddArc(G, E)
AddArc(G, E, ip)
G
-
directed graph
E
arc, trail, or set of arcs
ip
(optional) equation of the form inplace=true or false
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 arc,weight, where the arc is just the from/to vertex pair, and the weight represents the value of the arc weight.
with⁡GraphTheory:
G≔Digraph⁡a,b,c,d,e,a,b,b,c,c,d,d,e
G≔Graph 1: a directed graph with 5 vertices and 4 arc(s)
AddArc⁡G,a,c,inplace=false
Graph 2: a directed graph with 5 vertices and 5 arc(s)
Graph 1: a directed graph with 5 vertices and 4 arc(s)
AddArc⁡G,a,c,b,d,inplace=false
Graph 3: a directed graph with 5 vertices and 6 arc(s)
AddArc⁡G,a,c,b,d
Graph 1: a directed graph with 5 vertices and 6 arc(s)
Gw≔Graph⁡Matrix⁡0,1,1,0,1,0,0,3,`$`⁡`$`⁡0,4,2,weighted,directed
Gw≔Graph 4: a directed weighted graph with 4 vertices and 4 arc(s)
Edges⁡Gw,weights
1,2,1,1,3,1,2,1,1,2,4,3
AddArc⁡Gw,1,4,2
Graph 4: a directed weighted graph with 4 vertices and 5 arc(s)
1,2,1,1,3,1,1,4,2,2,1,1,2,4,3
G≔Digraph⁡1,3,5,7
G≔Graph 5: a directed graph with 4 vertices and 0 arc(s)
AddArc⁡G,Trail⁡1,5,3,7,1
Graph 5: a directed graph with 4 vertices and 4 arc(s)
Edges⁡G
1,5,3,7,5,3,7,1
See Also
AddEdge
DeleteArc
Digraph
Edges
HasArc
Trail
Download Help Document