Construct the graph
for ( int i = 0 ; i < edges . size ( ) ; i ++ ) { adj [ edges [ i ] . first ] . push_back ( edges [ i ] . second ) ; adj [ edges [ i ] . second ] . push_back ( edges [ i ] . first ) ; }