fn calc_fork_map(towers: &[Tower], fork_tree: &HashMap<usize, Fork>) -> HashMap<usize, usize> {
    let mut lca_map: HashMap<usize, usize> = HashMap::new();
    for tower in towers {
        let mut start = tower.last_fork();
        loop {
            *lca_map.entry(start.id).or_insert(0) += 1;
            if !fork_tree.contains_key(&start.base) {
                break;
            }
            start = fork_tree.get(&start.base).unwrap().clone();
        }
    }
    lca_map
}
/// map of `fork id` to `tower count`
/// This map contains the number of nodes that have the fork as an ancestor.
/// The fork with the highest count that is the newest is the cluster "trunk".
map of `fork id` to `tower count`
This map contains the number of nodes that have the fork as an ancestor.
The fork with the highest count that is the newest is the cluster "trunk".
map of ` fork id ` to ` tower count ` This map contains the number of nodes that have the fork as an ancestor . The fork with the highest count that is the newest is the cluster " trunk " .
fn calc_fork_map(towers: &[Tower], fork_tree: &HashMap<usize, Fork>) -> HashMap<usize, usize> {
    let mut lca_map: HashMap<usize, usize> = HashMap::new();
    for tower in towers {
        let mut start = tower.last_fork();
        loop {
            *lca_map.entry(start.id).or_insert(0) += 1;
            if !fork_tree.contains_key(&start.base) {
                break;
            }
            start = fork_tree.get(&start.base).unwrap().clone();
        }
    }
    lca_map
}
fn calc_fork_map ( towers : & [ Tower ] , fork_tree : & HashMap < usize , Fork > ) -> HashMap < usize , usize > { let mut lca_map : HashMap < usize , usize > = HashMap :: new ( ) ; for tower in towers { let mut start = tower . last_fork ( ) ; loop { * lca_map . entry ( start . id ) . or_insert ( 0 ) += 1 ; if ! fork_tree . contains_key ( & start . base ) { break ; } start = fork_tree . get ( & start . base ) . unwrap ( ) . clone ( ) ; } } lca_map }
map of `fork id` to `tower count`
This map contains the number of nodes that have the fork as an ancestor.
map of ` fork id ` to ` tower count ` This map contains the number of nodes that have the fork as an ancestor .
towers
&[Tower]
fork_tree
&HashMap<usize, Fork>