pub fn enumerate_graph<V: Ord + Clone>(adj: &Graph<V>) -> Vec<Vec<usize>> {
    let mut result = vec![vec![]; adj.len() + 1];
    let ordering: Vec<V> = adj.keys().cloned().collect();
    for (zero_idx, edges) in adj.values().enumerate() {
        let idx = zero_idx + 1;
        result[idx] = edges
            .iter()
            .map(|x| ordering.binary_search(x).unwrap() + 1)
            .collect();
    }
    result
}
/*
This function creates a graph with vertices numbered from 1 to n for any input
`Graph<V>`. The result is in the form of Vec<Vec<usize> to make implementing
other algorithms on the graph easier and help with performance.

We expect that all vertices, even the isolated ones, to have an entry in `adj`
(possibly an empty vector)
*/
This function creates a graph with vertices numbered from 1 to n for any input
`Graph`. The result is in the form of Vec to make implementing
other algorithms on the graph easier and help with performance.

We expect that all vertices, even the isolated ones, to have an entry in `adj`
(possibly an empty vector)
This function creates a graph with vertices numbered from 1 to n for any input ` Graph ` . The result is in the form of Vec to make implementing other algorithms on the graph easier and help with performance . We expect that all vertices even the isolated ones to have an entry in ` adj ` ( possibly an empty vector )
pub fn enumerate_graph<V: Ord + Clone>(adj: &Graph<V>) -> Vec<Vec<usize>> {
    let mut result = vec![vec![]; adj.len() + 1];
    let ordering: Vec<V> = adj.keys().cloned().collect();
    for (zero_idx, edges) in adj.values().enumerate() {
        let idx = zero_idx + 1;
        result[idx] = edges
            .iter()
            .map(|x| ordering.binary_search(x).unwrap() + 1)
            .collect();
    }
    result
}
pub fn enumerate_graph < V : Ord + Clone > ( adj : & Graph < V > ) -> Vec < Vec < usize > > { let mut result = vec ! [ vec [ ] adj len ( ) 1 ] ; let ordering : Vec < V > = adj . keys ( ) . cloned ( ) . collect ( ) ; for ( zero_idx , edges ) in adj . values ( ) . enumerate ( ) { let idx = zero_idx + 1 ; result [ idx ] = edges . iter ( ) . map ( | x | ordering . binary_search ( x ) . unwrap ( ) + 1 ) . collect ( ) ; } result }
This function creates a graph with vertices numbered from 1 to n for any input
`Graph<V>`.
This function creates a graph with vertices numbered from 1 to n for any input ` Graph<V > ` .
adj
&Graph<V>
adj
&Graph<V>