private static double branchWeight ( Node node , Arborescence < Node > arborescence , Map < Node , Set < Node > > edgesParentToChild , Map < Node , Map < Node , Fragment > > edgeFragmentChildToParent ) { Double nodeWeight = node . getNodeWeight ( ) ; if ( nodeWeight == null ) { nodeWeight = getEdgeFragmentCost ( node , arborescence , edgeFragmentChildToParent ) + nodeFragmentWeight ( node ) ; node . setNodeWeight ( nodeWeight ) ; } Double branchWeight = node . getBranchWeight ( ) ; if ( branchWeight == null ) { final double [ ] weight = { nodeWeight } ; if ( edgesParentToChild . containsKey ( node ) ) { edgesParentToChild . get ( node ) . forEach ( child -> weight [ 0 ] += branchWeight ( child , arborescence , edgesParentToChild , edgeFragmentChildToParent ) ) ; } branchWeight = weight [ 0 ] ; node . setBranchWeight ( branchWeight ) ; } return branchWeight ; }
recursively compute the weight of a branch