Excluding Layers in GoLayoutForceDirected

If you have Links on two different layers and one of the layers is hidden, is it possibe for GoLayoutForceDirected to only layout the visible objects? It seems the Layout is tied to the View, but performed on the Document?
BTW - So far nice product!
Regards,
Mike

Actually, GoLayout is not tied to a GoView. It needs a GoDocument so that it can have a collection from which it can generate a GoLayoutNetwork if you don’t supply one, and so that it can perform updating more efficiently.
However, we have added a GoView property in 2.5, to provide support for asynchronous execution.
If you want to do a layout on a subset of the document, you need to customize the GoLayoutNetwork that it uses. For example, if you just have one layer that is visible and thus have just one layer that you want to lay out, assign the GoLayout.Network property to:
new GoLayoutNetwork(yourLayer)
or in 2.5:
new GoLayoutForceDirectedNetwork(yourLayer)
If you want to operate on a subset of the layers, create a GoLayout[ForceDirected]Network and call AddNodesAndLinksFromCollection on each layer. You can make finer-grained adjustments by calling AddNode or DeleteNode or LinkNodes or DeleteLink.

Not Much Success :(

<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

As a test I am using your example of WebWalker, which I am trying to use forced layout on.

In Webwalker, You place all the sites on default layer with Backward links on a second layer. You then build links between pages on the default link layer and layout.

Similar in my altered version, my nodes (goGeneralNode) are added to the Document (default layer) with links to a root node (links on an SecondLayer) – One to many (spoke and hub)

Additional relationships links are added between the spoke nodes on the default layer.

Now all my items are to ForcedDirected are on the Default layer. The links on the secondlayer should not be considered since hidden in the View.Document and are on another layer which isn’t added to the network. Problem: All nodes move based upon all the links

Example:

1 root node added to the default layer

20 leaf nodes added to the default layer

20 links are added from 1 root to the 20 leaf nodes on LinkLayer2

3 additional links are added to 3 leaf nodes on the default layer (should form a triangle)

All 20 nodes should be visible, and the 3 inter links – the 20 root links are hidden

The 17 leaf nodes and the 1 root should repel, and the three nodes with the links should pull together to a triangle.

Code

Dim MyNet As New GoLayoutForceDirectedNetwork()

MyNet.AddNodesAndLinksFromCollection(Doc.Layers.Default, True)

' MyNet.AddNodesAndLinksFromCollection(Doc.BackwardsLinksLayer , True)

MyNet.AddNodesAndLinksFromCollection(Doc.LinksLayer, True)

Dim MyLayout As New GoLayoutForceDirected()

MyLayout.MaxIterations = 2

MyLayout.Network = MyNet ' FYI (NODES=21,LINKS=3)

MyLayout.Document = myView.Document

MyLayout.PerformLayout()' FYI The nodes without links move as if BackwardsLinks are present

Thanks,

Mike

To be clear: The visibility of the objects in a GoView doesn’t matter to the auto-layout algorithms. It’s whether or not there is a corresponding object (node or link) in the GoLayoutNetwork that matters.
I just tried this quickly trying it both with and without the (separate) GoDocument.LinksLayer added to the GoLayoutForceDirectedNetwork. It worked the way you would expect. When I get a chance later I’ll try it with and without a third layer of links.
Did you confirm that those additional links really are in the BackwardsLinksLayer and not in the LinksLayer? I guess you made the LinksLayer not Visible, or else removed the LinksLayer from the GoView.Layers collection.

From the WebWalker sample app, Hide Backwards links - this does toggle the visability of the layer.
BTW this is the 2.5 beta I am playing with.

OK, I modified WebWalker too, and found that it was doing what I expected – only those links that got added to the Network had an effect constraining the positions of the connected nodes.
However, I notice in your code you limited MaxIterations to 2, which is a very small value. Try not setting that property, which defaults to a much larger value. Perhaps you are not seeing the results you expect because there haven’t been enough iterations to let the forces stabilize.

I’m getting it to work better now, it seems that if add the nodes to the document and only the links to a layer ill cause all the nodes to be layed out. If I seperate everything and put nodes on layer0 and my links on two other layers then I can layout layers 0 & 1 and 0 & 2.
Also
I’ve noticed differences on the ordering of the properties like

Dim MyNet As New Go.Layout.GoLayoutTreeNetwork(lay0)
MyNet.AddNodesAndLinksFromCollection(lay1, True)
Dim MyLayout As New Go.Layout.GoLayoutTree
MyLayout.Document = GoView1.Document
MyLayout.Network = MyNet
MyLayout.PerformLayout()
will error but

MyLayout.Network = MyNet
MyLayout.Document = GoView1.Document
MyLayout.PerformLayout()

Works fine. Apparently it .Network must be called before .Document (for the new tree layout).

I’ll keep learning - Thanks again for the help.
Regards,
Mike

Yes, the order of setting GoLayout.Document and GoLayout.Network matters, and is documented so. You should set .Document first, and then (optionally) .Network. Setting .Document is required in any case. Setting .Network is optional because GoLayout can create a default network for the document.
So I disagree with your conclusion – you need to set .Document first.