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

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 2⁢rn+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 1−kk and k−1k.

• 

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

> 

with⁡PartiallyOrderedSets&colon;

> 

leq≔`<=`&colon;

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

> 

S≔1&comma;2&comma;3&comma;4&comma;5&colon;poset1≔PartiallyOrderedSet⁡S&comma;leq

poset1≔< a poset with 5 elements >

(1)

Display this poset

> 

DrawGraph⁡poset1

Create a poset from a set and a strict partial order

> 

lneq≔`<`&colon;poset1_1≔PartiallyOrderedSet⁡S&comma;lneq

poset1_1≔< a poset with 5 elements >

(2)

Display this poset

> 

DrawGraph⁡poset1_1

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

> 

divisibility≔x&comma;y↦irem⁡y&comma;x=0&colon;T≔3&comma;4&comma;5&comma;6&comma;7&comma;8&comma;9&colon;

> 

poset2≔PartiallyOrderedSet⁡T&comma;divisibility

poset2≔< a poset with 7 elements >

(3)

Display this poset

> 

DrawGraph⁡poset2

Create a poset from a set and a strict partial order

> 

divisibNE≔x&comma;y↦irem⁡y&comma;x=0andy≠x&colon;

> 

poset2_1≔PartiallyOrderedSet⁡T&comma;divisibNE&comma;reflexive=checkfalse

poset2_1≔< a poset with 7 elements >

(4)

Display this poset

> 

DrawGraph⁡poset2_1

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

> 

U≔1&comma;2&comma;3&colon;

> 

poset3≔PartiallyOrderedSet⁡U&comma;leq&comma;reflexive=checktrue

poset3≔< a poset with 3 elements >

(5)

Display this poset

> 

DrawGraph⁡poset3

Create a poset from a set and a strict partial order

> 

poset3_1≔PartiallyOrderedSet⁡U&comma;lneq&comma;reflexive=useclosure

poset3_1≔< a poset with 3 elements >

(6)

Display this poset

> 

DrawGraph⁡poset3_1

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

> 

X≔4&comma;5&comma;6&colon;poset3_2≔PartiallyOrderedSet⁡X&comma;leq&comma;reflexive=checktrue

poset3_2≔< a poset with 3 elements >

(7)

Display this poset

> 

DrawGraph⁡poset3_2

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

> 

adjMatrix4≔Matrix⁡1&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

adjMatrix4≔1111101111001110001100001

(8)
> 

poset4≔PartiallyOrderedSet⁡convert⁡S&comma;list&comma;adjMatrix4

poset4≔< a poset with 5 elements >

(9)

Display this poset

> 

DrawGraph⁡poset4

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

> 

adjList5≔map2⁡map&comma;`+`&comma;Array⁡1&comma;4&comma;7&comma;2&comma;6&comma;3&comma;4&comma;5&comma;6&comma;7&comma;2

adjList5≔3&comma;6&comma;94&comma;856789

(10)
> 

poset5≔PartiallyOrderedSet⁡convert⁡T&comma;list&comma;adjList5

poset5≔< a poset with 7 elements >

(11)

Display this poset

> 

DrawGraph⁡poset5

Create a poset from a set and a directed graph

> 

G≔GraphTheory:-Graph⁡directed&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

G≔Graph 1: a directed graph with 6 vertices, 11 arcs, and 6 self-loops

(12)
> 

poset6≔PartiallyOrderedSet⁡G

poset6≔< a poset with 6 elements >

(13)

Display this poset

> 

DrawGraph⁡poset6

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

> 

poset7≔PartiallyOrderedSet⁡convert⁡U&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

> 

DrawGraph⁡poset7

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

> 

poset8≔PartiallyOrderedSet⁡1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;Array⁡1&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

> 

DrawGraph⁡poset8

Define a polyhedral set and get its dimension

> 

t≔PolyhedralSets:-ExampleSets:-Octahedron⁡

t≔&lcub;Coordinates&colon;x1&comma;x2&comma;x3Relations&colon;−x1−x2−x3≤1&comma;−x1−x2+x3≤1&comma;−x1+x2−x3≤1&comma;−x1+x2+x3≤1&comma;x1−x2−x3≤1&comma;x1−x2+x3≤1&comma;x1+x2−x3≤1&comma;x1+x2+x3≤1

(16)
> 

d≔PolyhedralSets:-Dimension⁡t

d≔3

(17)

Collect the faces of this polyhedral set

> 

t_faces≔seq⁡op⁡PolyhedralSets:-Faces⁡t&comma;dimension=i&comma;i=−0..d&colon;

> 

t_faces≔t_facesunionPolyhedralSets:-ExampleSets:-EmptySet⁡d&colon;

> 

FL≔convert⁡t_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_poset≔PartiallyOrderedSet⁡seq⁡i&comma;i=1..nops⁡FL&comma;inclusion

polyhedral_poset≔< a poset with 28 elements >

(18)

Display this poset

> 

DrawGraph⁡polyhedral_poset

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

> 

M≔Matrix⁡1&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;

> 

poset9≔PartiallyOrderedSet⁡seq⁡1..5&comma;M

poset9≔< a poset with 5 elements >

(19)

Display this poset

> 

DrawGraph⁡poset9

 

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

> 

Z≔1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;10&comma;12&comma;15&comma;20&comma;30&comma;60

Z≔1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;10&comma;12&comma;15&comma;20&comma;30&comma;60

(20)
> 

poset10≔PartiallyOrderedSet⁡Z&comma;divisibility

poset10≔< a poset with 12 elements >

(21)

Display the transitive reduction of this poset

> 

DrawGraph⁡poset10&comma;reduction=true

Display the transitive closure of this poset

> 

DrawGraph⁡poset10&comma;reduction=false

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

> 

DrawGraph⁡poset10&comma;reduction=false&comma;showlabels=false

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

> 

ZZ≔1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;12&comma;15&comma;60

ZZ≔1&comma;2&comma;3&comma;4&comma;5&comma;6&comma;12&comma;15&comma;60

(22)
> 

poset11≔PartiallyOrderedSet⁡ZZ&comma;divisibility

poset11≔< a poset with 9 elements >

(23)

Display this poset using horizontal positions calculated by predecessor maximums

> 

DrawGraph⁡poset11&comma;prefer=low

Display this poset using horizontal positions calculated by sucessor minimums

> 

DrawGraph⁡poset11&comma;prefer=high

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

> 

DrawGraph⁡poset11&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]