private Set<Integer> computeId2DataRec(int numberOfDataSets,Node v,Map<Integer,Integer[]> id2counts,Map<Integer,Set<Integer>> id2idsBelow,Map<Integer,NodeData> id2data){
  final int id=(Integer)v.getInfo();
  final Set<Integer> idsBelow=new HashSet<>();
  id2idsBelow.put(id,idsBelow);
  idsBelow.add(id);
  for (Edge e=v.getFirstOutEdge(); e != null; e=v.getNextOutEdge(e)) {
    Node w=e.getTarget();
    final Set<Integer> allBelow=computeId2DataRec(numberOfDataSets,w,id2counts,id2idsBelow,id2data);
    idsBelow.addAll(allBelow);
  }
  int[] assigned=new int[numberOfDataSets];
  int[] summarized=new int[numberOfDataSets];
  long total=0;
  final Integer[] counts=id2counts.get(id);
  if (counts != null) {
    int top=Math.min(assigned.length,counts.length);
    for (int i=0; i < top; i++) {
      if (counts[i] != null) {
        assigned[i]=counts[i];
        total+=counts[i];
      }
    }
  }
  for (  Integer below : id2idsBelow.get(id)) {
    Integer[] countBelow=id2counts.get(below);
    if (countBelow != null) {
      int top=Math.min(summarized.length,countBelow.length);
      for (int i=0; i < top; i++) {
        if (countBelow[i] != null) {
          summarized[i]+=countBelow[i];
          total+=countBelow[i];
        }
      }
    }
  }
  if (total > 0)   id2data.put(id,new NodeData(assigned,summarized));
  return idsBelow;
}

private Set < Integer > computeId2DataRec ( int numberOfDataSets , Node v , Map < Integer , Integer [ ] > id2counts , Map < Integer , Set < Integer > > id2idsBelow , Map < Integer , NodeData > id2data ) { final int id = ( Integer ) v . getInfo ( ) ; final Set < Integer > idsBelow = new HashSet < > ( ) ; id2idsBelow . put ( id , idsBelow ) ; idsBelow . add ( id ) ; for ( Edge e = v . getFirstOutEdge ( ) ; e != null ; e = v . getNextOutEdge ( e ) ) { Node w = e . getTarget ( ) ; final Set < Integer > allBelow = computeId2DataRec ( numberOfDataSets , w , id2counts , id2idsBelow , id2data ) ; idsBelow . addAll ( allBelow ) ; } int [ ] assigned = new int [ numberOfDataSets ] ; int [ ] summarized = new int [ numberOfDataSets ] ; long total = 0 ; final Integer [ ] counts = id2counts . get ( id ) ; if ( counts != null ) { int top = Math . min ( assigned . length , counts . length ) ; for ( int i = 0 ; i < top ; i ++ ) { if ( counts [ i ] != null ) { assigned [ i ] = counts [ i ] ; total += counts [ i ] ; } } } for ( Integer below : id2idsBelow . get ( id ) ) { Integer [ ] countBelow = id2counts . get ( below ) ; if ( countBelow != null ) { int top = Math . min ( summarized . length , countBelow . length ) ; for ( int i = 0 ; i < top ; i ++ ) { if ( countBelow [ i ] != null ) { summarized [ i ] += countBelow [ i ] ; total += countBelow [ i ] ; } } } } if ( total > 0 ) id2data . put ( id , new NodeData ( assigned , summarized ) ) ; return idsBelow ; }
recursively computes the classification - id 2 assigned and classification - id 2 summarized maps . use this when classification contains same leaves more than once
