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
Implementing the Yen's algorithm and its improved versions #27859
Comments
Changed keywords from none to gsoc19 |
Author: Rajat Mittal |
Commit: |
comment:4
This is the implementation of original yen's algorithm for k shortest paths which the method will return as an iterator. This will be compared with the improved yen's(Feng) algorithm which will be implemented shortly. shortest_path methods are also enhanced by adding exclude_vertices and exclude_edges parameter which are required for Yen's or improved Yen's algorithm. If some improvements are possible please let me know so I can improve the above method. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:8
I'm a bit reluctant to the changes you did in You must try to have the minimum possible impact on them. For instance do:
you could also create Is method |
comment:10
I have made the changes in shortest_paths methods to have a minimal effect of exclude_edges and exclude_vertices. yen_k_shortest_paths is for both the directed as well as undirected graphs as evident from the examples in the method.
|
comment:11
Replying to @rajat1433:
you were too fast. You still have
The first lines of description are not clear. That's why I asked. Plus it would be better to have a single line of description. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:13
Oops! I have made the description more clear and also concised the checks and removed "if not exclude_edges and not exclude_vertices:" these from wherever unnecessary. If there is further any improvement possible please let me know. |
comment:14
What about: - if exclude_edges and ((out == 1 and (u, w) not in exclude_edges_int) or (out == -1 and (w, u) not in exclude_edges_int)):
- if not exclude_vertices or (exclude_vertices and w not in exclude_vertices_int):
- neighbors.append(w)
- elif not exclude_edges and exclude_vertices and w not in exclude_vertices_int:
- neighbors.append(w)
+ if exclude_vertices and w not in exclude_vertices_int:
+ neighbors.append(w)
+ elif (exclude_edges and
+ ((out == 1 and (u, w) not in exclude_edges_int) or
+ (out == -1 and (w, u) not in exclude_edges_int))):
+ neighbors.append(w) |
comment:15
I think there may be a problem in that, consider that w is not in exclude_vertices(there are other vertices though) but (u,w) is present in exclude_edges then w will be appended as a neighbor, but it should be not appended. |
comment:16
+ if exclude_vertices and w in exclude_vertices_int:
+ continue
+ if (exclude_edges and
+ ((out == 1 and (u, w) in exclude_edges_int) or
+ (out == -1 and (w, u) in exclude_edges_int))):
+ continue
+ neighbors.append(w) |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:150
I rebased on last beta and fixed merge conflicts. Then I added a test on random digraphs. I have not yet identified new issues, and I hope I will not find any ;) |
comment:151
I did the following test and I don't understand why Feng is significantly slower than Yen. Do you have any idea of the parts that must be improved ?
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:153
|
comment:154
|
comment:155
Though I have improved the speed of Feng's significantly from the version just before but still in some cases Yen is faster and in some cases Feng is faster. |
comment:157
I did some minor edits in Yen and Feng. In Feng, why are you adding/removing edges ? can't we avoid that ? |
comment:159
Adding and Removing edges in Feng's is required when we find express edges so that we can update the head node of express edges directly to the target. (This is done because the cost of the path between the head of express edge and the target becomes zero as per the cost function defined by Feng in his paper.) And when we move to the next vertex for deviation of the current path we update the express edges and also remove the additional edges of some vertices we introduced previously which are no longer valid. Though I have tried not to remove the vertices and nodes in the graph by using exclude_vertices and exclude_edges set so that we don't have to remove and add again and again, but adding the edges from head of express edge to target was a necessity as described in the algorithm. |
comment:160
I agree. So I propose to let speed-up improvements of the algorithms to future tickets. Good to go. |
Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:
|
comment:162
@dcoudert |
comment:163
Please don't do that. Such kind of modification can be postpone to another ticket. |
Changed branch from public/graphs/27859_enumerate_paths to |
This ticket aims at implementing the Yen's algorithm and its improved version for k shortest simple path enumeration between the source and the target. The implementation will be compared to the original yen's algorithm.
CC: @dcoudert
Component: graph theory
Keywords: gsoc19
Author: Rajat Mittal
Branch/Commit:
fcfa3e6
Reviewer: David Coudert
Issue created by migration from https://trac.sagemath.org/ticket/27859
The text was updated successfully, but these errors were encountered: