upper_triangular_permutations

Function upper_triangular_permutations 

Source
pub fn upper_triangular_permutations<T, R, C, S>(
    mat: &Matrix<T, R, C, S>,
) -> (PermutationSequence<Dyn>, PermutationSequence<Dyn>)
where T: Scalar + PartialEq + Default, R: Dim, C: Dim, S: Storage<T, R, C>,
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);