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

# Online Help

###### All Products    Maple    MapleSim

GraphTheory

 Subgraph
 construct subgraph of graph

 Calling Sequence Subgraph(G, E, opts)

Parameters

 G - graph E - set or list of edges opts - (optional) one or more options as given below

Options

 • removesingletons=truefalse
 Specifies whether vertices with no neighbors in the constructed subgraph should be removed from the vertex list. The default value, false, leaves the vertex list exactly as it was given in G.

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 graph with 5 vertices and 10 edge\left(s\right)}}$ (1)
 > $E≔\left\{\left\{1,2\right\},\left\{2,3\right\},\left\{3,4\right\},\left\{4,1\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 graph with 5 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)$

Compatibility

 • The GraphTheory[Subgraph] command was updated in Maple 2023.
 • The removesingletons option was introduced in Maple 2023.
 • For more information on Maple 2023 changes, see Updates in Maple 2023.

 See Also