// ---
// tags: trop, source
// crystal-type: source
// crystal-domain: comp
// ---
//! Tropical determinant (minimum-weight perfect matching).
//!
//! trop_det(A) = min over all permutations sigma of sum_i A\[i\]\[sigma(i)\].
//!
//! This is equivalent to the minimum-weight perfect matching in a bipartite
//! graph, solvable in O(n^3) by the Hungarian algorithm. Here we implement
//! the naive O(n!) enumeration for n <= 10.
use crateTropical;
use crateTropMatrix;
/// Maximum dimension for the naive determinant algorithm.
const MAX_NAIVE_DIM: usize = 10;
/// Compute the tropical determinant of a square matrix.
///
/// trop_det(A) = min_{sigma in S_n} sum_i A\[i\]\[sigma(i)\]
///
/// # Panics
/// Panics if `n > 10` (use the Hungarian algorithm for larger matrices).
/// Evaluate the cost of the current permutation and update best.
/// Generate all permutations via Heap's algorithm and evaluate each.
trop/rs/src/determinant.rs
ฯ 0.0%