Many, many Nodes and performance

Hi,
I have a problem with many, many nodes. At the moment I have a NodeSource that contains 15427 Nodes and the performance is really, really bad. Even the load is over over 1 minute.
These 15427 have a property called visible and indeed there are only < 350 nodes which are visible at one time. So I had the idea to have a collection of all nodes and filter this collection for visible nodes only to make a new nodesource for the diagram. If I just load the 15427 nodes in a standalone ObservableCollection it takes only 2.7 seconds (of cause - because not wpf-control/node is created).
But then I need something like OnNodeAdded and OnNodeRemoved to manage my “all nodes collection” in the background (this should work with create by dragging and create by paste).

Is there a tool or event I can use?

Do all of your node data objects have location information in them? In other words, do you need to perform a layout before you can decide which of those ~350 nodes should be shown and where?

If so, I think you want to implement virtualization – only create those Nodes whose bounds do not intersect with the Diagram’s viewport or that have connected Links that intersect with the viewport. See the Virtualizing sample in GoWpfDemo, although that sample makes the additional assumption that a simple tree layout of the model data is required and can be performed before creating any actual Nodes and Links.

Virtualization depends on a DiagramPanel.ViewportBoundsChanged listener to notice when the viewport has changed and thus create any nodes or links that might be visible, and eventually to remove any nodes or links that are no longer needed. This greatly reduces the overhead needed to show the viewport. But it requires not showing a lot of nodes, so a ZoomToFit command or an Overview won’t help at all. And there is overhead in virtualization when scrolling or zooming.

Hi Walter,
all 15427 node share the same viewport. There are no nodes that are “outside” of the diagram. Just the greater part of the nodes is not visible.

So are you saying that all of the Nodes have bounds that are within the viewport? But most of them are not Visible?

If so, then something like your original idea is good – just make sure that your model’s NodesSource only holds “visible” node data, and that its LinksSource only holds link data when both connected node data are “visible”.