fn create_all_paths<'a>(
    key: &'a str,
    h: &'a HashMap<String, Vec<(i32, String)>>,
) -> HashSet<&'a str> {
    // We go through all the keys multiple times until we have no more to go over.
    let mut ret = HashSet::new();
    // We enter this value initially.
    ret.insert(key);

    loop {
        let ret_before = ret.len();
        for (k, v) in h {
            for elem in v {
                if ret.contains(elem.1.as_str()) {
                    ret.insert(k.as_str());
                }
            }
        }
        let ret_after = ret.len();

        if ret_before == ret_after {
            // This means that there are no ways of getting to these nodes and that would mean they
            // are the outer most nodes.
            break;
        }
    }
    ret.remove(key);
    ret
}
/// This is going through the map and construct a tree of all the ways to reaching the
/// key node from everywhere else. This returns a vec of sets.
/// The 0th level is the key itself.
/// The 1st level is all the keys, that lead to any on level 0
/// and so on.
This is going through the map and construct a tree of all the ways to reaching the
key node from everywhere else. This returns a vec of sets.
The 0th level is the key itself.
The 1st level is all the keys, that lead to any on level 0
and so on.
This is going through the map and construct a tree of all the ways to reaching the key node from everywhere else . This returns a vec of sets . The 0th level is the key itself . The 1st level is all the keys that lead to any on level 0 and so on .
fn create_all_paths<'a>(
    key: &'a str,
    h: &'a HashMap<String, Vec<(i32, String)>>,
) -> HashSet<&'a str> {
    // We go through all the keys multiple times until we have no more to go over.
    let mut ret = HashSet::new();
    // We enter this value initially.
    ret.insert(key);
    loop {
        let ret_before = ret.len();
        for (k, v) in h {
            for elem in v {
                if ret.contains(elem.1.as_str()) {
                    ret.insert(k.as_str());
                }
            }
        }
        let ret_after = ret.len();
        if ret_before == ret_after {
            // This means that there are no ways of getting to these nodes and that would mean they
            // are the outer most nodes.
            break;
        }
    }
    ret.remove(key);
    ret
}
fn create_all_paths < ' a > ( key : & ' a str , h : & ' a HashMap < String , Vec < ( i32 , String ) > > , ) -> HashSet < & ' a str > { // We go through all the keys multiple times until we have no more to go over. let mut ret = HashSet :: new ( ) ; // We enter this value initially. ret . insert ( key ) ; loop { let ret_before = ret . len ( ) ; for ( k , v ) in h { for elem in v { if ret . contains ( elem . 1 . as_str ( ) ) { ret . insert ( k . as_str ( ) ) ; } } } let ret_after = ret . len ( ) ; if ret_before == ret_after { // This means that there are no ways of getting to these nodes and that would mean they // are the outer most nodes. break ; } } ret . remove ( key ) ; ret }
This is going through the map and construct a tree of all the ways to reaching the
key node from everywhere else.
This is going through the map and construct a tree of all the ways to reaching the key node from everywhere else .
key
&'a str
h
&'a HashMap<String, Vec<(i32, String)>>
key
&'a str
h
&'a HashMap<String, Vec<(i32, String)>>