protected BallNode makeBallTree(TempNode node,int startidx,int endidx,int[] instList,int depth,final double rootRadius) throws Exception {
  BallNode ball=null;
  Instance pivot;
  if (m_MaxDepth < depth)   m_MaxDepth=depth;
  if (node.points.length > m_MaxInstancesInLeaf && (rootRadius == 0 ? false : node.radius / rootRadius >= m_MaxRelLeafRadius) && node.left != null && node.right != null) {
    ball=new BallNode(startidx,endidx,m_NumNodes,(pivot=BallNode.calcCentroidPivot(startidx,endidx,instList,m_Instances)),BallNode.calcRadius(startidx,endidx,instList,m_Instances,pivot,m_DistanceFunction));
    m_NumNodes+=1;
    ball.m_Left=makeBallTree(node.left,startidx,startidx + node.left.points.length - 1,instList,depth + 1,rootRadius);
    ball.m_Right=makeBallTree(node.right,startidx + node.left.points.length,endidx,instList,depth + 1,rootRadius);
  }
 else {
    ball=new BallNode(startidx,endidx,m_NumNodes,(pivot=BallNode.calcCentroidPivot(startidx,endidx,instList,m_Instances)),BallNode.calcRadius(startidx,endidx,instList,m_Instances,pivot,m_DistanceFunction));
    m_NumNodes+=1;
    m_NumLeaves++;
  }
  return ball;
}

protected BallNode makeBallTree ( TempNode node , int startidx , int endidx , int [ ] instList , int depth , final double rootRadius ) throws Exception { BallNode ball = null ; Instance pivot ; if ( m_MaxDepth < depth ) m_MaxDepth = depth ; if ( node . points . length > m_MaxInstancesInLeaf && ( rootRadius == 0 ? false : node . radius / rootRadius >= m_MaxRelLeafRadius ) && node . left != null && node . right != null ) { ball = new BallNode ( startidx , endidx , m_NumNodes , ( pivot = BallNode . calcCentroidPivot ( startidx , endidx , instList , m_Instances ) ) , BallNode . calcRadius ( startidx , endidx , instList , m_Instances , pivot , m_DistanceFunction ) ) ; m_NumNodes += 1 ; ball . m_Left = makeBallTree ( node . left , startidx , startidx + node . left . points . length - 1 , instList , depth + 1 , rootRadius ) ; ball . m_Right = makeBallTree ( node . right , startidx + node . left . points . length , endidx , instList , depth + 1 , rootRadius ) ; } else { ball = new BallNode ( startidx , endidx , m_NumNodes , ( pivot = BallNode . calcCentroidPivot ( startidx , endidx , instList , m_Instances ) ) , BallNode . calcRadius ( startidx , endidx , instList , m_Instances , pivot , m_DistanceFunction ) ) ; m_NumNodes += 1 ; m_NumLeaves ++ ; } return ball ; }
makes ball tree nodes of temp nodes that were used in the merging process .
