Originally posted by Jasiek Motyka:
To delete a node from my application code I am using a reference to its
controller
A controller should only be responsible for interpreting user gestures. The actual deleting should happen in the model. If some of your business needs to delete a node, it shouldn't use a controller to do so. In fact, it shouldn't even know about the existence of controllers.
from which I can retrieve only edge models. But to delete the edges
I must have references to their controllers too!
I think you misunderstand how MVC is supposed to work.
If a user deletes a node, the controller should simply tell the model to delete that one node. It is then the responsibility of the model to find out about the edges that need to be deleted, too - as this is business logic, not presentation logic. That is, what edges will be deleted doesn't depend on how the edges are presented (view) or how the user interacts with them (controller).
Once the model deletes an edge in the model, the model notifies all of its observers that the edge got deleted. One of the observers will be the associated view, which then takes appropriate action to update the UI.
Does that help?