5 Simple tree drawing algorithm.
\r
7 y coordinate of node is index in depth-first traversal.
\r
8 x coordinate is distance from root.
\r
11 static unsigned DistFromRoot(const Tree &tree, unsigned uNodeIndex)
\r
13 const unsigned uRoot = tree.GetRootNodeIndex();
\r
15 while (uNodeIndex != uRoot)
\r
18 uNodeIndex = tree.GetParent(uNodeIndex);
\r
23 static void DrawNode(const Tree &tree, unsigned uNodeIndex)
\r
25 if (!tree.IsLeaf(uNodeIndex))
\r
26 DrawNode(tree, tree.GetLeft(uNodeIndex));
\r
28 unsigned uDist = DistFromRoot(tree, uNodeIndex);
\r
29 for (unsigned i = 0; i < 5*uDist; ++i)
\r
31 Log("%d\n", uNodeIndex);
\r
33 if (!tree.IsLeaf(uNodeIndex))
\r
34 DrawNode(tree, tree.GetRight(uNodeIndex));
\r
37 void DrawTree(const Tree &tree)
\r
39 unsigned uRoot = tree.GetRootNodeIndex();
\r
40 DrawNode(tree, uRoot);
\r