Advanced maths

Linear extension count calculator for a partially ordered set

Count all linear extensions of a finite partially ordered set from strict precedence pairs.

Your numbers

Rows on separate lines; comma-separated values within each row.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Count all linear extensions of a finite partially ordered set from strict precedence pairs. A linear extension is a total ordering that respects every entered comparison. The calculator uses subset dynamic programming with exact integer counts and returns one deterministic witness ordering. It does not sample uniformly from the extensions, infer missing observations or count unlabeled posets.

THE FORMULADP(S∪{v}) += DP(S) when every predecessor of v already belongs to S.

A worked example

If zero and one must each precede two, the compatible total orders are 0,1,2 and 1,0,2. The exact linear-extension count is two. A relation cycle is rejected rather than reported as a valid poset with zero extensions.

Good to know

1–20 labeled elements and strict precedence pairs. Counts are exact big integers. Returns a deterministic witness order; uniform random sampling is not included. No counting up to poset automorphisms.

Relations constrain order, not spacing

A pair a,b says element a must appear before b. It does not require adjacency in the final order, and it does not specify how much time separates the elements. Unrelated elements may occur in either order.

Transitive pairs can be included but are unnecessary when already implied by paths. Repeating an implied relation should not change the number of extensions. Numeric labels identify elements rather than their desired final positions.

Two incomparable prerequisites can be ordered either way0120 before 21 before 2Orders: 012 and 102
If zero and one must each precede two, the compatible total orders are 0,1,2 and 1,0,2. The exact linear-extension count is two. A relation cycle is rejected rather than reported as a valid poset with zero extensions. Static schematic; numerical labels define the example.

Counts total orderings compatible with a relation; width and minimum chain decomposition do not count them. The Exact cover calculator with solution counts and chosen subsets offers a complementary calculation under its own stated assumptions.

Ideals as dynamic-programming states

A subset represents elements already placed. An unplaced element can be appended only when all its required predecessors are in that subset. The recurrence adds the number of ways to reach each larger valid subset.

Although the state array includes all subsets, only order ideals receive positive counts. The final full-set entry is the exact number of compatible total orders. This avoids enumerating each permutation explicitly, though the subset count still grows exponentially with ground-set size.

Worked example and mathematical rule

If zero and one must each precede two, the compatible total orders are 0,1,2 and 1,0,2. The exact linear-extension count is two. A relation cycle is rejected rather than reported as a valid poset with zero extensions.

DP(S∪{v}) += DP(S) when every predecessor of v already belongs to S.

Cycles and inconsistent comparisons

A directed cycle such as a before b before a makes a strict partial order impossible. No complete ordering can extend it, so the tool rejects cyclic precedence rather than describing the input as an ordinary poset with zero extensions.

Self-comparisons are also invalid strict relations. A completed valid poset always has at least one linear extension. When importing dependencies, confirm edge direction before concluding the original specification is contradictory.

The witness is not a random schedule

The displayed extension chooses an available element deterministically at each step. It certifies existence but is not a uniform sample and need not represent a typical extension.

Choosing uniformly among currently available elements would not generally produce a uniform distribution over full extensions either, because branches can have different numbers of completions. Uniform sampling would need the dynamic counts to weight choices appropriately and is outside this page’s output.

Extreme cases and useful identities

An antichain on n labeled elements has n factorial extensions. A chain has exactly one.

If two posets are disconnected, their extensions can be interleaved in binomially many ways, multiplying the component counts by the interleaving factor. Adding a genuine new comparison can only reduce or preserve the count. These identities offer independent checks and explain why the exact answer can become very large even for a modest number of elements.

Where this helps and where it stops

Linear extensions describe compatible rankings, task sequences and uncertainty in incomplete order information. They do not account for durations, parallel execution, resources or preferences among allowed orders.

The exact count measures combinatorial freedom under the supplied constraints, not the probability that a particular order occurs in reality. Record the element labels and relation direction with the count. If an application needs weighted or probabilistic rankings, counting equally distinct extensions is only a structural starting point.

A few questions, answered

Must I enter the transitive closure?

No. Direct precedence pairs suffice; implied transitive relations are respected automatically.

Is the witness uniformly random?

No. It is a deterministic valid extension.

What does an antichain produce?

All n factorial labeled permutations are valid.

Does this schedule parallel tasks?

No. A linear extension is a total sequence, not a resource-aware parallel schedule.

Find your calculator

Start typing to explore the library.