evenfurther / pathfinding

Pathfinding library for rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Demo for Munkkres Algorithm

jackpeters667 opened this issue · comments

Hi there, I'm playing around with the crate and I havent been able to get the munkres algorithm working, I suspect i'm missing something fundamentally. Please have a look

        let d2: Vec<Vec<i32>> = vec![vec![2;3];3];
        let matrix = Matrix::from_vec(
            d2.len(),
            d2.get(0).unwrap().len(),
            d2,
        )
        .unwrap();
        let res = kuhn_munkres(&matrix);

But i'm getting trait bound errors on passing matrix to the function. How should I be going about it?

Matrix::from_vec() expects a flat vector, in your case that would be [2; 9]. In your case, you probably want to use Matrix::from_rows() which takes something that can be made into an iterator:

    let d2: Vec<Vec<i32>> = vec![vec![2;3];3];
    let matrix = Matrix::from_rows(d2).unwrap();
    let res = kuhn_munkres(&matrix);