title: Algorithm for efficiently drawing trees?
body: <p>I need to draw a corporate structure tree (sort-of like a family tree) in C#. All the ancillary code is there. It is colored, interactive, and fancy. The only trouble is the algorithm that actually decides where to put each node is giving me a lot of grief.</p>
  
  <p>For the moment, boxes are 100x50 in size, and I have a class called <code>StaffNode</code> which represents a staff member at a particular x,y co-ordinate.</p>
  
  <p>The algorithm just needs to create a <code>List&lt;StaffNode&gt;</code> with the appropriate x's and y's.</p>
  
  <p>This is incredibly tricky.</p>
  
  <p>Basically the algorithm is recursive along the corporate structure, so left->right, then top->down along the tree. Obviously it is bad if two nodes are on top of one another.</p>
  
  <p>I can think of a few algorithms that might produce something like this:</p>
  
  <pre><code>          *
      o         O
  o o o o o     O
  o         O O O O O
                  O
  </code></pre>
  
  <p>Whereas something like this would be better, since the tree is very large and space is very limited:</p>
  
  <pre><code>       *
      o     O
  o o o o o O
  o     O O O O O
              O
  </code></pre>
  
  <p>Have any of you had to draw a tree like this before? If you have I'm sure you've come across the many hurdles I've got. Any tips? So far I've spent an entire day on it.</p>