All examples By author By category About

nitaku

Tangled tree II

An improved layout for tangled trees. With respect to the first example, which only constrained the layout to always produce downward links, this one also ensures that nodes at the same depth are keep aligned.

As in this quite old example, we used the maximum distance from a node to a root to introduce the concept of depth (remember that a tangled tree structure is not actually a tree). Longest path algorithms are not so common, so we relied on a technique based on topological sorting. A simple JS snippet by Shinout is used to perform the topological sorting.