/** * Recursively build a string representation of the Cobweb tree * * @param depth depth of this node in the tree * @param text holds the string representation */ protected void dumpTree(int depth, StringBuffer text) { if (depth == 0) { determineNumberOfClusters(); } if (m_children == null) { text.append("\n"); for (int j = 0; j < depth; j++) { text.append("| "); } text.append("leaf " + m_clusterNum + " [" + m_clusterInstances.numInstances() + "]"); } else { for (int i = 0; i < m_children.size(); i++) { text.append("\n"); for (int j = 0; j < depth; j++) { text.append("| "); } text.append("node " + m_clusterNum + " [" + m_clusterInstances.numInstances() + "]"); m_children.get(i).dumpTree(depth + 1, text); } } }
/** * Recursively build a string representation of the Cobweb tree * * @param depth depth of this node in the tree * @param text holds the string representation */ protected void dumpTree(int depth, StringBuffer text) { if (depth == 0) { determineNumberOfClusters(); } if (m_children == null) { text.append("\n"); for (int j = 0; j < depth; j++) { text.append("| "); } text.append("leaf " + m_clusterNum + " [" + m_clusterInstances.numInstances() + "]"); } else { for (int i = 0; i < m_children.size(); i++) { text.append("\n"); for (int j = 0; j < depth; j++) { text.append("| "); } text.append("node " + m_clusterNum + " [" + m_clusterInstances.numInstances() + "]"); m_children.get(i).dumpTree(depth + 1, text); } } }
/** * Returns a description of the clusterer as a string. * * @return a string describing the clusterer. */ @Override public String toString() { StringBuffer text = new StringBuffer(); if (m_cobwebTree == null) { return "Cobweb hasn't been built yet!"; } else { m_cobwebTree.dumpTree(0, text); return "Number of merges: " + m_numberMerges + "\nNumber of splits: " + m_numberSplits + "\nNumber of clusters: " + numberOfClusters() + "\n" + text.toString() + "\n\n"; } }
/** * Returns a description of the clusterer as a string. * * @return a string describing the clusterer. */ @Override public String toString() { StringBuffer text = new StringBuffer(); if (m_cobwebTree == null) { return "Cobweb hasn't been built yet!"; } else { m_cobwebTree.dumpTree(0, text); return "Number of merges: " + m_numberMerges + "\nNumber of splits: " + m_numberSplits + "\nNumber of clusters: " + numberOfClusters() + "\n" + text.toString() + "\n\n"; } }