ContractSubgraph - Maple Help

GraphTheory

 ContractSubgraph
 contract subgraph to single vertex

 Calling Sequence ContractSubgraph(G, S)

Parameters

 G - graph S - set or list of vertices, or a subgraph of G

Description

 • The ContractSubgraph command returns a new graph with all the vertices in S merged into a single vertex. The neighborhood of the new vertex will be the union of the neighborhoods of all of merged vertices.
 • If S is given as a subgraph of G, all the vertices of S will be contracted.
 • To contract a single edge, use the Contract command.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $\mathrm{C6}≔\mathrm{CycleGraph}\left(6\right)$
 ${\mathrm{C6}}{≔}{\mathrm{Graph 1: an undirected unweighted graph with 6 vertices and 6 edge\left(s\right)}}$ (1)
 > $H≔\mathrm{ContractSubgraph}\left(\mathrm{C6},\left[1,2,6\right]\right)$
 ${H}{≔}{\mathrm{Graph 2: an undirected unweighted graph with 4 vertices and 4 edge\left(s\right)}}$ (2)
 > $\mathrm{Vertices}\left(H\right)$
 $\left[{1}{,}{3}{,}{4}{,}{5}\right]$ (3)
 > $\mathrm{Edges}\left(H\right)$
 $\left\{\left\{{1}{,}{3}\right\}{,}\left\{{1}{,}{5}\right\}{,}\left\{{3}{,}{4}\right\}{,}\left\{{4}{,}{5}\right\}\right\}$ (4)
 > $\mathrm{with}\left(\mathrm{SpecialGraphs}\right):$
 > $P≔\mathrm{PetersenGraph}\left(\right)$
 ${P}{≔}{\mathrm{Graph 3: an undirected unweighted graph with 10 vertices and 15 edge\left(s\right)}}$ (5)
 > $\mathrm{DrawGraph}\left(P\right)$
 > $H≔\mathrm{ContractSubgraph}\left(P,\left[1,2,3,6,7,9\right]\right)$
 ${H}{≔}{\mathrm{Graph 4: an undirected unweighted graph with 5 vertices and 7 edge\left(s\right)}}$ (6)
 > $\mathrm{DrawGraph}\left(H\right)$

Compatibility

 • The GraphTheory[ContractSubgraph] command was introduced in Maple 2020.