Vector to store nodes directly connected to ith node along with their values
Vector < Vector < pair > > g = new Vector < Vector < pair > > ( ) ; for ( int i = 0 ; i < V ; i ++ ) g . add ( new Vector < pair > ( ) ) ;