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

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : PartiallyOrderedSets/DrawGraph

PartiallyOrderedSets

  

DrawGraph

  

displays the directed graph associated with a poset

 

Calling Sequence

Parameters

Options

Description

Layout algorithms

Examples

References

Compatibility

Calling Sequence

DrawGraph(P)

DrawGraph(P,dopts,dgopts)

Parameters

P

-

PartiallyOrderedSet

dopts

-

(optional) zero or more options specific to the Draw command, of the form prefer=l, reduction=b, where l is low or high, and b is a boolean 

dgopts

-

(optional) zero or more options to be passed to the GraphTheory:-DrawGraph command

Options

• 

reduction = truefalse

  

There are two (potentially) different graphs that this command can generate: the graph where the arrows form the transitive reduction of the ordering of P, and the graph where the arrows form the transitive closure of the ordering. By default, DrawGraph displays the transitive reduction graph (the Hasse diagram). When passed the option reduction = false, it displays the transitive closure graph. Passing the option reduction or reduction = true explicitly selects the default transitive reduction graph.

• 

graded = truefalse

  

When laying out the vertices of a transitive reduction graph, Maple chooses between two different but similar algorithms; one applicable only to graded posets and a more general algorithm applicable to all posets. Both are described below. By default, Maple determines if the poset is graded if this is not known already, and then chooses the algorithm for graded posets if applicable and the general algorithm otherwise; except if the option prefer = high is used, then the general algorithm is used.

  

When passing the option graded = false, Maple will bypass this check and always use the algorithm appropriate for all posets.

  

The option graded = true explicitly selects the algorithm appropriate only for graded posets. If the poset is not graded, this option is ignored.

  

The graded option is not supported for drawing the transitive closure graph.

• 

prefer = low or high

  

When using the algorithm appropriate for non-graded posets, the vertices are divided into groups, each group being placed at the same height. Some vertices have a fixed height, whereas for others, there are several possibilities. With the option prefer = low (the default), each vertex gets placed into the lowest group available to it. With the option prefer = high, each vertex gets placed into the highest group available to it.

  

This option is not supported for drawing the transitive closure graph and it is ignored by the algorithm for drawing graded posets. If the algorithm appropriate for non-graded posets is used to draw a graded poset, this option has no effect.

• 

dgopts (not a literal option name)

  

If passing any extra options not mentioned before (represented by dgopts in the calling sequence above), they are passed on to the GraphTheory:-DrawGraph command.

Description

• 

The command DrawGraph(P) displays the vertices and edges of the partially ordered set P as the Maple plot of a graph using the command GraphTheory:-DrawGraph  of the package GraphTheory.

Terminology

• 

A partially ordered set, or poset for short, is a pair (P, <=) where P is a set and <= is a partial order on P. The poset (P, <=) defines a directed graph whose vertices are the elements of P and (a,b) is a directed edge whenever a <= b holds. Conversely, a poset can be defined from a directed graph, assuming that the defined binary relation is anti-symmetric, and transitive, and, either reflexive, or irreflexive.

• 

From now on, we fix a poset (P, <=)

• 

The element a of P is strictly less than the element b of P if a <= b and a \342\211\240 b both hold.

• 

The element b  of P covers the element a of P if a  is strictly less than b and for no element c of P, distinct from both a and b, both a <= c and c <= b hold.

• 

The relation b covers a defines a homogeneous binary relation on P which is the transitive reduction of (P, <=). This is also a directed acyclic graph on P often refers as the Hasse diagram of (P, <=).

Layout algorithms

• 

In this section, we describe the algorithms for layout out the vertices of transitive reduction graphs. As described in the "Options" section, there are two algorithms: one appropriate for graded posets only, and one applicable more generally. We first describe the algorithm for graded posets:

– 

First, the rank of all elements is determined (that is, their value under a rank function), which also determines the split of the elements into connected components. The rank determines the y-coordinate at which a vertex is placed; concretely, the y-coordinates of a vertex corresponding to an element of rank r, in a poset of rank n, is 2rn+1.

– 

To determine the x-coordinate, we proceed connected component by connected component (in arbitrary order), as follows.

• 

First, order the elements of minimal rank in this component arbitrarily. If there are k elements of this rank, place them spaced equidistantly between 1kk and k1k.

• 

Then we iterate over the ranks in ascending order. For each rank, order the elements by the average horizontal position of their immediate predecessors, using the same rule for spacing.

• 

Finally, re-order the minimal rank entries by the average horizontal position of their successors.

– 

If there are fewer than two connected components, we use these x-coordinates directly. Otherwise, we shift each connected component horizontally so that the first connected component has 0 as its left hand bound, and the space between each pair of subsequent connected components is one third of the maximal width of one connected component.

• 

Note that Maple's algorithm for computing ranks sets the rank of the lowest-ranked elements of each connected component of the poset to 0. This can be seen if a poset has two connected components, each of which is ranked, but they have different rank: then this algorithm lays out the components so that their lowest-ranked elements align horizontally.

• 

The more general algorithm proceeds as follows.

– 

We compute all maximal chains and group these by the pair of their minimal and maximal elements. Let S be the set that consists of those chains within each such group of maximal cardinality within that group. For now, we consider only the covering relations within S; we call these the skeleton of the poset. We will find "ranks" for the elements of the chains in S in a straightforward manner, below. Note that some vertices may not be in any of these chains; we will find appropriate ranks for them later. Note furthermore that the elements of the chains in S in a single connected component, are still connected if we only consider the covering relations in S.

– 

We now compute "ranks" for all elements of the chains in S, as follows. We initially color all these elements black. We pick one arbitrarily and set its "rank" to 0, coloring it gray. We then iteratively pick one gray element, color it white, and color its neighbors (both greater and smaller) gray, assigning their "ranks" as we do so. When we have no more gray elements, we have finished this connected component and we can again pick an arbitrary black element if any are left. After we are done with a connected component, we subtract either its minimal (if the prefer = low option is used) or its maximal (if the prefer = high option is used; the default is prefer = low) "rank" from all "ranks" in that component. As a consequence, with prefer = low, the lowest-ranked elements of each connected component will have the same "rank" (0), and with prefer = high, the highest-ranked elements of each connected component will have the same "rank" (0). During this step, we keep track of which of the elements in the chains in S are in which connected component.

– 

Next, we assign "ranks" to the remaining elements of the poset and add them to the correct connected component.

• 

If the prefer = low option is used, we iterate through these elements in an order that is compatible with the partial ordering. When processing an element e, we look at all its immediate predecessors in the partial ordering. There must be some, because otherwise e would be part of a chain in S; and its connected component and "rank" will have been assigned, either when assigning ranks for S or earlier in this loop. We put this element in the same connected component as its predecessors and assign it the maximum of the "ranks" of the predecessors, plus one.

• 

If the prefer = high option is used, we do the same, except we iterate through these elements in the reverse of this order, look at the element's immediate successors rather than predecessors, and assign the minimum of the "ranks" of the successors, minus one.

– 

Once these "ranks" have been assigned, we proceed exactly as in the algorithm for graded posets, except using the newly computed "ranks" instead of the actual ranks of the elements.

Examples

withPartiallyOrderedSets&colon;

leq`<=`&colon;

Create a poset from a set and a non-strict partial order

S1&comma;2&comma;3&comma;4&comma;5&colon;poset1PartiallyOrderedSetS&comma;leq

poset1< a poset with 5 elements >

(1)

Display this poset

DrawGraphposet1

Create a poset from a set and a strict partial order

lneq`<`&colon;poset1_1PartiallyOrderedSetS&comma;lneq

poset1_1< a poset with 5 elements >

(2)

Display this poset

DrawGraphposet1_1

Create a poset from a set and a non-strict partial order

divisibilityx&comma;yiremy&comma;x=0&colon;T3&comma;4&comma;5&comma;6&comma;7&comma;8&comma;9&colon;

poset2PartiallyOrderedSetT&comma;divisibility

poset2< a poset with 7 elements >

(3)

Display this poset

DrawGraphposet2

Create a poset from a set and a strict partial order

divisibNEx&comma;yiremy&comma;x=0andyx&colon;

poset2_1PartiallyOrderedSetT&comma;divisibNE&comma;reflexive=checkfalse

poset2_1< a poset with 7 elements >

(4)

Display this poset

DrawGraphposet2_1

Create a poset from a set and a non-strict partial order

U1&comma;2&comma;3&colon;

poset3PartiallyOrderedSetU&comma;leq&comma;reflexive=checktrue

poset3< a poset with 3 elements >

(5)

Display this poset

DrawGraphposet3

Create a poset from a set and a strict partial order

poset3_1PartiallyOrderedSetU&comma;lneq&comma;reflexive=useclosure

poset3_1< a poset with 3 elements >

(6)

Display this poset

DrawGraphposet3_1

Create a poset from a set and a non-strict partial order

X4&comma;5&comma;6&colon;poset3_2PartiallyOrderedSetX&comma;leq&comma;reflexive=checktrue

poset3_2< a poset with 3 elements >

(7)

Display this poset

DrawGraphposet3_2

Create a poset from a set and an adjacency matrix of a partial order regarded as a directed graph

adjMatrix4Matrix1&comma;1&comma;1&comma;1&comma;1&comma;0&comma;1&comma;1&comma;1&comma;1&comma;0&comma;0&comma;1&comma;1&comma;1&comma;0&comma;0&comma;0&comma;1&comma;1&comma;0&comma;0&comma;0&comma;0&comma;1

adjMatrix41111101111001110001100001

(8)

poset4PartiallyOrderedSetconvertS&comma;list&comma;adjMatrix4

poset4< a poset with 5 elements >

(9)

Display this poset

DrawGraphposet4

Create a poset from a set and an adjacency list of a partial order regarded as a directed graph

adjList5map2map&comma;`+`&comma;Array1&comma;4&comma;7&comma;2&comma;6&comma;3&comma;4&comma;5&comma;6&comma;7&comma;2

adjList53&comma;6&comma;94&comma;856789

(10)

poset5PartiallyOrderedSetconvertT&comma;list&comma;adjList5

poset5< a poset with 7 elements >

(11)

Display this poset

DrawGraphposet5

Create a poset from a set and a directed graph

GGraphTheory:-Graphdirected&comma;1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;1&comma;1&comma;1&comma;2&comma;1&comma;3&comma;1&comma;4&comma;1&comma;5&comma;1&comma;6&comma;2&comma;2&comma;2&comma;4&comma;2&comma;6&comma;3&comma;3&comma;3&comma;5&comma;3&comma;6&comma;4&comma;4&comma;4&comma;6&comma;5&comma;5&comma;5&comma;6&comma;6&comma;6

GGraph 1: a directed graph with 6 vertices, 11 arcs, and 6 self-loops

(12)

poset6PartiallyOrderedSetG

poset6< a poset with 6 elements >

(13)

Display this poset

DrawGraphposet6

Create a poset from a set an adjacency matrix of the transitive reduction of a partial order on that set

poset7PartiallyOrderedSetconvertU&comma;list&comma;1|1|0&comma;0|1|1&comma;0|0|1&comma;input=transitivereduction

poset7< a poset with 3 elements >

(14)

Display this poset

DrawGraphposet7

Create a poset from a set and an adjacency list of the transitive reduction of a partial order on that set

poset8PartiallyOrderedSet1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;Array1&comma;2&comma;3&comma;2&comma;4&comma;3&comma;5&comma;4&comma;6&comma;5&comma;6&comma;6&comma;input=transitivereduction

poset8< a poset with 6 elements >

(15)

Display this poset

DrawGraphposet8

Define a polyhedral set and get its dimension

tPolyhedralSets:-ExampleSets:-Octahedron

t&lcub;Coordinates&colon;x1&comma;x2&comma;x3Relations&colon;x1x2x31&comma;x1x2+x31&comma;x1+x2x31&comma;x1+x2+x31&comma;x1x2x31&comma;x1x2+x31&comma;x1+x2x31&comma;x1+x2+x31

(16)

dPolyhedralSets:-Dimensiont

d3

(17)

Collect the faces of this polyhedral set

t_facesseqopPolyhedralSets:-Facest&comma;dimension=i&comma;i=0..d&colon;

t_facest_facesunionPolyhedralSets:-ExampleSets:-EmptySetd&colon;

FLconvertt_faces&comma;list&colon;

Construct the face lattice of that polyhedral set

inclusion := proc(x,y) PolyhedralSets:-`subset`(FL[x],FL[y]) end proc:

polyhedral_posetPartiallyOrderedSetseqi&comma;i=1..nopsFL&comma;inclusion

polyhedral_poset< a poset with 28 elements >

(18)

Display this poset

DrawGraphpolyhedral_poset

Create a poset from a set and an adjacency matrix of a partial order regarded as a directed graph

MMatrix1&comma;1&comma;1&comma;1&comma;1&comma;0&comma;1&comma;1&comma;0&comma;1&comma;0&comma;0&comma;1&comma;0&comma;1&comma;0&comma;0&comma;0&comma;1&comma;1&comma;0&comma;0&comma;0&comma;0&comma;1&colon;

poset9PartiallyOrderedSetseq1..5&comma;M

poset9< a poset with 5 elements >

(19)

Display this poset

DrawGraphposet9

 

Create a poset from a set and a non-strict partial order

Z1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;10&comma;12&comma;15&comma;20&comma;30&comma;60

Z1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;10&comma;12&comma;15&comma;20&comma;30&comma;60

(20)

poset10PartiallyOrderedSetZ&comma;divisibility

poset10< a poset with 12 elements >

(21)

Display the transitive reduction of this poset

DrawGraphposet10&comma;reduction=true

Display the transitive closure of this poset

DrawGraphposet10&comma;reduction=false

Display the transitive closure of this poset, passing extra options to GraphTheory:-DrawGraph

DrawGraphposet10&comma;reduction=false&comma;showlabels=false

Create a poset from a set and a non-strict partial order

ZZ1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;12&comma;15&comma;60

ZZ1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;12&comma;15&comma;60

(22)

poset11PartiallyOrderedSetZZ&comma;divisibility

poset11< a poset with 9 elements >

(23)

Display this poset using horizontal positions calculated by predecessor maximums

DrawGraphposet11&comma;prefer=low

Display this poset using horizontal positions calculated by sucessor minimums

DrawGraphposet11&comma;prefer=high

Display this poset using horizontal positions calculated by predecessor maximums, passing extra options to GraphTheory:-DrawGraph

DrawGraphposet11&comma;caption=Poset11&comma;size=200&comma;200

References

  

Richard P. Stanley: Enumerative Combinatorics 1. 1997, Cambridge Studies in Advanced Mathematics. Vol. 49. Cambridge University Press.

Compatibility

• 

The PartiallyOrderedSets[DrawGraph] command was introduced in Maple 2025.

• 

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

See Also

PartiallyOrderedSets[ToGraph]

PartiallyOrderedSets[TransitiveClosure]

PartiallyOrderedSets[TransitiveReduction]

GraphTheory[DrawGraph]