Number of vertices and edges
int n = 5 , m = 5 ; @ SuppressWarnings ( " unchecked " ) ArrayList < Pair > [ ] gr = new ArrayList [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { gr [ i ] = new ArrayList < Pair > ( ) ; }