adjacency graph for tree
int V = 8 ; Vector < Vector < Integer > > graph = new Vector < Vector < Integer > > ( ) ; for ( int i = 0 ; i < V + 1 ; i ++ ) graph . add ( new Vector < Integer > ( ) ) ; graph . get ( 0 ) . add ( 1 ) ; graph . get ( 0 ) . add ( 2 ) ; graph . get ( 1 ) . add ( 3 ) ; graph . get ( 1 ) . add ( 4 ) ; graph . get ( 1 ) . add ( 5 ) ; graph . get ( 2 ) . add ( 5 ) ; graph . get ( 2 ) . add ( 6 ) ; graph . get ( 6 ) . add ( 7 ) ;