 StyleEdgesByProperty - Maple Help

GraphTheory

 StyleEdgesByProperty
 style graph edges by property Calling Sequence StyleEdgesByProperty(G, P, ip) Parameters

 G - graph P - either a matrix or table of numeric values, specifying values for each edge of G, or a procedure that returns a matrix or table of numeric values, specifying values for each edge of G ip - (optional) equation of the form inplace = true or inplace = false Options

 • colorscheme : colors
 This sets edgecolor using ColorTools:-Blend
 • thicknessscheme: nonnegative
 This sets edgethickness. The value can be zero, but for best results should be positive
 • arrowsizescheme : nonnegative
 This sets arrowsize
 • arrowposscheme : 0..1
 This sets arrowpos
 • arrowshapescheme : string
 This sets arrowshape. Only valuesplit schemes are supported.
 • linestylescheme : string
 This sets linestyle. Only valuesplit schemes are supported.
 • scheme : list_of_styles
 This only supports valuesplit schemes.  For each value a custom list of stylesheet properties can be given.
 • range=range(numeric)
 All styling schemes scale the values in P to the range $0..1$ based on the minimum and maximum values in P.  The range option overrides that and does a linear scaling where lhs(range) becomes to 0 and rhs(range) becomes 1.  This is useful for achieving consistent styling across multiple graphs.  After scaling, values less than 0 will be treated the same as 0 and values greater than 1 will be treated the same as 1.
 • markers=list(numeric)
 By default all the styling schemes linearly interpolate between styles equally spaced across on interval. The markers option allows you to specify exactly which values between 0 and 1 are assigned to each style.  The value of markers must be a sorted list of values between 0 and 1 which is the same length as the list of values given to each scheme.
 • Limitation: If multiple style scheme are being used with markers all the schemes must have the same number of values. The best work around is to just invoke this command twice on the same graph. Description

 • By default the DrawGraph command draws the edges and vertices of the graph with the same set of style options. The command StyleEdgesByProperty, allows you to set styles for all vertices according to a property.
 • Every style scheme can also be given as a valuesplit scheme. Instead of a list of values to blend between, a valuesplit scheme assigns a discrete set of styles by exact value, range, or list or set of values given as a list of equations and default value. The equations match the property value to the left-hand side and use the value on the right-hand side. For example, colorscheme=["valuesplit", [1="Blue", 2..3="Red", [4,5]="Green", "DarkGrey"] ] If no default value is given, unmatched properties will not be given a style.
 • 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. 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(\mathrm{weighted},\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 weighted graph with 6 vertices and 7 edge\left(s\right)}}$ (1)
 > $\mathrm{RandomGraphs}:-\mathrm{AssignEdgeWeights}\left(G,1..10\right)$
 ${\mathrm{Graph 1: an undirected weighted graph with 6 vertices and 7 edge\left(s\right)}}$ (2)
 > $\mathrm{StyleEdgesByProperty}\left(G,\mathrm{WeightMatrix},\mathrm{colorscheme}=\left["Blue","Red"\right],\mathrm{thicknessscheme}=\left[0.5,2.5\right]\right)$
 > $\mathrm{DrawGraph}\left(G\right)$ Here is an example of how to use the output of EdgeChromaticNumber to create an edge coloring

 > $\mathrm{G2}≔\mathrm{SpecialGraphs}:-\mathrm{PetersenGraph}\left(\right)$
 ${\mathrm{G2}}{≔}{\mathrm{Graph 2: an undirected unweighted graph with 10 vertices and 15 edge\left(s\right)}}$ (3)
 > $c≔\mathrm{EdgeChromaticNumber}\left(\mathrm{G2},'\mathrm{coloring}'\right)$
 ${c}{≔}{4}$ (4)
 > edgecolor := proc(G) local i, e, color; for e in Edges(G) do    for i from 1 to nops(coloring) do        if e in coloring[i] then            color[e[]] := i;        end if;    end do;  end do; return color; end proc;
 ${\mathrm{edgecolor}}{≔}{\mathbf{proc}}\left({G}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{i}{,}{e}{,}{\mathrm{color}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{for}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{e}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{in}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{GraphTheory}}{:-}{\mathrm{Edges}}{}\left({G}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{do}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{for}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{i}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{to}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{nops}}{}\left({\mathrm{coloring}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{do}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{e}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{in}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{coloring}}{[}{i}{]}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{then}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{color}}{[}{e}{[}{}{]}{]}{≔}{i}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end do}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end do}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{return}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{color}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (5)
 > $\mathrm{G3}≔\mathrm{StyleEdgesByProperty}\left(\mathrm{G2},\mathrm{edgecolor},\mathrm{colorscheme}=\left["valuesplit",\left[\mathrm{seq}\left(i=\mathrm{cat}\left("Bright",i\right),i=1..c\right)\right]\right],\mathrm{inplace}=\mathrm{false}\right)$
 ${\mathrm{G3}}{≔}{\mathrm{Graph 3: an undirected unweighted graph with 10 vertices and 15 edge\left(s\right)}}$ (6)
 > $\mathrm{DrawGraph}\left(\mathrm{G3}\right)$ > $\mathrm{StyleEdgesByProperty}\left(\mathrm{G2},\mathrm{edgecolor},\mathrm{linestylescheme}=\left["valuesplit",\left[1="solid",2="dash",3="dot",4="dashdot"\right]\right]\right)$
 > $\mathrm{DrawGraph}\left(\mathrm{G2}\right)$  Compatibility

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