-
-
Notifications
You must be signed in to change notification settings - Fork 629
PNC k shortest simple path (for directed graphs) #40284
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
base: develop
Are you sure you want to change the base?
Conversation
…o this implementation)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it necessary to define PathCandidate
in a .h file ? can't it be done in file path_enumeration.pxd
?
src/sage/graphs/path_enumeration.pyx
Outdated
G.delete_edges(G.incoming_edges(source, labels=False)) | ||
G.delete_edges(G.outgoing_edges(target, labels=False)) | ||
|
||
if weight_function is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is done by the call to _get_weight_function
. No need to duplicate.
src/sage/graphs/path_enumeration.pyx
Outdated
if self.has_loops() or self.allows_multiple_edges(): | ||
G = self.to_simple(to_undirected=False, keep_label='min', immutable=False) | ||
else: | ||
G = self.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be on the safe side, use self.copy(immutable=False)
src/sage/graphs/path_enumeration.pyx
Outdated
reverse_graph = G.reverse() | ||
dist, successor = shortest_paths(reverse_graph, target, weight_function=reverse_weight_function, | ||
algorithm='Dijkstra_Boost') | ||
cdef set unnecessary_vertices = set(G) - set(dist) # no path to target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
always add 2 spaces before a comment at the end of a line, so set(list) # vertices with no path to target
src/sage/graphs/path_enumeration.pyx
Outdated
|
||
# ancestor_idx_dict[v] := the first vertex reachable by edges of | ||
# first shortest path tree from v | ||
ancestor_idx_dict = dict() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ancestor_idx_dict = {v: i for I, v in enumerate(path)}
Because I want to use priority_queue of C++ standard library, the type of PathCandidate must be struct of C++. Thus, I think I need definition of PathCandidate in .h file. However, There may be another way of doing so without .h file. I am looking for it. |
isn't it possible to use a tuple instead of PathCandidate ? or may be |
Implement PNC k shortest simple path for directed graphs.
I implemented for only directed graphs for simplicity first.
📝 Checklist
⌛ Dependencies
#40248
#40217