private int getMaximumLeafSize(Tree tree, int max) {
   if (tree.isLeaf()) {
     return Math.max(max, tree.getFrequencySum());
   } else {
     Iterator<Edge> e = tree.childIterator();
     int maximum = max;
     while (e.hasNext()) {
       Edge edge = e.next();
       Tree child = edge.getChild();
       maximum = Math.max(maximum, getMaximumLeafSize(child, maximum));
     }
     return maximum;
   }
 }
  private void addTree(
      DirectedOrderedSparseMultigraph<String, String> treeGraph, Tree node, String parentName) {
    Iterator<Edge> e = node.childIterator();
    double edgeWeightSum = 0.0d;
    while (e.hasNext()) {
      Edge edge = e.next();
      Tree child = edge.getChild();
      edgeWeightSum += child.getSubtreeFrequencySum();
    }

    e = node.childIterator();
    while (e.hasNext()) {
      Edge edge = e.next();
      Tree child = edge.getChild();
      SplitCondition condition = edge.getCondition();
      String childName = vertexFactory.create();
      String edgeName = edgeFactory.create();
      vertexMap.put(childName, child);
      edgeMap.put(edgeName, condition);
      edgeStrengthMap.put(edgeName, child.getSubtreeFrequencySum() / edgeWeightSum);
      treeGraph.addEdge(edgeName, parentName, childName);
      addTree(treeGraph, child, childName);
    }
  }
 @Override
 public String getVertexName(String object) {
   Tree node = vertexMap.get(object);
   String name = "";
   if (node != null) {
     if (node.isLeaf()) {
       name = node.getLabel();
     } else {
       Iterator<Edge> e = node.childIterator();
       while (e.hasNext()) {
         SplitCondition condition = e.next().getCondition();
         name = condition.getAttributeName();
         break;
       }
     }
   }
   return name;
 }