StyleSubgraph - Maple Help

GraphTheory

 StyleSubgraph
 specify styles for a subgraph of a graph

 Calling Sequence StyleSubgraph(G, S) StyleSubgraph(G, S, edgestylesheet=[ optionsequence ], vertexstylesheet=[ optionsequence ], ip)

Parameters

 G - graph S - a subgraph or a list or set of subgraphs of G 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 - (optional) optionsequence is a sequence of keyword options to specify the style or a list of such sequences

Description

 • By default the DrawGraph command draws the edges and vertices of the graph with the same set of style options. The command StyleSubgraph, allows you to specify styles for given subgraphs overriding the default or previously set styles.
 • 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.
 • 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.
 • Control of the style can be set using stylesheet options. The stylesheet options are understood as modifiers to the current graph style. So, for example, if a color is not specified the current color of each vertex is kept.

Vertex Stylesheet Options

 • The styles that are understood for vertices are:
 – border : whether to draw the border (true or false), or a color. Special color values are supported.
 • Special value "_contrast" (the default color) automatically sets the line color to a grayscale value that contrasts with the vertex color.
 • Special value "_blend" sets the line color to the average of the colors of the vertex and the plot background.
 • Special value "_match" sets the font color to the vertex color and the vertex is drawn in the background color. It also supports all the other formats in ColorTools/Format.
 – color : color of the vertex. See ColorTools/Format.
 – fontcolor : color of the vertex label. Special color values are supported.
 • Special value "_contrast" (the default color) automatically sets the font to a grayscale value that contrasts with the vertex color.
 • Special value "_match" sets the font color to the vertex color.
 • Special value "_blend" also sets the font color to the vertex color. It also supports all the other formats in ColorTools/Format.
 – fontsize : size of the vertex label, a positive integer in points
 – fontfamily : font family to use for the vertex label, a string. See plot/options.
 – fontstyle : font style to use for the vertex label, a string. See plot/options.
 – font : shorthand to specify a vertex label font as a list either [family, size] or [family, style, size]
 – padding : extra space around vertex label, a number in points
 – shape : shape of the vertex, a string understood by plottools/polygonbyname or default.  Examples:
 • ellipse, circle,
 • common polygons up to ten sides, e.g., hexagon
 • arbitrary regular polygons given as number-gon, e.g., 7gon
 • a regular star version of polygons with more than 4 sides will be drawn if prefixed (with or without spaces) with star, e.g., star hexagon
 • a flattened version of a polygon will be drawn if prefixed with wide, e.g., wide pentagon
 • the wide and star prefixes can be combined in any order
 • polygons are drawn with a flat bottom unless prefixed with inverted in which case it will have point bottom, e.g., inverted 9gon
 • the inverted, star, and wide prefixes can be combined, but inverted must come first, though it can be abbreviated to inv, e.g., invwide13gon
 – thickness : thickness of the border, a non-negative value

Edge Stylesheet Options

 • The styles that are understood for edges are:
 – arrowpos : the position of the arrow on a directed edge, a number between 0 and 1
 – arrowsize : the length, in points, of the arrow on a directed edge
 – arrowshape : a string understood by plottools/polygonbyname or "line" specifying the shape of the arrowhead on a directed edge
 – color : color of the edge line. See ColorTools/Format. Special color values are supported
 • Special value "_contrast" sets the color to a grayscale value that contrasts with the background color of the plot.
 • Special value "_match" sets the font color to the weight color.
 • Special value "_blend" also sets the font color to average of the colors of the vertices on each end of the edge.
 – fontcolor : color of the weight label. See ColorTools/Format. Special color values are supported.
 • Special value "_contrast" sets the font to a grayscale value that contrasts with the background color of the plot.
 • Special value "_match" (the default) sets the font color to the edge color.
 • Special value "_blend" also sets the font color to average of the colors of the vertices on each end of the edge.
 – fontsize : size of the weight label in points, a positive integer
 – fontfamily : font family to use for the weight label, a string. See plot/options.
 – fontstyle : font style to use for the weight label, a string. See plot/options.
 – font : shorthand to specify the weight label font as a list either [family, size] or [family, style, size]
 – linestyle : style of the edge line, a string: solid, dot, dash, dashdot, longdash, spacedash, or spacedot. See plot/options.
 – thickness : thickness of the edge line, a non-negative value

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $G≔\mathrm{Graph}\left(\left\{\left\{1,2\right\},\left\{1,3\right\},\left\{2,3\right\},\left\{3,4\right\},\left\{4,5\right\},\left\{4,6\right\},\left\{5,6\right\}\right\}\right)$
 ${G}{≔}{\mathrm{Graph 1: an undirected unweighted graph with 6 vertices and 7 edge\left(s\right)}}$ (1)
 > $H≔\mathrm{Graph}\left(\left[1,2,3,4\right],\left\{\left\{1,2\right\},\left\{1,3\right\},\left\{2,3\right\}\right\}\right)$
 ${H}{≔}{\mathrm{Graph 2: an undirected unweighted graph with 4 vertices and 3 edge\left(s\right)}}$ (2)
 > $\mathrm{G0}≔\mathrm{StyleSubgraph}\left(G,H,\mathrm{inplace}=\mathrm{false},\mathrm{vertexstylesheet}=\left[\mathrm{color}="Red"\right],\mathrm{edgestylesheet}=\left[\mathrm{color}="Blue"\right]\right)$
 ${\mathrm{G0}}{≔}{\mathrm{Graph 3: an undirected unweighted graph with 6 vertices and 7 edge\left(s\right)}}$ (3)
 > $\mathrm{DrawGraph}\left(\mathrm{G0}\right)$

Here is an example of highlighting multiple subgraphs given as lists of vertices:

 > $B≔\mathrm{BiconnectedComponents}\left(G\right)$
 ${B}{≔}\left[\left[{4}{,}{5}{,}{6}\right]{,}\left[{3}{,}{4}\right]{,}\left[{1}{,}{2}{,}{3}\right]\right]$ (4)
 > $\mathrm{G1}≔\mathrm{StyleSubgraph}\left(G,B,\mathrm{vertexstylesheet}=\left[\left[\mathrm{color}="Blue"\right],\left[\mathrm{color}="Green"\right],\left[\mathrm{color}="Cyan"\right]\right],\mathrm{edgestylesheet}=\left[\mathrm{color}="Yellow"\right],\mathrm{inplace}=\mathrm{false}\right)$
 ${\mathrm{G1}}{≔}{\mathrm{Graph 4: an undirected unweighted graph with 6 vertices and 7 edge\left(s\right)}}$ (5)
 > $\mathrm{DrawGraph}\left(\mathrm{G1},\mathrm{style}=\mathrm{spring}\right)$

More detailed stylesheets can be used instead of just colors:

 > $\mathrm{G2}≔\mathrm{StyleSubgraph}\left(G,B\left[1\right],\mathrm{edgestylesheet}=\left[\mathrm{thickness}=4\right],\mathrm{vertexstylesheet}=\left[\mathrm{thickness}=4,\mathrm{color}="White"\right],\mathrm{inplace}=\mathrm{false}\right)$
 ${\mathrm{G2}}{≔}{\mathrm{Graph 5: an undirected unweighted graph with 6 vertices and 7 edge\left(s\right)}}$ (6)
 > $\mathrm{DrawGraph}\left(\mathrm{G2}\right)$

Here a subgraph specified as a set of edges:

 > $\mathrm{G3}≔\mathrm{StyleSubgraph}\left(G,\left\{\left\{1,2\right\},\left\{1,3\right\},\left\{2,3\right\}\right\},\mathrm{vertexstylesheet}=\left[\mathrm{color}="Red"\right],\mathrm{inplace}=\mathrm{false}\right)$
 ${\mathrm{G3}}{≔}{\mathrm{Graph 6: an undirected unweighted graph with 6 vertices and 7 edge\left(s\right)}}$ (7)
 > $\mathrm{DrawGraph}\left(\mathrm{G3}\right)$

Here you can see how setting subgraph styles add to existing vertex styles.

 > $P≔\mathrm{SpecialGraphs}:-\mathrm{PetersenGraph}\left(\right)$
 ${P}{≔}{\mathrm{Graph 7: an undirected unweighted graph with 10 vertices and 15 edge\left(s\right)}}$ (8)
 > $\mathrm{StyleVertex}\left(P,1,\mathrm{fontcolor}="Red"\right)$
 > $\mathrm{StyleSubgraph}\left(P,\left[\left[1,2,3,4,5\right],\left[6,7,8,9,10\right]\right],\mathrm{edgestylesheet}=\left[\left[\mathrm{color}="Blue"\right],\left[\mathrm{color}="Green"\right]\right],\mathrm{vertexstylesheet}=\left[\left[\mathrm{color}="White"\right],\left[\mathrm{color}="Black",\mathrm{fontcolor}="White"\right]\right]\right)$
 > $\mathrm{DrawGraph}\left(P\right)$
 > $\mathrm{StyleSubgraph}\left(P,\left[\left[1,2,3,4,5\right],\left[6,7,8,9,10\right]\right],\mathrm{edgestylesheet}=\left[\left[\mathrm{thickness}=4,\mathrm{color}="Black"\right],\left[\mathrm{thickness}=2\right]\right],\mathrm{vertexstylesheet}=\left[\left[\mathrm{color}="White"\right],\left[\mathrm{color}="Black",\mathrm{fontcolor}="White"\right]\right]\right)$
 > $\mathrm{DrawGraph}\left(P\right)$

Compatibility

 • The GraphTheory[StyleSubgraph] command was introduced in Maple 2020.
 • For more information on Maple 2020 changes, see Updates in Maple 2020.