// ---
// tags: trop, source
// crystal-type: source
// crystal-domain: comp
// ---
//! Tropical eigenvalue (minimum mean cycle weight).
//!
//! The tropical eigenvalue of a matrix A is
//! lambda = min over all elementary cycles C of (weight(C) / |C|).
//!
//! This implementation uses Karp's algorithm:
//! 1. Compute D\[k\]\[v\] = min-weight k-edge walk from source 0 to v, for k = 0..n.
//! 2. lambda = min_v max_{0 <= k < n} (D\[n\]\[v\] - D\[k\]\[v\]) / (n - k).
//!
//! Since we work in u64, we return the numerator and denominator separately
//! in a rational form, then produce the floor as a Tropical value.
use crateTropical;
use crate;
/// Compute the tropical eigenvalue (minimum mean cycle weight).
///
/// Returns `Tropical::INF` if the graph is acyclic (no cycles).
///
/// For graphs with cycles, returns `Tropical(floor(lambda))` where
/// lambda is the minimum mean cycle weight.
///
/// Uses Karp's algorithm: O(n^2 * n) = O(n^3).
trop/rs/src/eigenvalue.rs
π 0.0%