fn dfs(
            key: u64,
            adj: &BTreeMap<u64, BTreeSet<u64>>,
            mut visited: &mut BTreeSet<u64>,
            mut component: &mut BTreeSet<u64>,
        ) {
            visited.insert(key);
            component.insert(key);
            for value in adj.get(&key).unwrap() {
                if !visited.contains(value) {
                    dfs(*value, adj, &mut visited, &mut component);
                }
            }
        }
// Do depth first search in the data items and group them together.
Do depth first search in the data items and group them together.
Do depth first search in the data items and group them together .
fn dfs(
            key: u64,
            adj: &BTreeMap<u64, BTreeSet<u64>>,
            mut visited: &mut BTreeSet<u64>,
            mut component: &mut BTreeSet<u64>,
        ) {
            visited.insert(key);
            component.insert(key);
            for value in adj.get(&key).unwrap() {
                if !visited.contains(value) {
                    dfs(*value, adj, &mut visited, &mut component);
                }
            }
        }
fn dfs ( key : u64 , adj : & BTreeMap < u64 , BTreeSet < u64 > > , mut visited : & mut BTreeSet < u64 > , mut component : & mut BTreeSet < u64 > , ) { visited . insert ( key ) ; component . insert ( key ) ; for value in adj . get ( & key ) . unwrap ( ) { if ! visited . contains ( value ) { dfs ( * value , adj , & mut visited , & mut component ) ; } } }
Do depth first search in the data items and group them together.
Do depth first search in the data items and group them together .
key
u64
adj
&BTreeMap<u64, BTreeSet<u64>>
visited
&mut BTreeSet<u64>
component
&mut BTreeSet<u64>
key
u64
adj
&BTreeMap<u64, BTreeSet<u64>>
visited
&mut BTreeSet<u64>
component
&mut BTreeSet<u64>