I’m trying to upgrade to version 4.0, but I’ve come across a problem. I’m creating an instance of a network object and manually adding nodes and links to it (rather than just creating it from a document). Whenever I call PerformLayout(), the Nodes and Links collections are cleared.
More precisely, I’ve derived a class off of GoLayoutForceDirectedNetwork and am adding nodes by calling GoLayoutGenericNetwork.AddNode(N). I’m creating links by calling GayLayoutGenericNetwork.LinkNodes (N, N, null). In all cases, the type of N is GoLayoutForceDirectedNode. I’ve also derived a class off of GoLayoutForceDirected where I assign my derived network class to the Network property just after construction. Just before calling PerformLayout, I create a new GoDocument and assign it to GoLayout.Document.
Interesting, the Document assignment clears the Nodes and Links collections, so what I’m really doing is more like this:
var network = Network;
var doc = new GoDocument();
Document = doc;
Network = network;
I tried moving this back to the constructor of the derived layout class (so the document would be present when I called AddNode and LinkNodes), but the collections still get cleared. Plus having this code in the constructor is a bad idea since calling GoLayout.Document is a virtual member call in a constructor.
Any ideas as to why my collections are cleared when I call PeformLayout?