graphlib icon indicating copy to clipboard operation
graphlib copied to clipboard

Add shortest path iterator

Open octavonce opened this issue 6 years ago • 6 comments

In order to support more use cases, we can add a shortest path between two nodes iterator.

octavonce avatar Mar 14 '19 13:03 octavonce

What should be preferred? Bellman–Ford or Dijkstra's algorithm. Or both!

cherrygot-personal avatar Mar 18 '19 10:03 cherrygot-personal

Yes! We can certainly do both!

We can expose them as Graph::bellman_ford() and Graph::dijkstra().

octavonce avatar Mar 19 '19 14:03 octavonce

I was trying to implement the Dijkstra algorithm, but found that there is no method to get the weight of edge between two vertices. Maybe you can help. If I have 'VertexId's of two nodes, how would I know weight of edge between them?

cherrygot-personal avatar Mar 25 '19 12:03 cherrygot-personal

Maybe we need to do these first: #4 #3 and also include a Graph::weight method which receives as parameters two VertexId structs.

octavonce avatar Mar 25 '19 23:03 octavonce

Graph::dijkstra() and iterator::Dijkstra exist now.

cemeyer avatar Dec 09 '21 14:12 cemeyer

Sorry if this is out of nowhere, but would it not be a more productive approach to implement the traits in petgraph to get access to all their algorithms implemented in petgraph::algo?

Is it because of the no-std option that this route was not taken?

saona-raimundo avatar Jan 12 '22 08:01 saona-raimundo