I’m using a GraphLinksModel with instances of GraphLinksModelNodeData. Are the node keys considered to be mutable or immutable? That is, I have some scenarios where an external tool transforms one node into another. This transform can include an identity change which would necessitate changing the value of the GraphLinksModelNodeData.Key property. Will this work or does the model get thrown off by this identity change? If the latter, I assume I would just remove the first node, copy it’s relevant display properties to a new node, and then add the new node.
Are you talking about the values that are of type NodeKey (the generic type parameter)?
As long as the “value” stays the same, you can modify those objects.
The “value” is determined by its maintaining identity in a Dictionary<NodeKey, …>
It is also possible to modify the key value of a particular node data object.
For node data objects that implement INotifyPropertyChanged, the model will detect a change to the property value that represents the “key” and will update its internal data structures accordingly.
For less capable node data objects, you will need to call model.DoNodeKeyChanged so that the model learns about the change to that important property value.
But note that just because a node data object has gotten a new key value does not mean that any references using the old key are updated.
Whether or not any such references (say from a link data object) should be modified to use the new key value depends entirely on the semantics of the operation that changed the node data key value.
This is a bit subtle, but I hope I explained myself clearly.
I think it’s clear. I am indeed talking about values that are of type NodeKey. I assume that the Northwoods GraphLinksModelNodeData class raises a PropertyChanged event when its key value is updated thus informing the model of the change.
Can you be more specific about references that use the old key? It sounds like other nodes’s FromKeys/ToKeys properties might still point to the old key. (But that doesn’t make a whole lot of sense to me if the model was properly informed of the key change.) I’m just trying to work out where old values of the keys might still be used so I could take an appropriate action.
Say you have a node data with .Key == “A” and a link data with .From == “A”.
Clearly you would expect a Link in the Diagram to come from Node “A”.
If you modify that node data .Key = “A2”, the link data .From property still has the value “A”.
So the Link will no longer be coming from the Node “A2”.
You need to decide whether to modify the link data .From property to refer to “A2”, or to add a new node data with .Key == “A”, or to delete the link data, or to do nothing if you are supporting partly or completely disconnected links, or to do something completely different.