rmpca 0.1.1

Enterprise-grade route optimization engine — Chinese Postman Problem solver with Eulerian circuit detection, Lean 4 FFI boundary, and property-based testing
Documentation
//! Eulerian circuit solver using Hierholzers algorithm.
//!
//! // Aligns with Lean4: theorem `eulerian_circuit_exists`

use crate::optimizer::error::RouteError;
use crate::optimizer::hierholzer;
use crate::optimizer::types::Node;
use petgraph::graph::{DiGraph, NodeIndex};

/// Isolated solver for finding Eulerian circuits in directed graphs.
pub struct EulerianSolver;

impl EulerianSolver {
    /// Find an Eulerian circuit in the given directed graph.
    ///
    /// # Arguments
    /// * `graph` - A directed petgraph graph
    /// * `start_idx` - The node index to start the circuit from
    ///
    /// # Errors
    /// * `RouteError::NotEulerian` - If the graph is not Eulerian
    /// * `RouteError::EmptyGraph` - If the graph has no nodes
    ///
    /// // Aligns with Lean4: theorem `find_circuit_returns_eulerian_circuit`
    pub fn find_circuit<E: Clone>(
        graph: &DiGraph<Node, E>,
        start_idx: NodeIndex,
    ) -> Result<Vec<NodeIndex>, RouteError> {
        hierholzer::directed_eulerian_circuit(graph, start_idx)
    }
}