@Override public void graphTree(StringBuffer buff) { boolean first = true; for (Map.Entry<String, HNode> e : m_children.entrySet()) { HNode child = e.getValue(); String branch = e.getKey(); if (child != null) { String conditionForBranch = m_split.conditionForBranch(branch); if (first) { String testAttName = null; if (conditionForBranch.indexOf("<=") < 0) { testAttName = conditionForBranch.substring(0, conditionForBranch.indexOf("=")).trim(); } else { testAttName = conditionForBranch.substring(0, conditionForBranch.indexOf("<")).trim(); } first = false; buff.append("N" + m_nodeNum + " [label=\"" + testAttName + "\"]\n"); } int startIndex = 0; if (conditionForBranch.indexOf("<=") > 0) { startIndex = conditionForBranch.indexOf("<") - 1; } else if (conditionForBranch.indexOf("=") > 0) { startIndex = conditionForBranch.indexOf("=") - 1; } else { startIndex = conditionForBranch.indexOf(">") - 1; } conditionForBranch = conditionForBranch.substring(startIndex, conditionForBranch.length()).trim(); buff.append( "N" + m_nodeNum + "->" + "N" + child.m_nodeNum + "[label=\"" + conditionForBranch + "\"]\n") .append("\n"); } } for (Map.Entry<String, HNode> e : m_children.entrySet()) { HNode child = e.getValue(); if (child != null) { child.graphTree(buff); } } }
@Override protected int dumpTree(int depth, int leafCount, StringBuffer buff) { for (Map.Entry<String, HNode> e : m_children.entrySet()) { HNode child = e.getValue(); String branch = e.getKey(); if (child != null) { buff.append("\n"); for (int i = 0; i < depth; i++) { buff.append("| "); } buff.append(m_split.conditionForBranch(branch).trim()); buff.append(": "); leafCount = child.dumpTree(depth + 1, leafCount, buff); } } return leafCount; }