private void computeWeights ( Node node ) { int wsum = 0 ; for ( Node child : node . children ) { computeWeights ( child ) ; wsum += child . weight ; } node . weight = Math . max ( 1 , wsum ) ; }
Recursively assign node weights .