pub fn sort_weight_matrix<T>(matrix: &[Vec<T>]) -> Vec<(usize, usize, T)>where
T: Copy + PartialOrd,
Expand description
Sorts an weight matrix in a ascending order.
The diagonal of the matrix is ignored.
ยงExamples
use rpid::algorithms;
let matrix = vec![
vec![10, 9, 7],
vec![3, 11, 8],
vec![5, 1, 12],
];
let expected = vec![
(2, 1, 1),
(1, 0, 3),
(2, 0, 5),
(0, 2, 7),
(1, 2, 8),
(0, 1, 9),
(0, 0, 10),
(1, 1, 11),
(2, 2, 12),
];
assert_eq!(algorithms::sort_weight_matrix(&matrix), expected);