 GraphTheory - Maple Programming Help

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

GraphTheory

 Subgraph

 Calling Sequence Subgraph(G, E)

Parameters

 G - graph E - set or list of edges

Description

 • The Subgraph command returns the subgraph formed by a specified set (or list) of edges.
 • To induce a subgraph using a set of vertices, use the InducedSubgraph command.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $\mathrm{K5}≔\mathrm{CompleteGraph}\left(5\right)$
 ${\mathrm{K5}}{≔}{\mathrm{Graph 1: an undirected unweighted graph with 5 vertices and 10 edge\left(s\right)}}$ (1)
 > $E≔\left\{\left\{1,2\right\},\left\{1,4\right\},\left\{2,3\right\},\left\{3,4\right\}\right\}$
 ${E}{≔}\left\{\left\{{1}{,}{2}\right\}{,}\left\{{1}{,}{4}\right\}{,}\left\{{2}{,}{3}\right\}{,}\left\{{3}{,}{4}\right\}\right\}$ (2)
 > $H≔\mathrm{Subgraph}\left(\mathrm{K5},E\right)$
 ${H}{≔}{\mathrm{Graph 2: an undirected unweighted graph with 4 vertices and 4 edge\left(s\right)}}$ (3)
 > $\mathrm{evalb}\left(\mathrm{Edges}\left(H\right)=E\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{HighlightSubgraph}\left(\mathrm{K5},H\right)$
 > $\mathrm{DrawGraph}\left(\mathrm{K5}\right)$ 