fn process_vertex(
        id: u64,
        vertices: &HashMap<u64, DeviceVertex>,
        states: &mut HashMap<u64, State>,
    ) -> bool {
        states.insert(id, State::Processing);
        if let Some(vertex) = vertices.get(&id) {
            for child_id in vertex.child_ids.iter() {
                match states.get(child_id) {
                    // We found another Node that's processing which means
                    // there's a cycle.
                    Some(State::Processing) => {
                        return true;
                    }
                    Some(State::Unprocessed) => {
                        // Check our unprocessed child for cycles and return if
                        // we find one.
                        if process_vertex(*child_id, vertices, states) {
                            return true;
                        }
                    }
                    _ => {}
                }
            }
        }

        // We have not found any cycles so mark Node as processed.
        states.insert(id, State::Processed);
        false
    }
// Process a vertex and its children for cycles.
// Returns true if there's a cycle and false if there is not.
Process a vertex and its children for cycles.
Returns true if there's a cycle and false if there is not.
Process a vertex and its children for cycles . Returns true if there ' s a cycle and false if there is not .
fn process_vertex(
        id: u64,
        vertices: &HashMap<u64, DeviceVertex>,
        states: &mut HashMap<u64, State>,
    ) -> bool {
        states.insert(id, State::Processing);
        if let Some(vertex) = vertices.get(&id) {
            for child_id in vertex.child_ids.iter() {
                match states.get(child_id) {
                    // We found another Node that's processing which means
                    // there's a cycle.
                    Some(State::Processing) => {
                        return true;
                    }
                    Some(State::Unprocessed) => {
                        // Check our unprocessed child for cycles and return if
                        // we find one.
                        if process_vertex(*child_id, vertices, states) {
                            return true;
                        }
                    }
                    _ => {}
                }
            }
        }
        // We have not found any cycles so mark Node as processed.
        states.insert(id, State::Processed);
        false
    }
fn process_vertex ( id : u64 , vertices : & HashMap < u64 , DeviceVertex > , states : & mut HashMap < u64 , State > , ) -> bool { states . insert ( id , State :: Processing ) ; if let Some ( vertex ) = vertices . get ( & id ) { for child_id in vertex . child_ids . iter ( ) { match states . get ( child_id ) { // We found another Node that's processing which means // there's a cycle. Some ( State :: Processing ) => { return true ; } Some ( State :: Unprocessed ) => { // Check our unprocessed child for cycles and return if // we find one. if process_vertex ( * child_id , vertices , states ) { return true ; } } _ => { } } } } // We have not found any cycles so mark Node as processed. states . insert ( id , State :: Processed ) ; false }
Process a vertex and its children for cycles.
Process a vertex and its children for cycles .
id
u64
vertices
&HashMap<u64, DeviceVertex>
states
&mut HashMap<u64, State>
id
u64
vertices
&HashMap<u64, DeviceVertex>
states
&mut HashMap<u64, State>