pub fn check_hamiltonian(&self) -> HamiltonianResult {
        // Check if all edges link back.
        for vertex in 0..self.0.len() {
            let adj = self[vertex];

            let adj0 = self[adj.0];
            if adj0.0 != vertex && adj0.1 != vertex {
                return dbg!(HamiltonianResult::NoEdgeBack(vertex, adj.0, adj0));
            };

            let adj1 = self[adj.1];
            if adj1.0 != vertex && adj1.1 != vertex {
                return dbg!(HamiltonianResult::NoEdgeBack(vertex, adj.1, adj1));
            };
        }

        // Check if all vertices are present
        for vertex in 0..self.0.len() {
            if !self.vertices_visited().any(|v| v == vertex) {
                return dbg!(HamiltonianResult::NotVisited(vertex));
            }
        }

        HamiltonianResult::Ok
    }
/// Check if the path is complete and Hamiltonian.
/// This method is not optimized and is supposed to be used only for debug/sanity purposes.
Check if the path is complete and Hamiltonian.
This method is not optimized and is supposed to be used only for debug/sanity purposes.
Check if the path is complete and Hamiltonian . This method is not optimized and is supposed to be used only for debug / sanity purposes .
pub fn check_hamiltonian(&self) -> HamiltonianResult {
        // Check if all edges link back.
        for vertex in 0..self.0.len() {
            let adj = self[vertex];
            let adj0 = self[adj.0];
            if adj0.0 != vertex && adj0.1 != vertex {
                return dbg!(HamiltonianResult::NoEdgeBack(vertex, adj.0, adj0));
            };
            let adj1 = self[adj.1];
            if adj1.0 != vertex && adj1.1 != vertex {
                return dbg!(HamiltonianResult::NoEdgeBack(vertex, adj.1, adj1));
            };
        }
        // Check if all vertices are present
        for vertex in 0..self.0.len() {
            if !self.vertices_visited().any(|v| v == vertex) {
                return dbg!(HamiltonianResult::NotVisited(vertex));
            }
        }
        HamiltonianResult::Ok
    }
pub fn check_hamiltonian ( & self ) -> HamiltonianResult { // Check if all edges link back. for vertex in 0 .. self . 0 . len ( ) { let adj = self [ vertex ] ; let adj0 = self [ adj . 0 ] ; if adj0 . 0 != vertex && adj0 . 1 != vertex { return dbg ! ( HamiltonianResult NoEdgeBack ( vertex adj 0 adj0 ) ) ; } ; let adj1 = self [ adj . 1 ] ; if adj1 . 0 != vertex && adj1 . 1 != vertex { return dbg ! ( HamiltonianResult NoEdgeBack ( vertex adj 1 adj1 ) ) ; } ; } // Check if all vertices are present for vertex in 0 .. self . 0 . len ( ) { if ! self . vertices_visited ( ) . any ( | v | v == vertex ) { return dbg ! ( HamiltonianResult NotVisited ( vertex ) ) ; } } HamiltonianResult :: Ok }
Check if the path is complete and Hamiltonian.
Check if the path is complete and Hamiltonian .
&self
&self