private void calculateIntervals(){
  int nodeCount=tree.getNodeCount();
  times=new double[nodeCount];
  int[] childCounts=new int[nodeCount];
  collectTimes(tree,times,childCounts);
  indices=new int[nodeCount];
  HeapSort.sort(times,indices);
  if (intervals == null || intervals.length != nodeCount) {
    intervals=new double[nodeCount];
    lineageCounts=new int[nodeCount];
    lineagesAdded=new List[nodeCount];
    lineagesRemoved=new List[nodeCount];
    lineages=new List[nodeCount];
  }
  double start=times[indices[0]];
  int numLines=0;
  int nodeNo=0;
  intervalCount=0;
  while (nodeNo < nodeCount) {
    int lineagesRemoved=0;
    int lineagesAdded=0;
    double finish=times[indices[nodeNo]];
    double next;
    do {
      final int childIndex=indices[nodeNo];
      final int childCount=childCounts[childIndex];
      nodeNo+=1;
      if (childCount == 0) {
        addLineage(intervalCount,tree.getNode(childIndex));
        lineagesAdded+=1;
      }
 else {
        lineagesRemoved+=(childCount - 1);
        final NodeRef parent=tree.getNode(childIndex);
        for (int j=0; j < childCount; j++) {
          NodeRef child=tree.getChild(parent,j);
          removeLineage(intervalCount,child);
        }
        addLineage(intervalCount,parent);
        if (multifurcationLimit == 0.0) {
          break;
        }
      }
      if (nodeNo < nodeCount) {
        next=times[indices[nodeNo]];
      }
 else       break;
    }
 while (Math.abs(next - finish) <= multifurcationLimit);
    if (lineagesAdded > 0) {
      if (intervalCount > 0 || ((finish - start) > multifurcationLimit)) {
        intervals[intervalCount]=finish - start;
        lineageCounts[intervalCount]=numLines;
        intervalCount+=1;
      }
      start=finish;
    }
    numLines+=lineagesAdded;
    if (lineagesRemoved > 0) {
      intervals[intervalCount]=finish - start;
      lineageCounts[intervalCount]=numLines;
      intervalCount+=1;
      start=finish;
    }
    numLines-=lineagesRemoved;
  }
  intervalsKnown=true;
}

private void calculateIntervals ( ) { int nodeCount = tree . getNodeCount ( ) ; times = new double [ nodeCount ] ; int [ ] childCounts = new int [ nodeCount ] ; collectTimes ( tree , times , childCounts ) ; indices = new int [ nodeCount ] ; HeapSort . sort ( times , indices ) ; if ( intervals == null || intervals . length != nodeCount ) { intervals = new double [ nodeCount ] ; lineageCounts = new int [ nodeCount ] ; lineagesAdded = new List [ nodeCount ] ; lineagesRemoved = new List [ nodeCount ] ; lineages = new List [ nodeCount ] ; } double start = times [ indices [ 0 ] ] ; int numLines = 0 ; int nodeNo = 0 ; intervalCount = 0 ; while ( nodeNo < nodeCount ) { int lineagesRemoved = 0 ; int lineagesAdded = 0 ; double finish = times [ indices [ nodeNo ] ] ; double next ; do { final int childIndex = indices [ nodeNo ] ; final int childCount = childCounts [ childIndex ] ; nodeNo += 1 ; if ( childCount == 0 ) { addLineage ( intervalCount , tree . getNode ( childIndex ) ) ; lineagesAdded += 1 ; } else { lineagesRemoved += ( childCount - 1 ) ; final NodeRef parent = tree . getNode ( childIndex ) ; for ( int j = 0 ; j < childCount ; j ++ ) { NodeRef child = tree . getChild ( parent , j ) ; removeLineage ( intervalCount , child ) ; } addLineage ( intervalCount , parent ) ; if ( multifurcationLimit == 0.0 ) { break ; } } if ( nodeNo < nodeCount ) { next = times [ indices [ nodeNo ] ] ; } else break ; } while ( Math . abs ( next - finish ) <= multifurcationLimit ) ; if ( lineagesAdded > 0 ) { if ( intervalCount > 0 || ( ( finish - start ) > multifurcationLimit ) ) { intervals [ intervalCount ] = finish - start ; lineageCounts [ intervalCount ] = numLines ; intervalCount += 1 ; } start = finish ; } numLines += lineagesAdded ; if ( lineagesRemoved > 0 ) { intervals [ intervalCount ] = finish - start ; lineageCounts [ intervalCount ] = numLines ; intervalCount += 1 ; start = finish ; } numLines -= lineagesRemoved ; } intervalsKnown = true ; }
recalculates all the intervals for the given tree .
