Advanced maths

Partially ordered set width and chain decomposition calculator

A partially ordered set can contain elements that are incomparable even though a topological ordering lists them sequentially.

Your numbers

Vertices are indexed 0 through n−1.
Rows from,to,weight; absent weight means one. Leave empty for no edges.

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

A partially ordered set can contain elements that are incomparable even though a topological ordering lists them sequentially. This calculator closes a directed acyclic relation transitively, computes a minimum chain partition and finds a maximum antichain. Matching and exhaustive checks verify the same width from two complementary constructions.

THE FORMULAwidth(P)=maximum antichain size=minimum chain-partition size.

A worked example

The diamond order has bottom zero, incomparable middle elements one and two, and top three. Its maximum antichain is {1,2}, of size two. Chains such as 0<1<3 and the singleton 2 partition the set, confirming that two chains are both sufficient and necessary.

Good to know

At most 16 elements, strict precedence edges, cycles rejected. Input may omit transitive edges because closure is computed. No arbitrary equivalence relation, weighted chain cover or replacement of antichains by consecutive positions in a topological sort.

A partial order permits incomparability

A strict partial order is acyclic and transitive. The supplied edges may omit implied relationships because the calculator computes transitive closure. A directed cycle violates strictness and is rejected rather than broken by an arbitrary ordering, which would change the relation whose width is being measured.

Two elements can be incomparable even if a topological sort places one before the other. The sort is only a linear presentation compatible with known precedences, not evidence of a new comparability. Width therefore cannot be read from adjacent positions or from the maximum number of nodes at one arbitrarily chosen drawing level.

The two middle vertices of a diamond form a maximum antichain0123Antichain: {1,2}Width: 2Two chains suffice
The diamond order has bottom zero, incomparable middle elements one and two, and top three. Its maximum antichain is {1,2}, of size two. Chains such as 0<1<3 and the singleton 2 partition the set, confirming that two chains are both sufficient and necessary.

The Topological sort calculator for a directed acyclic graph covers the nearby task. A topological ordering linearizes dependencies; width and chain cover measure incomparable elements.

Chains partition while antichains separate

A chain contains pairwise comparable elements arranged along the order. A chain partition covers every element once. A matching between left and right copies of the transitive relation links compatible consecutive chain members, reducing the number of required chains while preserving the underlying strict order.

An antichain contains pairwise incomparable elements. Its members must occupy different chains in any partition, giving a lower bound on chain count. The calculator searches for an antichain whose size matches the computed chain partition, so the same answer has both an explicit feasible partition and a separating lower-bound witness.

The equality of two constructions verifies width

The diamond order has two incomparable middle elements, immediately ruling out a single chain. Its two-chain partition reaches that lower bound. Adding a transitive edge from bottom to top changes neither width nor the valid relation, which is a useful test that closure rather than raw edge count drives the result.

Independent verification compares exhaustive antichains and the matching-based chain construction on small posets. Weights have no role in this page. Weighted partitions, equivalence classes and cyclic dependency scheduling require other models; the equal-width certificate applies only to the validated finite partial order and its stated bounded vertex set.

Define chains and antichains from the actual order

A chain is a subset whose elements are pairwise comparable under the partial order. An antichain is a subset whose distinct elements are pairwise incomparable. Width is the maximum antichain size. A linear topological ordering lists all elements consistently, but consecutive positions in that list do not automatically form an antichain or a chain.

Enter strict precedence edges, not reflexive self-relations. The calculator computes transitive closure, so 0<1 and 1<2 already imply 0<2 without another row. A directed cycle would make distinct elements precede one another in both directions and is rejected instead of being interpreted as a valid partial order.

Certify the width of the diamond order

Use 0<1,0<2,1<3,2<3. Elements 1 and 2 are incomparable, so {1,2} is an antichain of size two and gives a lower bound on width. Chains {0,1,3} and {2} cover all four elements, providing an upper bound of two. Matching lower and upper certificates prove the width is two.

For an order with no relations on four elements, every pair is incomparable, so width is four and four singleton chains are required. For a total chain 0<1<2<3, the width is one. These checks show that the number of elements and the number of entered relation rows do not determine width by themselves.

See how matching produces a chain partition

Construct a bipartite graph with left and right copies of each element and an edge from left x to right y whenever x<y in the transitive closure. A matching links elements into predecessor-successor chains. If the maximum matching has size M among n elements, a minimum chain partition has n−M chains.

Dilworth’s theorem equates that minimum chain count with maximum antichain size. This implementation also searches antichains explicitly for the supported small order, allowing the two certificates to be compared. The matching uses comparability in the full closure, not merely the cover edges typed into the form; omitting that closure could miss valid chain links.

Avoid overinterpreting width as a complete schedule

A maximum antichain identifies a largest mutually incomparable collection, which can describe potential concurrency under pure precedence. It does not account for durations, resources, release dates or machine constraints. A minimum chain partition likewise groups comparable tasks but is not a complete optimal timetable.

Chains need not be saturated paths in the entered cover graph: comparable elements can be adjacent in a reported chain even if their relation follows through another element assigned elsewhere. That remains a valid partition into chains. Different optimal chain decompositions and maximum antichains can exist; the equality of their sizes is the central invariant, not the exact labeling of one witness.

A few questions, answered

Do I need to enter transitive edges?

No. The page computes transitive closure from the acyclic strict relation.

Why show an antichain and chains?

Their matching sizes certify both a lower bound and an achieved chain-partition width.

Must I enter every transitive relation?

No. Strict precedence edges are enough because the calculator computes closure. It rejects cycles and self-relations that violate the strict-order input.

Is width the minimum number of machines for a real schedule?

Not generally. Width concerns incomparable elements under precedence alone. Durations and resource constraints require a separate scheduling model.

Find your calculator

Start typing to explore the library.