Construct the graph
for ( var i = 0 ; i < edges . length ; i ++ ) { ( adj [ ( edges [ i ] ) . first ] ) . push ( ( edges [ i ] ) . second ) ; ( adj [ ( edges [ i ] ) . second ] ) . push ( ( edges [ i ] ) . first ) ; }