Opened 7 years ago
Last modified 7 years ago
#11804 new Library Submissions
Contribution: edge-disjoint k-shortest paths
Reported by: | Owned by: | Jeremiah Willcock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | graph |
Version: | Boost 1.57.0 | Severity: | Not Applicable |
Keywords: | Cc: |
Description
Hi,
I want to contribute a function that calculates edge-disjoint k-shortest paths.
The algorithm searches for a shortest path. Then it disables the edges of the shortest path, and repeats the search. On so on, until no path can be found.
I'm attaching the source file and a unit test.
There are two things that bug me in the code:
- the predecessor map is hardcoded as:
boost::vector_property_map<edge_descriptor> pred(num_vertices(g));
while perhaps it should depend on the graph type,
- the formatting of this call is ugly:
boost::dijkstra_shortest_paths
(fg, s,
visitor(make_dijkstra_visitor(record_edge_predecessors(pred, on_edge_relaxed()))));
I would appreciate it, if someone could give me a hint on these two problems.
I would also appreciate very much any comments and improvements.
Thanks!
Attachments (13)
Change History (22)
by , 7 years ago
Attachment: | edge_disjoint_ksp.hpp added |
---|
comment:1 by , 7 years ago
I attached the second version of the implementation and the unit test. Now the function returns its results in a list, not in a multiset anymore.
comment:2 by , 7 years ago
The reasoning for the used data types:
- the excluded edges are stored in a set in edksp_filter, to make sure that the edge lookup is fast,
- the path is a list (and not a vector), because the length of the path is not known up front (building a path as a vector could resize the vector), and the paths are not expected to be heavily used to merit the use of a vector,
- for the same reasons as for a path, the found paths are returned in a list, not a vector.
by , 7 years ago
Attachment: | edge_disjoint_ksp.3.hpp added |
---|
comment:3 by , 7 years ago
I attached the third version of the implementation and the unit test. This revision has a number of changes:
- bug fix: the Dijkstra call is using the right property map (wm), and not the graph's built in,
- new feature: the user is allowed to provide an optional argument K, which limits the search to at most K shortest paths,
- performance improvement: the Dijkstra search is stopped as soon as the shortest path to the destination vertex is found,
- added more comments,
- moved the call to Dijkstra to a separate function, and made the call well-formatted (i.e., it's not very long).
by , 7 years ago
Attachment: | custom_dijkstra_call.hpp added |
---|
the implementation of the custom dijkstra call - v1
by , 7 years ago
Attachment: | exclude_filter.hpp added |
---|
the implementation of the exclude filter - v1
comment:4 by , 7 years ago
Made the implementation more generic by allowing a user to provide the vector index map. I also moved the implementation of the exclude filter and the custom dijkstra call to separate files.
comment:5 by , 7 years ago
Thanks to Daniel Hofmann for his advice on how to better call the Dijkstra function, i.e. to use the iterator_property_map, and to let the user provide the vector index map. Many thanks!
by , 7 years ago
Attachment: | custom_dijkstra_call.2.hpp added |
---|
the implementation of the custom dijkstra call - v2
comment:6 by , 7 years ago
In revisions just added (edge_disjoint_ksp.5.hpp and custom_dijkstra_call.2.hpp), I only cleaned up the inclusion of header files.
comment:7 by , 7 years ago
I would appreciate some advice on what I should do next to contribute this code. Please let me know.
comment:8 by , 7 years ago
Compile the unit test like this:
g++ -std=c++11 edge_disjoint_ksp.cc -l boost_unit_test_framework -l boost_test_exec_monitor -o edge_disjoint_ksp
comment:9 by , 7 years ago
I added a simplified implementation and a modified unit test. This implementation does not use the exclude_filter.hpp, which I implemented. Instead, we use the filter provided by the filtered_graph.
the implementation