 Contract - Maple Help

GraphTheory

 Contract
 contract edge of a graph Calling Sequence Contract(G, e, mul) Parameters

 G - graph e - edge of the graph mul - (optional) equation of the form multigraph=true or false Description

 • The Contract command contracts the specified edge of a graph. By default, all the loops and multiple edges are removed. By setting multigraph=true, the loops and multiple edges are preserved and the output is a weighted graph.
 • To contract multiple edges in a graph, use ContractSubgraph or use the foldl command. Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $\mathrm{with}\left(\mathrm{SpecialGraphs}\right):$
 > $G≔\mathrm{CompleteGraph}\left(4\right)$
 ${G}{≔}{\mathrm{Graph 1: an undirected graph with 4 vertices and 6 edge\left(s\right)}}$ (1)
 > $\mathrm{Contract}\left(G,\left\{1,3\right\}\right)$
 ${\mathrm{Graph 2: an undirected graph with 3 vertices and 3 edge\left(s\right)}}$ (2)
 > $\mathrm{Contract}\left(G,\left\{1,3\right\},\mathrm{multigraph}=\mathrm{true}\right)$
 ${\mathrm{Graph 3: an undirected multigraph with 3 vertices, 5 edge\left(s\right), and 1 self-loop\left(s\right)}}$ (3)
 > $P≔\mathrm{PetersenGraph}\left(\right)$
 ${P}{≔}{\mathrm{Graph 4: an undirected graph with 10 vertices and 15 edge\left(s\right)}}$ (4)
 > $\mathrm{DrawGraph}\left(P\right)$ Contract the five edges connecting the inner star to the outer pentagon to show K5.

 > $G≔\mathrm{foldl}\left(\mathrm{Contract},P,\left\{1,6\right\},\left\{2,9\right\},\left\{3,7\right\},\left\{4,10\right\},\left\{5,8\right\}\right)$
 ${G}{≔}{\mathrm{Graph 5: an undirected graph with 5 vertices and 10 edge\left(s\right)}}$ (5)
 > $\mathrm{NumberOfVertices}\left(G\right)$
 ${5}$ (6)
 > $\mathrm{IsClique}\left(G\right)$
 ${\mathrm{true}}$ (7)