iterating over the node set to count the number of nodes visited after making the graph directed and storing it in the variable count . If count / 2 == number of nodes - 1 , then increment count by 1.
int count = 0 ; for ( auto it = node . begin ( ) ; it != node . end ( ) ; ++ it ) count += Graph [ ( * it ) ] . size ( ) ; count /= 2 ; if ( count == node . size ( ) - 1 ) number_of_nodes ++ ; } } return number_of_nodes ; }