Driver code
public static void main ( String [ ] args ) { int N = 5 ; ArrayList < Pair > edges = new ArrayList < > ( ) ; for ( int i = 0 ; i < MAX ; i ++ ) { adj [ i ] = new ArrayList < > ( ) ; } edges . add ( new Pair ( 5 , 1 ) ) ; edges . add ( new Pair ( 5 , 2 ) ) ; edges . add ( new Pair ( 1 , 2 ) ) ; edges . add ( new Pair ( 2 , 3 ) ) ; edges . add ( new Pair ( 2 , 4 ) ) ; System . out . println ( minNodetoRemove ( N , edges ) ) ; } }