src/machinelearning/DecisionTree.java
private String graph() {
		StringBuilder result = new StringBuilder();
		LinkedList<Node> stack = new LinkedList<Node>();
		LinkedList<String> stackLabel = new LinkedList<String>();
		stack.addFirst(root);
	    result.append("digraph DecisionTree {\n");
		
		while (stack.size() > 0) {
			Node current = stack.remove();
			
			if (current.parent != null) {
				String parentlabel = stackLabel.remove();
			    result.append("N" + current.parent.id
			    		+ "->" + "N" + current.id +
			    		" [label=\"= " + parentlabel + "\"]\n");
			}
			
			if (current.isLeaf()) {
				result.append("N" + current.id +
						" [label=\"" + current.label + "\" " +
						"shape=box style=\"rounded,filled\"]\n");
			} else {
				result.append("N" + current.id +
						" [label=\"" + current.label + "\" " +
						"shape=box]\n");
				for (int i=1; i>=0; i--) {
					stack.addFirst(current.children.get(i));
					stackLabel.addFirst((i == 1)?"1":"0");
				}
			}
		}
		
		result.append("}\n");
		
		return result.toString();
	}
/**
	 * @return The decision tree as a string
	 */
@return The decision tree as a string
@return The decision tree as a string
private String graph() {
		StringBuilder result = new StringBuilder();
		LinkedList<Node> stack = new LinkedList<Node>();
		LinkedList<String> stackLabel = new LinkedList<String>();
		stack.addFirst(root);
	    result.append("digraph DecisionTree {\n");
		while (stack.size() > 0) {
			Node current = stack.remove();
			if (current.parent != null) {
				String parentlabel = stackLabel.remove();
			    result.append("N" + current.parent.id
			    		+ "->" + "N" + current.id +
			    		" [label=\"= " + parentlabel + "\"]\n");
			}
			if (current.isLeaf()) {
				result.append("N" + current.id +
						" [label=\"" + current.label + "\" " +
						"shape=box style=\"rounded,filled\"]\n");
			} else {
				result.append("N" + current.id +
						" [label=\"" + current.label + "\" " +
						"shape=box]\n");
				for (int i=1; i>=0; i--) {
					stack.addFirst(current.children.get(i));
					stackLabel.addFirst((i == 1)?"1":"0");
				}
			}
		}
		result.append("}\n");
		return result.toString();
	}
private String graph ( ) { StringBuilder result = new StringBuilder ( ) ; LinkedList < Node > stack = new LinkedList < Node > ( ) ; LinkedList < String > stackLabel = new LinkedList < String > ( ) ; stack . addFirst ( root ) ; result . append ( "digraph DecisionTree {\n" ) ; while ( stack . size ( ) > 0 ) { Node current = stack . remove ( ) ; if ( current . parent != null ) { String parentlabel = stackLabel . remove ( ) ; result . append ( "N" + current . parent . id + "->" + "N" + current . id + " [label=\"= " + parentlabel + "\"]\n" ) ; } if ( current . isLeaf ( ) ) { result . append ( "N" + current . id + " [label=\"" + current . label + "\" " + "shape=box style=\"rounded,filled\"]\n" ) ; } else { result . append ( "N" + current . id + " [label=\"" + current . label + "\" " + "shape=box]\n" ) ; for ( int i = 1 ; i >= 0 ; i -- ) { stack . addFirst ( current . children . get ( i ) ) ; stackLabel . addFirst ( ( i == 1 ) ? "1" : "0" ) ; } } } result . append ( "}\n" ) ; return result . toString ( ) ; }
@return The decision tree as a string
@return The decision tree as a string