Add edges to the Vector along with the values of the node
for ( int i = 0 ; i < n ; i ++ ) { g . get ( u [ i ] ) . add ( new pair ( val [ v [ i ] ] , v [ i ] ) ) ; g . get ( v [ i ] ) . add ( new pair ( val [ u [ i ] ] , u [ i ] ) ) ; }