Commit Graph

6 Commits

Author SHA1 Message Date
Dan Kortschak
9e7bb93637 graph/path: allow cost-based Yen shortest path calculation
This adds an additional constraint onto YenKShortestPaths to consider
the paths' cost as well as the number of paths, enabling search within a
constrained distance.
2023-06-26 19:49:09 +09:30
Dan Kortschak
d6b9d45e9e graph/path: fix yen k-shortest path with root cycles
Previously the code was not removing nodes on the root of the search
path, resulting in searches that could re-enter previously searched
nodes. In addition to this, the logic for making edges was incorrectly
marking both directions for digraphs and only one direction for
undirected graphs.

Finally, the range of nodes to include in the spur-node set was
off-by-one. This is now clarified by including the comment from the wiki
article since the pseudo-code is less clear than the English due to
choice of range indexing convention.
2023-01-17 06:39:13 +10:30
Dan Kortschak
8f6a7707f4 graph/internal/ordered: replace slice sort types with sort.Slice calls 2021-10-14 07:01:58 +10:30
Dan Kortschak
8d530b6437 graph/path: fix YenKShortestPaths 2021-08-27 17:46:02 +09:30
Egon Elbre
b6ceadb9b7 graph/path: make tests parallel 2020-03-16 16:10:59 +02:00
Dan Kortschak
0d92706921 graph/path: add Yen k-shortest paths implementation
Also add Rishi Desai, primary-author of the commit.
2018-08-22 07:50:28 +09:30