Skip to content

cvzi/py_treedraw

Repository files navigation

treedraw.py

Example screenshot with pygame

This module implements a layout algorithm for a tree. Each node in the tree has a layout property that contains an x and y coordinate.

The layout is calculated by calling the method "walker(distance)".

The distance property indicated the distance between nodes on the same level. If the tree is build up using the addChild/removeChild methods, the layout will be calculated in linear time O(n).

The algorithm is a python implemenation of this publication "Improving Walker's Algorithm to Run in Linear Time" by Christoph Buchheim, Michael Jünger, Sebastian Leipert.

Tested with Python 2.6, 2.7, 3.3, 3.4, 3.5, 3.6 and 3.7

The example code (example.py) requires pygame for the graphical interface.

Build Status Codacy Badge Coverage Status