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

Online Help

All Products    Maple    MapleSim


GraphTheory

  

AddEdge

  

add edge to graph

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

AddEdge(G, E)

AddEdge(G, E, ip)

Parameters

G

-

undirected graph

E

-

edge, trail, or set of edges

ip

-

(optional) equation of the form inplace=true or false

Description

• 

The AddEdge command adds one or more edges to an undirected graph. By default, the original graph is changed to a graph containing the specified set of edge(s).  By setting inplace=false the original graph remains unchanged and a new graph containing the specified set of edges is created.

• 

If the graph is weighted, then a weighted edge can be added by calling AddEdge with one or more edges in the form edge,weight, where the edge is just the set of two vertices, and the weight represents the value of the edge weight.

Examples

withGraphTheory:

GCycleGraph5

GGraph 1: an undirected graph with 5 vertices and 5 edge(s)

(1)

AddEdgeG,1,3,inplace=false

Graph 2: an undirected graph with 5 vertices and 6 edge(s)

(2)

G

Graph 1: an undirected graph with 5 vertices and 5 edge(s)

(3)

AddEdgeG,1,3,2,4,inplace=false

Graph 3: an undirected graph with 5 vertices and 7 edge(s)

(4)

AddEdgeG,1,3,2,4

Graph 1: an undirected graph with 5 vertices and 7 edge(s)

(5)

G

Graph 1: an undirected graph with 5 vertices and 7 edge(s)

(6)

GwGraphMatrix0,1,1,0,1,0,0,1,1,0,0,0,0,1,0,0,weighted

GwGraph 4: an undirected weighted graph with 4 vertices and 3 edge(s)

(7)

EdgesGw,weights

1,2,1,1,3,1,2,4,1

(8)

AddEdgeGw,1,4,2

Graph 4: an undirected weighted graph with 4 vertices and 4 edge(s)

(9)

EdgesGw,weights

1,2,1,1,3,1,1,4,2,2,4,1

(10)

GGrapha,b,c,d

GGraph 5: an undirected graph with 4 vertices and 0 edge(s)

(11)

AddEdgeG,Traila,b,c,d,a

Graph 5: an undirected graph with 4 vertices and 4 edge(s)

(12)

EdgesG

a,b,a,d,b,c,c,d

(13)

See Also

AddArc

DeleteEdge

Edges

Graph

HasEdge

Trail