block by nitaku 7910706

Random tree

Full Screen

This example generates and visualizes a random tree. It uses a recursive algorithm similar to the simplest one I found in a survey about random trees used in genetic programming (Luke 2001). Hit reload to generate a different tree.

The generated tree has a maximum depth of 10, and for each node branches with a probability of 0.5 yielding at most 6 children.

Leaf nodes (depicted in gray) are placed after internal nodes (in white). The blue label shows an internal node’s prefix, i.e. the path from the root node to it.

The implementation is based on this example by Mike Bostock, and customizes d3.js’s tree layout to fit my taste.

index.js

index.html

index.coffee

index.css

index.sass