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

Add Dijkstra's shortest path algorithm. #6

Open
jureslak opened this issue Apr 20, 2016 · 2 comments
Open

Add Dijkstra's shortest path algorithm. #6

jureslak opened this issue Apr 20, 2016 · 2 comments
Assignees

Comments

@jureslak
Copy link
Member

No description provided.

@jureslak jureslak assigned viddrobnic and zigapk and unassigned viddrobnic Apr 20, 2016
@zigapk
Copy link
Collaborator

zigapk commented May 2, 2016

Should dijkstra only return path length or the entire path?

@jureslak
Copy link
Member Author

jureslak commented May 2, 2016

Hmm, I believe it is best to provide two overloads. As Dijsktra computes the shortest paths from one vertex to all the others (if not stopped early), it seems reasonable to provide an overload that does that, returning distances and previous map, telling for each node which index is the previous in the path.

pair<vector<double>, vector<int>> shortest_path_dijsktra(const graf_t& graf, int origin);

Another should find the shortest path from one vertex to another and break earlier than above, but also return the path, as it costs little more to provide that data.

pair<double, vector<int>> shortest_path_dijsktra(const graf_t& graf, int origin, int target);

This should be consistent with BellmanFord algorithm. @mucamaca

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

3 participants