Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floyd-Warshall implementation doesn't work on undirected graphs. #524

Closed
cryslith opened this issue Dec 6, 2022 · 3 comments
Closed

Floyd-Warshall implementation doesn't work on undirected graphs. #524

cryslith opened this issue Dec 6, 2022 · 3 comments

Comments

@cryslith
Copy link

cryslith commented Dec 6, 2022

use petgraph::{graph::{UnGraph, NodeIndex}, algo::floyd_warshall::floyd_warshall}; // 0.6.2

fn main() {
    let mut g: UnGraph<(), ()> = UnGraph::new_undirected();
    let n1 = g.add_node(());
    let n2 = g.add_node(());
    g.add_edge(n1, n2, ());
    println!("{:?}", floyd_warshall(&g, |_| 1));
}

outputs Ok({(NodeIndex(0), NodeIndex(0)): 0, (NodeIndex(1), NodeIndex(0)): 2147483647, (NodeIndex(1), NodeIndex(1)): 0, (NodeIndex(0), NodeIndex(1)): 1})

I expect the distance from node 1 to node 0 to be 1 rather than the max integer.

@Dr-Emann
Copy link

This appears to have been fixed in #487, but hasn't been released yet.

@jfarrell468
Copy link

I encountered this as well.

@ABorgna
Copy link
Member

ABorgna commented Feb 7, 2023

The bugfix has been published in 0.6.3.

@ABorgna ABorgna closed this as completed Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants