private int init(
				final Tree<V, ?> tree,
				final String parentLabel,
				final int index
			) {
				int idx = index;
				final CharSequence value = _mapper.apply(tree.value());
				final String label = String.format("node_%03d", idx);
				_labels.put(label, value);

				if (parentLabel != null) {
					_edges.add(parentLabel + " -> " + label);
				}
				for (int i = 0; i < tree.childCount(); ++i) {
					final Tree<V, ?> child = tree.childAt(i);
					idx = init(child, label, idx + 1);
				}
				return idx;
			}
This formatter converts a tree to the .dot representation.
jenetics.ext/src/main/java/io/jenetics/ext/util/TreeFormatter.java