GraphTheory
HighlightSubgraph
highlight a subgraph of a graph
Calling Sequence
Parameters
Description
Examples
Compatibility
HighlightSubgraph(G, S)
HighlightSubgraph(G, S, C1, C2, ip)
HighlightSubgraph(G, S, edgestylesheet=[ optionsequence ], vertexstylesheet=[ optionsequence ], ip)
G
-
graph
S
a subgraph or a list or set of subgraphs of G
C1, C2
(optional) colors for edges and vertices respectively
ip
(optional) equation of the form inplace = true or inplace = false
edgestylesheet
(optional) optionsequence is a sequence of keyword options to specify the style or a list of such sequences
vertexstylesheet
By default the DrawGraph command draws the edges and vertices of the graph with the same set of style options. The command HighlightVertex, allows the subgraph to be given a different highlighted style specified in the graph stylesheet.
A subgraph can be given explicitly as a graph or implicitly as a list/set of vertices of G, or a list/set of edges of G. In the implicit cases, explicit subgraphs will be constructed using the Subgraph command for edges or the InducedSubgraph command for vertices.
Given only a graph G and a subgraph or subgraphs S, HighlightSubgraph marks the components of the specified subgraphs as to be rendered with the default highlighted style.
If you simply want a trail to have a different style without being grouped with other highlighted graph components, use the command StyleSubgraph instead.
If you want to highlight a subgraph but give it different colors, the simplest way is to give C1, a color for the edges, and C2, a color for the vertices. The colors can be given in any form understood by Maple. See ColorTools/Formats for details. When the color of a vertex is set, the color of the vertex label is set automatically to an appropriately contrasting grayscale.
If S is a list of subgraphs, then a list of colors or stylesheets can be used to associate a different color or style to each member.
By default, this command modifies G and returns nothing. If you supply the option inplace = false, then instead the changes are applied to a copy of G, and that copy is returned.
More precise overriding of the default highlighted style can be set using stylesheet options. The stylesheet options are understood as modifiers to the default highlighted style. So, for example, if a color is not specified the default highlight color is used. If the stylesheet options and a color C1 or C2 are both given, the colors are ignored. See StyleSubgraph for a complete list of vertex and edge style options.
with⁡GraphTheory:
G≔Graph⁡1,2,1,3,2,3,3,4,4,5,4,6,5,6
G≔Graph 1: an undirected graph with 6 vertices and 7 edge(s)
H≔Graph⁡1,2,3,4,1,2,1,3,2,3
H≔Graph 2: an undirected graph with 4 vertices and 3 edge(s)
G0≔HighlightSubgraph⁡G,H,inplace=false
G0≔Graph 3: an undirected graph with 6 vertices and 7 edge(s)
DrawGraph⁡G0
Here is an example of highlighting multiple subgraphs given as lists of vertices:
B≔BiconnectedComponents⁡G
B≔4,5,6,3,4,1,2,3
G1≔HighlightSubgraph⁡G,B,Blue,Green,Cyan,Yellow,inplace=false
G1≔Graph 4: an undirected graph with 6 vertices and 7 edge(s)
DrawGraph⁡G1,style=spring
More detailed stylesheets can be used instead of just colors:
G2≔HighlightSubgraph⁡G,B1,edgestylesheet=thickness=4,vertexstylesheet=thickness=4,color=White,inplace=false
G2≔Graph 5: an undirected graph with 6 vertices and 7 edge(s)
DrawGraph⁡G2
Here a subgraph specified as a set of edges:
G3≔HighlightSubgraph⁡G,1,2,1,3,2,3,inplace=false
G3≔Graph 6: an undirected graph with 6 vertices and 7 edge(s)
DrawGraph⁡G3
P≔SpecialGraphs:-PetersenGraph⁡
P≔Graph 7: an undirected graph with 10 vertices and 15 edge(s)
HighlightSubgraph⁡P,1,2,3,4,5,6,7,8,9,10,Blue,Green,White,Black
DrawGraph⁡P
HighlightSubgraph⁡P,1,2,3,4,5,6,7,8,9,10,edgestylesheet=thickness=4,color=Black,thickness=1,vertexstylesheet=color=White,color=Black,fontcolor=White
The GraphTheory[HighlightSubgraph] command was updated in Maple 2019.
The stylesheet option was updated in Maple 2019.
See Also
DrawGraph
HighlightEdges
HighlightVertex
Subgraph
Download Help Document