fn count_paths_part2(&self, start: &str, end: &str, verbose: bool) -> usize {
        let start = name_trans(start);
        let end = name_trans(end);
        let mut counter = PathCounter::with_capacity(self.adj.len(), verbose);
        let mut paths = HashSet::<String>::new(); // capacity: a lot
        counter.capacity = self.capacities(&start, &end);
        for node in self.adj.keys()
        {
            if node != &start && node != &end && counter.capacity[node].unwrap_or(0) == 1 {
                *counter.capacity.get_mut(node).unwrap().as_mut().unwrap() = 2;
                counter.counts.clear(); // XXX we could maybe save some memos...
                // XXX this probably counts many paths multiple times, need to de-dup
                counter.visit(self, &start, &end, |path| {
                    if verbose {
                        println!("** visiting {}", path);
                    }
                    paths.insert(path.0);
                });
                *counter.capacity.get_mut(node).unwrap().as_mut().unwrap() = 1;
            }
        }
        paths.len()
    }
// Count the number of paths where one lowercase node can be visited twice.
Count the number of paths where one lowercase node can be visited twice.
Count the number of paths where one lowercase node can be visited twice .
fn count_paths_part2(&self, start: &str, end: &str, verbose: bool) -> usize {
        let start = name_trans(start);
        let end = name_trans(end);
        let mut counter = PathCounter::with_capacity(self.adj.len(), verbose);
        let mut paths = HashSet::<String>::new(); // capacity: a lot
        counter.capacity = self.capacities(&start, &end);
        for node in self.adj.keys()
        {
            if node != &start && node != &end && counter.capacity[node].unwrap_or(0) == 1 {
                *counter.capacity.get_mut(node).unwrap().as_mut().unwrap() = 2;
                counter.counts.clear(); // XXX we could maybe save some memos...
                // XXX this probably counts many paths multiple times, need to de-dup
                counter.visit(self, &start, &end, |path| {
                    if verbose {
                        println!("** visiting {}", path);
                    }
                    paths.insert(path.0);
                });
                *counter.capacity.get_mut(node).unwrap().as_mut().unwrap() = 1;
            }
        }
        paths.len()
    }
fn count_paths_part2 ( & self , start : & str , end : & str , verbose : bool ) -> usize { let start = name_trans ( start ) ; let end = name_trans ( end ) ; let mut counter = PathCounter :: with_capacity ( self . adj . len ( ) , verbose ) ; let mut paths = HashSet :: < String > :: new ( ) ; // capacity: a lot counter . capacity = self . capacities ( & start , & end ) ; for node in self . adj . keys ( ) { if node != & start && node != & end && counter . capacity [ node ] . unwrap_or ( 0 ) == 1 { * counter . capacity . get_mut ( node ) . unwrap ( ) . as_mut ( ) . unwrap ( ) = 2 ; counter . counts . clear ( ) ; // XXX we could maybe save some memos... // XXX this probably counts many paths multiple times, need to de-dup counter . visit ( self , & start , & end , | path | { if verbose { println ! ( " " path ) ; } paths . insert ( path . 0 ) ; } ) ; * counter . capacity . get_mut ( node ) . unwrap ( ) . as_mut ( ) . unwrap ( ) = 1 ; } } paths . len ( ) }
Count the number of paths where one lowercase node can be visited twice.
Count the number of paths where one lowercase node can be visited twice .
&self
start
&str
end
&str
verbose
bool