问题
I need to work on drawing a hierarchical tree structure (HV-Drawing – Binary Tree) with orthogonal lines(straight rectangular connecting lines) between root and children ( like the following: http://lab.kapit.fr/display/visualizationlayouts/Hierarchical+Tree+layout ). I want to know if there are any open source examples of the algorithm of drawing trees like that so that I can implement the same algorithm in actionscript. Thanks Palash
回答1:
I did a C# version and put the code up on CodeProject. It's at:
http://www.codeproject.com/KB/WPF/LayeredTreeDraw.aspx
There's a generic part which gives the positions of all the nodes and a WPF specific implementation which actually draws everything using either straight lines or the orthogonal lines you're looking for.
回答2:
Here is my Python 3 realization: GitLab (this is internal project, GitLab registration required).
The program consists of only one file, so the installation is very simple (clone the repository and run hv-drawing.py
with necessary arguments).
Also the repository contents some examples of graphs for drawing.
The code is well-commented, so you can learn the algorithm on its realization.
来源:https://stackoverflow.com/questions/2897575/drawing-hierarchical-tree-with-orthogonal-lines-hv-drawing-binary-tree