StyleVerticesByProperty - Maple Help

GraphTheory

 StyleVerticesByProperty
 style graph vertices by property

 Calling Sequence StyleVerticesByProperty(G, P, ip)

Parameters

 G - graph P - either a list of numeric values, one for each vertex of G, or a procedure that returns a list of numeric values, one for each vertex of G ip - (optional) equation of the form inplace = true or inplace = false

Options

 • colorscheme : colors
 This sets vertexcolor using ColorTools:-Blend.
 • fontcolorscheme : colors
 This sets vertexfontcolor using ColorTools:-Blend.
 • fontsizescheme : posint
 This sets vertexfontsize. The values given must be valid font sizes in points.
 This sets vertexpadding. The values are given in points.
 • shapescheme : string
 This sets vertexshape. The values are given as strings. 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 StyleVerticesByProperty allows you to set styles for all vertices according to a property.  If no style is specified, the default of colorscheme=["Blue", "White", "Red"] will be used.
 • 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.

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

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $\mathrm{G1}≔\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)$
 ${\mathrm{G1}}{≔}{\mathrm{Graph 1: an undirected unweighted graph with 6 vertices and 7 edge\left(s\right)}}$ (1)
 > $\mathrm{StyleVerticesByProperty}\left(\mathrm{G1},\mathrm{Degree},\mathrm{colorscheme}=\left["Blue","White","Red"\right],\mathrm{range}=0..5\right)$
 > $\mathrm{DrawGraph}\left(\mathrm{G1}\right)$
 > $\mathrm{G2}≔\mathrm{RandomGraphs}:-\mathrm{RandomGraph}\left(10,15,\mathrm{connected}\right)$
 ${\mathrm{G2}}{≔}{\mathrm{Graph 2: an undirected unweighted graph with 10 vertices and 15 edge\left(s\right)}}$ (2)
 > $\mathrm{StyleVerticesByProperty}\left(\mathrm{G2},\mathrm{BetweennessCentrality},\mathrm{fontsizescheme}=\left[8,16\right],\mathrm{colorscheme}=\left["Blue","White","Red"\right]\right)$
 > $\mathrm{DrawGraph}\left(\mathrm{G2},\mathrm{layout}=\mathrm{spring},\mathrm{stylesheet}=\left[\mathrm{vertexshape}="star"\right]\right)$
 > $\mathrm{G3}≔\mathrm{SpecialGraphs}:-\mathrm{FlowerSnark}\left(5\right)$
 ${\mathrm{G3}}{≔}{\mathrm{Graph 3: an undirected unweighted graph with 20 vertices and 30 edge\left(s\right)}}$ (3)
 > $\mathrm{CircularChromaticNumber}\left(\mathrm{G3},'\mathrm{coloring}'\right)$
 $\frac{{5}}{{2}}$ (4)
 > $\mathrm{StyleVerticesByProperty}\left(\mathrm{G3},\mathrm{coloring},\mathrm{colorscheme}=\left["valuesplit",\left[\mathrm{seq}\left(i=\mathrm{cat}\left("Spring",i+1\right),i\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathrm{convert}\left(\mathrm{coloring},\mathrm{set}\right)\right)\right]\right]\right)$
 > $\mathrm{DrawGraph}\left(\mathrm{G3}\right)$

Compatibility

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