Statistical Methods
Reorder a Sparse Pattern Without Losing Variable Identities
Define the task
Sparse matrix bandwidth depends on variable ordering. A simultaneous row-and-column permutation can move nonzero entries closer to the diagonal without changing the underlying relationships. Preserve a mapping from each new position to the original variable identifier. The teaching tool operates on a symmetric binary adjacency pattern with a zero diagonal. It is intended to audit structure, not numerical factorization accuracy or statistical association.
Carry out the check
First compute the original maximum distance |i−j| over nonzero entries. The tool starts at a lowest-degree unvisited node, visits neighbors by increasing degree with index tie-breaking, repeats for disconnected components, and reverses the complete visitation order. Apply the resulting permutation to both matrix axes. Compare the new bandwidth rather than assuming improvement. Reverse Cuthill–McKee orderings may differ across implementations because of starting-node and tie choices, and the heuristic does not guarantee minimum bandwidth.
Worked hypothetical example
Hypothetical example: nodes ordered 0,1,2,3 form a path with edges 0–3, 3–1 and 1–2. Original bandwidth is 3. The displayed deterministic ordering is 2,1,3,0, reducing bandwidth to 1. Record this as new position → old index; confusing it with the inverse mapping mislabels results. With no edges, bandwidth is zero and any permutation leaves it zero. Validate that every original identifier appears exactly once before reattaching labels or interpreting a downstream solution.
Method checked 24 November 2026 against primary documentation: sparse.csgraph.reverse_cuthill_mckee.