Layout a few nodes added to the diagram

Hi Walter,

1) How do I keep all the nodes frozen in place and just implement a layout on just a few nodes added to the diagram that are linked to existing nodes on the diagram?
2) Is there a good MVVM way to do that by binding to the GraphLinksModelNodeData?
  1. For ForceDirectedLayout you can set ForceDirectedVertex.IsFixed to true for those nodes you don’t want the layout to move.

For other layouts there isn’t any easy way to do that and have the fixed nodes affect the layout. That’s because adding a node or even changing the size of a node might affect the locations of all of the other nodes.

But for TreeLayout if you have added some children to a parent node, you could create a TreeNetwork consisting of the parent node and all of its children links and children nodes, and just perform the layout on that with TreeLayout.Arrangement=“FixedRoots”. But there could easily be some overlap of the sub-tree arrangement with other parts of the tree, if there wasn’t room.

  1. I’m sorry, but I don’t understand your question: A “good MVVM way to do” what? Unless you’re still talking about partial layouts, which has nothing to do with MVVM design.

You might want to search this forum for posts about MVVM.

Thanks Walter,

I guess this pretty much answers the question. I guess I should have been more specific about MVVM way to do this. I was thinking it would be good if I could bind the panel to something that allowed me to freeze the node during layout, e.g. IsLayoutFrozen, so that I could set the node in the model and bind it in the NodePanel. But it appears Layout doesn't quite work that way.
I like the two ideas you proposed. I'll give them a try.

Yes, since the non-trivial layouts operate on separate networks of vertexes and edges, there wasn’t any easy way to use data-binding to set up those vertexes, which are usually created temporarily during the layout.

That’s particularly true for vertexes and edges that don’t have any corresponding Node or Link. That happens when one adds dummy “nodes” or dummy “links” that are only used for influencing the layout.

The only thing you can easily data-bind is go:Part.LayoutId to “None” if you don’t want that Part to participate in the layout at all.