Add multi-route comparison with Yen's k-shortest-paths algorithm

- Yen's algorithm in Rust: finds up to 3 distinct shortest routes by
  iteratively deviating from previously found paths with node exclusions
- Routes are deduplicated by station sequence (same stations = same route
  even if timing differs slightly)
- Dijkstra refactored to support node exclusion sets for Yen's spur paths
- WASM API returns JSON array of RouteResult (was single object)
- Frontend routing store holds multiple routes with selectedRouteIndex
- Route tabs: "Fastest", "Alternative 1", "Alternative 2" with distinct
  colors (orange, blue, purple), click to switch and resample trajectory
- Compact route planner layout: 2-column From/To, shorter window buttons
- Tested: Earth L1 → Jupiter L1 finds 2-leg relay via Mercury L1 (6.9mo)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-08 12:48:39 -07:00
parent 2ebe0e90d0
commit 3099b58ea0
5 changed files with 420 additions and 219 deletions

View File

@@ -213,17 +213,19 @@ pub fn compute_route(
},
);
// Find optimal route
let route = router::find_optimal_route(
// Find up to 3 shortest routes using Yen's algorithm
let routes = router::find_k_shortest_routes(
&matrix,
from_station,
to_station,
0,
week_window.saturating_sub(1),
3,
);
match route {
Some(r) => serde_json::to_string(&r).unwrap_or_default(),
None => String::new(),
if routes.is_empty() {
String::new()
} else {
serde_json::to_string(&routes).unwrap_or_default()
}
}