Expand description
Shortest-path routing over a Graph.
Structs§
- Lagrangian
Route - Outcome of the Lagrangian constrained-shortest-path solver: a feasible
path, its true cost/resource, the best dual lower bound on the optimal
cost (
cost == lower_boundproves optimality), the multiplier that produced it and the number of Dijkstra runs spent. - Pareto
Route - A Pareto-optimal route found by
pareto_paths.edgesholds the input-order indices of the edges actually traversed, so callers can recover attributes/geometry exactly even across parallel edges. - Route
- A route as node path plus the input-order indices of the edges traversed (so callers can recover attributes/geometry, parallel edges included).
Functions§
- csp_
lagrangian - Constrained shortest path by Lagrangian relaxation (the LARAC algorithm):
minimize cost subject to
resource <= budget, dualizing the constraint so each iteration is a plain Dijkstra oncost + lambda * resource. A binary search on the two support paths (cheapest-infeasible and feasible-so-far) driveslambdato the maximizer of the dual, which takes few iterations and scales to graphs where exact label-setting is slow. - csr_
edge_ order - Input-edge index occupying each CSR slot of the graph that
Graph::from_edgesbuilds fromfrom(it replays the same construction order). - dijkstra
- Dijkstra single-source shortest distances. Returns a vector of length
n_nodes; unreachable nodes aref64::INFINITY. - distance_
matrix - Row-major shortest-distance matrix from each source to each target.
- k_
shortest_ paths - Yen’s algorithm for the
kloopless shortest paths fromsourcetotarget. Returns up tokroutes in increasing cost order; Yen operates on the simple-graph abstraction where parallel edges collapse to the minimum weight, so each route’sedgesare those minimum-weight edges. - pareto_
paths - Bicriteria shortest paths from
sourcetotargetby label-setting (Martins’ algorithm): every edge carries a(cost, resource)pair and the result is the Pareto front of nondominated(cost, resource)path values, in increasing cost / decreasing resource order. With a finitebudgetthe front is restricted to paths withresource <= budget, so its first entry solves the constrained shortest path problem exactly.max_routescaps the number of routes returned (usize::MAXfor the whole front). - shortest_
path_ route - Dijkstra with predecessor tracking, returning the shortest path from
sourcetotargetas(node path, traversed CSR slots, cost), orNonewhen the target is unreachable. - tsp_
tour - Heuristic travelling-salesman tour over a row-major
n x ncost matrix. Builds a nearest-neighbour tour and, whenimprove, polishes it with an iterated local search: or-opt/swap/2-opt descent restarted from double-bridge perturbations, keeping the best tour found. The tour starts atstart; whenclosedit returns there (andendis ignored), otherwise a fixedendpins the final stop andNoneleaves it free. Returns the visiting order as indices into the matrix.