This is a fun problem, so I took a crack at it:
The only tricky part is was that you need to stash the previous layout
positions, so that when a new node enters, you can animate it from the
parent's previous position. However, at the same time, the parent is
repositioning because of the nature of the tidy tree layout!
> 3) Redraw only from the parent node downwards.
This isn't always possible with the Reingold-Tilford algorithm because
inserting a new child node can affect the layout of its parents and
other nodes in the graph. There are other tree layout algorithms where
only the new node (or only its siblings) would be affected, but these
layouts won't be as tidy. Regardless, it's always possible to do the
minimum amount of work given your layout in D3, by using the
enter/update/exit selections.
> Can I inject nodes into a parent node (does this mean I need to
> construct my own node objects ?) and re-evaluate the subtree.
You can inject nodes into your data, but by the nature of the layout
algorithm, you have to re-evaluate the entire tree. You could, of
course, write your own tree layout algorithm that supports incremental
updates more efficiently. But, depending on how many nodes you have in
your tree, and your desire to keep the appearance tidy, the existing
layout may be the best option.
Mike
I can see I was getting tied up in a procedural mindset and failing to pick up on how the links and nodes related.
regards
Steve