StyleEdgesByProperty - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


GraphTheory

  

StyleEdgesByProperty

  

style graph edges by property

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

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 schemes 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

withGraphTheory:

GGraphweighted,1,2,1,3,2,3,3,4,4,5,4,6,5,6

GGraph 1: an undirected weighted graph with 6 vertices and 7 edge(s)

(1)

RandomGraphs:-AssignEdgeWeightsG,1..10

Graph 1: an undirected weighted graph with 6 vertices and 7 edge(s)

(2)

StyleEdgesByPropertyG,WeightMatrix,colorscheme=Blue,Red,thicknessscheme=0.5,2.5

DrawGraphG

Here is an example of how to use the output of EdgeChromaticNumber to create an edge coloring

G2SpecialGraphs:-PetersenGraph

G2Graph 2: an undirected graph with 10 vertices and 15 edge(s)

(3)

cEdgeChromaticNumberG2,coloring

c4

(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;

edgecolorprocGlocali,e,color;foreinGraphTheory:-EdgesGdoforitonopscoloringdoifeincoloring[i]thencolor[e[]]iend ifend doend do;returncolorend proc

(5)

G3StyleEdgesByPropertyG2,edgecolor,colorscheme=valuesplit,seqi=catBright ,i,i=1..c,inplace=false

G3Graph 3: an undirected graph with 10 vertices and 15 edge(s)

(6)

DrawGraphG3

StyleEdgesByPropertyG2,edgecolor,linestylescheme=valuesplit,1=solid,2=dash,3=dot,4=dashdot

DrawGraphG2

Compatibility

• 

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

• 

For more information on Maple 2020 changes, see Updates in Maple 2020.

See Also

DrawGraph

StyleEdge

StyleSubgraph

Vertices