GraphTheory - Maple Programming Help

Home : Support : Online Help : Mathematics : Discrete Mathematics : Graph Theory : GraphTheory Package : GraphTheory/Contract

GraphTheory

 Contract

 Calling Sequence Contract(G, e, mul)

Parameters

 G - graph e - edge of the graph mul - (optional) equation of the form multi=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 multi=true, the loops and multiple edges are preserved and the output is a weighted graph.
 • To contract multiple edges in a graph, 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 unweighted 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 unweighted graph with 3 vertices and 3 edge\left(s\right)}}$ (2)
 > $\mathrm{Contract}\left(G,\left\{1,3\right\},\mathrm{multi}=\mathrm{true}\right)$
 ${\mathrm{Graph 3: an undirected weighted graph with 3 vertices and 3 edge\left(s\right)}}$ (3)
 > $P≔\mathrm{PetersenGraph}\left(\right)$
 ${P}{≔}{\mathrm{Graph 4: an undirected unweighted 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 unweighted 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)