+++ /dev/null
-#include "muscle.h"\r
-#include "tree.h"\r
-\r
-/***\r
-Simple tree drawing algorithm.\r
-\r
-y coordinate of node is index in depth-first traversal.\r
-x coordinate is distance from root.\r
-***/\r
-\r
-static unsigned DistFromRoot(const Tree &tree, unsigned uNodeIndex)\r
- {\r
- const unsigned uRoot = tree.GetRootNodeIndex();\r
- unsigned uDist = 0;\r
- while (uNodeIndex != uRoot)\r
- {\r
- ++uDist;\r
- uNodeIndex = tree.GetParent(uNodeIndex);\r
- }\r
- return uDist;\r
- }\r
-\r
-static void DrawNode(const Tree &tree, unsigned uNodeIndex)\r
- {\r
- if (!tree.IsLeaf(uNodeIndex))\r
- DrawNode(tree, tree.GetLeft(uNodeIndex));\r
-\r
- unsigned uDist = DistFromRoot(tree, uNodeIndex);\r
- for (unsigned i = 0; i < 5*uDist; ++i)\r
- Log(" ");\r
- Log("%d\n", uNodeIndex);\r
-\r
- if (!tree.IsLeaf(uNodeIndex))\r
- DrawNode(tree, tree.GetRight(uNodeIndex));\r
- }\r
-\r
-void DrawTree(const Tree &tree)\r
- {\r
- unsigned uRoot = tree.GetRootNodeIndex();\r
- DrawNode(tree, uRoot);\r
- }\r