-
-
Notifications
You must be signed in to change notification settings - Fork 512
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
implement Dijkstra's algorithm for C graphs #7673
Comments
comment:1
To write it I could need an implementation of heaps in Cython ( I would need top keep a list sorted through the execution of the algorithm, with insertion/deletions ). If anybody knows about such a thing, please tell me :-) |
comment:2
I think these are implemented in Please be my guest:-) |
comment:3
Here is one version using heapq from Python.... Once we will have a good Cython implementation of heaps, it will take something like 20 seconds to update it ! :-) |
rebased on 4.3.rc0 + #7640 |
comment:5
Attachment: trac_7673.patch.gz Replying to @rlmill:
OK, I've posted a new patch. |
Author: Nathann Cohen |
Reviewer: Robert Miller |
comment:8
Hi,
|
comment:9
Clearly, it is !! Thank you for taking a lot at it :-) Well, the only bugfix I can think about is to keep in memory the vertex v such that dist_y[v] + dist_x[v] is minimal, and only build the path when the neighborhoods of x and y at distance 2*(dist_y[v] + dist_x[v]) have been explored. It clearly fixes your counter-example, and I think it should solve all others, but I woud be glad to write a nicer solution... Any idea ? :-) Thank you very much again ! :-) Nathann |
comment:10
I don't know if it's nicer, but did you look at how it's done in networkx? Replying to @nathanncohen:
|
comment:11
Replying to @nathanncohen:
Maybe this is related to the "piority queue" in Demaine's descrition
at
|
comment:12
Here is a fixed version :-) |
comment:13
Attachment: trac_7673.2.patch.gz I do not think so, this bug just came from the fact that this version of dijkstra is bidirectional, and I wrongly assumed that as in the simple version of it, the first path found was the correct path. Obviously ( see your example ) it is not, and I expect this version of the algorithm to be correct :-) Nathann |
Changed reviewer from Robert Miller to Robert Miller, Yann Laigle-Chapuy |
comment:14
Sorry I missed that mistake! :o The new patch looks good. |
Merged: sage-4.3.rc1 |
As a follow up of #7640.
CC: @nathanncohen
Component: graph theory
Author: Nathann Cohen
Reviewer: Robert Miller, Yann Laigle-Chapuy
Merged: sage-4.3.rc1
Issue created by migration from https://trac.sagemath.org/ticket/7673
The text was updated successfully, but these errors were encountered: