pub fn upper_triangular_permutations<T, R, C, S>(
mat: &Matrix<T, R, C, S>,
) -> (PermutationSequence<Dyn>, PermutationSequence<Dyn>)Expand description
Return row/column permutations P, Q (as PermutationSequence) such that: U = P * mat * Q is (upper) block triangular with respect to the SCC block structure induced by a maximum matching.
Notes:
- This is purely structural: it uses mat[(i,j)] != Default::default() as “nonzero”.
- Works best / most meaningfully for square matrices with a perfect matching.
- For rectangular or structurally singular patterns, it still produces a useful diagnostic ordering; unmatched columns are appended at the end.
You apply these like: let (pr, pc) = upper_triangular_permutations(&mat); let mut u = mat.clone(); pr.permute_rows(&mut u); pc.permute_columns(&mut u);