Discrete MathRelations

Partial Orders and Hasse Diagrams

Draw a partial order such as "divides" as a Hasse diagram, and list the elements in an order that respects it.

Not started Jump to practice

Other relations behave like "comes before" or "is part of." Math Ladder itself is built on one: a topic can come before another because it is a prerequisite, and some pairs of topics simply have no order between them. Relations like that are partial orders.

Key idea

A partial order is a relation that is reflexive, antisymmetric and transitive. Examples: $\le$ on numbers, "divides" on positive integers, $\subseteq$ on sets. Two elements may be incomparable (neither is below the other). A Hasse diagram draws each element as a point, with $b$ above $a$ and an edge between them exactly when $a$ is below $b$ with nothing in between.

Why it works

The Hasse diagram leaves out loops and every edge that transitivity already implies, and loses nothing. Reflexivity is automatic, so loops carry no information. And $a$ is below $c$ exactly when you can climb from $a$ to $c$ along edges, because each step up is a comparison and transitivity chains them. So the short list of "covering" edges encodes the whole relation, and the picture stays readable.
The divisors of $12$ under "divides." Show all comparisons to add the implied edges (dashed). Then click the numbers in an order where each one comes after everything below it.

Worked examples

Worked example: Drawing a Hasse diagram

List the edges of the Hasse diagram of the divisors of $12$ under "divides."
  1. The divisors are $1, 2, 3, 4, 6, 12$.
  2. Draw an edge from $a$ up to $b$ when $a \mid b$ and no divisor lies strictly between; for divisors this means $b/a$ is prime.
  3. Edges: $1 - 2$, $1 - 3$, $2 - 4$, $2 - 6$, $3 - 6$, $4 - 12$, $6 - 12$. That is $7$ edges. The comparison $1 \mid 12$ is not drawn; it is implied by climbing $1 \to 2 \to 4 \to 12$.

Answer: $7$ edges: $1-2, 1-3, 2-4, 2-6, 3-6, 4-12, 6-12$

Worked example: Minimal and maximal elements

In $S = \{2, 3, 4, 6, 8, 9, 12\}$ under "divides," find the minimal and maximal elements.
  1. Minimal: nothing else in $S$ divides it. $2$ and $3$ qualify; $4$ does not ($2 \mid 4$).
  2. Maximal: it divides nothing else in $S$. $8$, $9$ and $12$ qualify; $6$ does not ($6 \mid 12$).
  3. A partial order can have several minimal and several maximal elements, because some elements are incomparable.

Answer: Minimal: $2, 3$. Maximal: $8, 9, 12$.

Worked example: An order that respects the relation

Courses A, B, C, D, E have prerequisites: A before C, B before C, C before E, B before D. Give an order for taking all five.
  1. A course can be taken once everything below it is done. Start with the minimal ones: A and B.
  2. After A and B, both C and D are available. After C, E is available.
  3. One valid order: A, B, D, C, E. (Others work too, such as B, A, C, D, E.) Such an order is called a topological sort.

Answer: For example A, B, D, C, E

Common mistake

Drawing implied edges, or assuming every two elements are comparable. A Hasse diagram with an edge from $1$ straight to $12$ is cluttered and shows the relation poorly; that edge is already implied. And in "divides," $4$ and $6$ are incomparable: neither divides the other. Check: an edge $a - b$ belongs in the diagram only if nothing fits between; and before saying "the largest element," make sure it really is above everything.
The subsets of $\{1, 2, 3\}$ under $\subseteq$: a cube standing on its corner, with $12$ edges.

Practice

Pass with 3 right answers, the last 2 in a row. Each right answer earns 2 XP.

Loading practice…

Builds on

Leads to

Sources and further reading

  • MIT OpenCourseWare 6.042J Mathematics for Computer Science (Lehman, Leighton and Meyer), chapter "Directed Graphs and Partial Orders"
@teddyrookbook GitHub