How this calculation works
Given an arbitrary binary matrix, decide whether columns can be permuted to make every row a single 1-block, count all labeled valid orders, and provide an order. Interval graph recognition is a derived application and does not accept arbitrary row constraints or count orders.
For each row r, {j:M[r,π(j)]=1} is empty or an interval; N=number of labeled permutations π satisfying every row.A worked example
The rows [1,1,0] and [0,1,1] allow exactly two column orders: [0,1,2] and [2,1,0]. Their shared column 1 must lie between columns 0 and 2.
Good to know
Binary matrix ≤30 rows and ≤9 columns; enumerate ≤362,880 labeled column permutations with prefix pruning. Exact count and first 100 orders; full count computed before sample truncation.
Reference: SageMath: PQ-Trees and consecutive ones (opens in a new tab) ↗
Consecutive ones row constraints
The consecutive-ones property asks for one column permutation that makes each row’s ones form a single contiguous block. Different rows may have blocks of different lengths and positions.
All-zero rows impose no restriction, and all-one rows are automatically contiguous. The requirement concerns the positions after permutation, not the original numerical order of the column labels.
Compare this with the Interval graph recognition calculator with an interval representation. Given an arbitrary binary matrix, decide whether columns can be permuted to make every row a single 1-block, count all labeled valid orders, and provide an order. Interval graph recognition is a derived application and does not accept arbitrary row constraints or count orders.
Labeled-column counting conventions
Columns remain labeled even when their entries are identical. Exchanging two identical columns gives a distinct labeled order, so the count can exceed the number of visually different reordered matrices.
A reversal of a valid order is valid as well. The calculator counts both directions instead of identifying mirror orders, except when a one-column input makes them the same permutation. For rows [1,1,0] and [0,1,1], a valid order must place the shared middle column between the other two. The labeled orders [0,1,2] and [2,1,0] both work, giving count two. Reversing any valid full order preserves the consecutive-ones property, which provides a basic symmetry check. Identical columns are still distinct labeled objects here, so permuting them can create separate counted orders even when the displayed binary matrix looks unchanged.
Prefix row-state pruning
During a prefix search, each row is not yet started, currently inside its one-block, or already closed after a zero following a one. A later one in a closed row rejects that prefix.
This three-state rule detects an unavoidable 1–0–1 pattern before completing the order. It prunes the enumeration without changing which complete labeled permutations are counted.
Recovering a column order
A positive result returns at least one order and the block endpoints of each nonempty row. Reordering the input matrix by that order and checking every row gives a direct certificate.
The exact total is accumulated over the full search. A bounded sample list can stop displaying more orders while counting continues, provided the result clearly distinguishes sample size from total count. During backtracking, a row progresses through three states: before its block, inside its block and after its block. Once a zero has ended a nonempty block, a later one invalidates that partial ordering and the branch is pruned. Complete branches contribute to the exact count, while only the first hundred orders are displayed. At most nine columns keeps this enumeration bounded. The implementation does not claim the scalability of a PQ-tree algorithm, although the mathematical property is the same.
Interval endpoint certificate
For rows {0,1} and {1,2}, the shared label 1 must sit between 0 and 2. The two orders are therefore 0,1,2 and its reversal 2,1,0.
Adding row {0,2} makes the instance impossible: all three pairs would have to be adjacent in a line of three positions, which has only two adjacent pairs.
An impossible three-row example
The illustration places the scrambled matrix beside a valid reordered version. Colored cells show the one-blocks, and the displayed column labels make the permutation independently recoverable.
Consecutive-ones constraints also appear inside interval-graph recognition, but arbitrary binary rows need not come from a graph’s maximal-clique matrix. This page accepts and counts the general matrix constraints directly. An all-zero row imposes no restriction, and an all-one row is automatically consecutive in every order. A matrix failing the test cannot be repaired merely by sorting columns by their sums; equal or favorable sums do not encode the rowwise interval constraints. The result says whether the supplied rows can all be intervals on one column line, not whether the matrix is totally unimodular or represents every broader class of interval structures.
Exhaustive count and bounded listing
The initial small-column engine may use exhaustive prefix search rather than construct a PQ-tree. Its correctness comes from complete enumeration within the stated limit, not from an unimplemented data structure.
Circular ones allow a block to wrap around the boundary and define a different property. Such wrapping must not be accepted here; a row’s first and last one must bound a fully occupied linear interval.
A few questions, answered
Can columns with identical entries be exchanged?
Yes. They remain distinct labeled columns, and exchanging them contributes another counted order.
Are all-zero rows allowed?
Yes. An all-zero row imposes no restriction on the labeled column order, so it leaves the valid-order count unchanged.
Is circular ones the same property?
No. Circular ones permits boundary wrapping; this calculator requires a linear interval.
Does the tool construct a PQ-tree?
The initial bounded algorithm uses prefix search and does not claim PQ-tree output.