This is primarily a question regarding the Force Directed layout, but I think it relates to all layouts.
I allow the user to build up a graph by adding new items to existing items (a node is selected, and the user then requests that related items are added to the graph - linking to the original node).
These graphs can get quite large, containing many nodes, and the users don’t like the general layout changing as they add in additional items (they have likely dragged items to a given place). To address this requirement, I have done the following:
- once items are added to the graph (after layout complete) the nodes are marked as being in a fixed location (using node.isLayoutPositioned = false).
- when adding new nodes to the graph (based on the user selecting an existing node and appending related nodes), I set the existing node to being layout positioned so that it can participate in the layout routine along with the new nodes that are being added.
- Once the layout pass is completed I translate the nodes that participated in the layout by an amount that move the existing selected node back to its original location.
This seems a bit cumbersome. Is there a more appropriate way to keep the existing graph shape, while still allowing the user to append items to the graph and having the new items appear in close proximity to the ‘root’ node that they selected?