fill adjacency matrix with - 1 to indicate no connections
for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { tree [ i ] [ j ] = - 1 ; } } int n = 11 ; for ( int i = 0 ; i < edge . length ; i ++ ) { edge [ i ] = new Edge ( 0 , 0 ) ; } for ( int i = 0 ; i < node . length ; i ++ ) { node [ i ] = new treeNode ( ) ; }