Drawing a Tree Structure

@Robert_Weaver - regarding the time to draw, I’ve been working with trees with millions of nodes. Several points to note:

  • it is essential to check for looping within the tree and stop that. If the code is recursive it results in a stack overflow; if it is iterative it gets stuck in an infinite loop.

  • use iteration (faster), and avoid recursion (slower); you can see where I did that in the example;

  • when traversing a big tree consider imposing a limit on the depth drawn (the number of levels), and let the user explore a sub-branch.

Drawing to the canvas as a bitmap works pretty well provided everything uses right-angles. But I wanted to draw circular trees, with text following the links on any angle. Drawing with 2D objects works, but with big trees there comes a point where it is slower than a bitmap.