Autolayout on Subgraphs


#1

I’m trying to auto-layout a subgraph, and all the children are in a straight line. I noticed that in this case the links should be added to the subgraph not the linkslayer. So now I create the node, create the link, then add it and the newly created node to the subgraph. After the nodes are created and added to the subgraph I auto-layout the graph and the nodes are still in a straight line. If you have any suggestions that would be great.
Thanks,
Jessica


#2

Did you copy the code from the SubGraphApp sample, or from the documentation?


#3

From the documentation! Maybe I’ll check out the SubGraphApp now. I’m guessing you’re referring to the layout graph code?


#4

Okay I just tried the LayoutSubGraphs function from SubGraphApp and I get the same result.


#5

So are you sure that all of the nodes and links of the subgraph are being included in the GoLayoutNetwork that is being laid out? You mentioned that the links between nodes in the subgraph should be added to the subgraph, so I assumed you did this correctly, but since you aren’t getting the right results, I’m wondering.
Note the GoSubGraph.ReparentToCommonSubGraph method (or the other method which calls that method for all links in a collection).


#6

These are the functions I’m using to layout my graphs.
Before this I create nodes, then the links, after I create the links I add both the node and link to the subgraph and add the
subgraph to the goview.document. I call the layoutgraph with goview.Document.

public void LayoutGraph(GoDocument doc)
{
try
{
GoLayoutLayeredDigraph layout = new GoLayoutLayeredDigraph();
layout.Document = doc;

LayoutGraph2(doc, layout);
}
catch(Exception ex)
{
throw ex;
}
}
private void LayoutGraph2(IGoCollection coll, GoLayout layout)
{
try
{
foreach (GoObject obj in coll)
{
GoSubGraph sg = obj as GoSubGraph;
if (sg != null)
{
LayoutGraph2(sg, layout);
}
}

layout.Network = new GoLayoutNetwork(coll);
layout.PerformLayout();
}
catch(Exception ex)
{
throw ex;
}
}
So to answer your question, i think I’m adding all the links are being added to the network, but maybe you can tell me differently.
Thanks!


#7

If you debug this, do you find that all expected links are in fact added to the correct GoLayoutNetwork, as children of the appropriate GoSubGraph?


#8

Oh one more thing! I meant to tell you right now I’m testing this with one parent and 25 children. I don’t know if that matters or not. They are not literally in a perfect straight line on top of one another, but they are being displayed straight down, basically overlapping one another still. Sorry for all the confusion.
Thanks!


#9

I checked and all the links and nodes are in the correct subgraph. I really don’t know what to try now. I seem to have double links also. I have the regular links coming from teh parent to the nodes, then another set of links from an invisible parent WEIRD. Obviously, I’ve done something very wrong, but can’t figure it out!


#10

Try debugging the simplest possible case, and then make it very slightly more complicated, until you find what’s wrong.