 StyleEdge - Maple Help

GraphTheory

 StyleEdge
 specify style changes to highlight certain edges of a graph Calling Sequence StyleEdge(G, E) StyleEdge(G, E, C, ip) StyleEdge(G, E, stylesheets, ip) Parameters

 G - graph E - a single edge or a list or set of edges of G or a subgraph of G or a list or set of subgraphs of G ip - (optional) equation of the form inplace = true or inplace = false stylesheets - (optional) a sequence of keyword options to specify the style or a sequence of lists of such sequences specifying styles for each of the edges. Description

 • By default the DrawGraph command draws the edges and vertices of the graph with the same set of style options. The command StyleEdge, allows you to specify individual styles for specified edges overriding the default or a previously set style.
 • Precise control of the style can be set using stylesheet options. The stylesheet options are understood as modifiers to the default style. So, for example, if a color is not specified the default color is used. 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):$
 > $\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)
 > $\mathrm{StyleEdge}\left(\mathrm{K5},\left\{1,2\right\},\mathrm{color}="Red"\right)$
 > $\mathrm{DrawGraph}\left(\mathrm{K5}\right)$ > $\mathrm{StyleEdge}\left(\mathrm{K5},\left[\left\{2,3\right\},\left\{4,5\right\}\right],\mathrm{thickness}=3\right)$
 > $\mathrm{DrawGraph}\left(\mathrm{K5}\right)$ > $\mathrm{ST}≔\mathrm{SpanningTree}\left(\mathrm{K5}\right)$
 ${\mathrm{ST}}{≔}{\mathrm{Graph 2: an undirected graph with 5 vertices and 4 edge\left(s\right)}}$ (2)

If we want a version of $\mathrm{K5}$ with $\mathrm{ST}$ highlighted, but we also want to keep the current version of $\mathrm{K5}$, we can use the $\mathrm{inplace}$ option.

 > $\mathrm{K5_with_ST}≔\mathrm{StyleEdge}\left(\mathrm{K5},\mathrm{ST},\mathrm{color}="Gold",\mathrm{inplace}=\mathrm{false}\right)$
 ${\mathrm{K5_with_ST}}{≔}{\mathrm{Graph 3: an undirected graph with 5 vertices and 10 edge\left(s\right)}}$ (3)
 > $\mathrm{DrawGraph}\left(\mathrm{K5_with_ST}\right)$ $\mathrm{K5}$ is unmodified.

 > $\mathrm{DrawGraph}\left(\mathrm{K5}\right)$ > $M≔\mathrm{Matrix}\left(\left[\left[0,2,9\right],\left[4,0,1\right],\left[3,0,0\right]\right]\right)$
 ${M}{≔}\left[\begin{array}{ccc}{0}& {2}& {9}\\ {4}& {0}& {1}\\ {3}& {0}& {0}\end{array}\right]$ (4)
 > $G≔\mathrm{Graph}\left(M\right)$
 ${G}{≔}{\mathrm{Graph 4: a directed weighted graph with 3 vertices and 5 arc\left(s\right)}}$ (5)
 > $\mathrm{StyleEdge}\left(G,\left[2,3\right],\mathrm{fontstyle}="bold",\mathrm{fontcolor}="Red",\mathrm{color}="Green",\mathrm{thickness}=3\right)$
 > $\mathrm{DrawGraph}\left(G\right)$ > $P≔\mathrm{SpecialGraphs}:-\mathrm{PetersenGraph}\left(\right)$
 ${P}{≔}{\mathrm{Graph 5: an undirected graph with 10 vertices and 15 edge\left(s\right)}}$ (6)
 > $\mathrm{P1}≔\mathrm{InducedSubgraph}\left(P,\left[1,2,3,4,5\right]\right)$
 ${\mathrm{P1}}{≔}{\mathrm{Graph 6: an undirected graph with 5 vertices and 5 edge\left(s\right)}}$ (7)
 > $\mathrm{P2}≔\mathrm{InducedSubgraph}\left(P,\left[6,7,8,9,10\right]\right)$
 ${\mathrm{P2}}{≔}{\mathrm{Graph 7: an undirected graph with 5 vertices and 5 edge\left(s\right)}}$ (8)
 > $\mathrm{StyleEdge}\left(P,\left[\mathrm{P1},\mathrm{P2}\right],\left[\mathrm{color}="Blue"\right],\left[\mathrm{color}="Green"\right]\right)$
 > $\mathrm{DrawGraph}\left(P\right)$ > $\mathrm{StyleEdge}\left(P,\left[\left\{1,6\right\},\left\{2,9\right\},\left\{3,7\right\},\left\{4,10\right\},\left\{5,8\right\}\right],\left[\mathrm{seq}\left(\left[\mathrm{thickness}=i\right],i=2..10,2\right)\right]\right)$
 > $\mathrm{DrawGraph}\left(P\right)$  Compatibility

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