One more thing, regarding Subgraphs

I am using a GoLayoutLayeredDigraph layout to implement flow charts in my web application. I am populating the flow charts from XML source, and everything is working pretty well. I am trying to implement subgraphs in the transformation code that I have written. I have overridden the ConsumeAttributes subroutine for my transformation class like this:

Public Overrides Sub ConsumeAttributes(ByVal obj As Object)
    Dim n As FlowNode = GetNode(obj)
    Dim doc As GoDocument = CType(Me.Reader.RootObject, GoDocument)
    If StringAttr("subGraphID", "0") <> "0" Then
        Dim sg As GoSubGraph = doc.FindPart(1000000 + CInt(StringAttr("subGraphID", "0")))
        If sg IsNot Nothing Then
        End If
        If StringAttr("hasSubGraph", "False") = "True" Then
            Dim sg As New GoSubGraph()
            sg.PartID = 1000000 + CLng(StringAttr("id", "0"))
        End If
    End If

End Sub

And the XML source would look like this:

…and for one of the children to be added to the subgraph, the XML would look like:

So, if a node should have a subGraph added, the XML element has its “hasSubGraph” attribute set to ‘True’. I check for that in my transformation code. If it is ‘True’ then I add a subgraph to the node in question, giving the subgraph a PartID of 1000000 + the node’s PartID (id in the XML). Then when I encounter a node that has a subGraphID=“5136”, for example, I know to add it to the subgraph with the ID of 1005136.

These nodes appear in the flowchart but, they are all stacked on top of each other, and on top of the parent node (5136). All other nodes in the flowchart are layed-out correctly. I thought that, maybe, I should explicitly call “layoutChildren” for each subgraph that I have added but, that doesn’t seem to have an effect.

Any suggestions as to what I might try?

Thanks, as always.

Yes, it’s true you need to recursively do a layout of the child nodes and links of a subgraph, before you do the layout of the whole document. This is demonstrated in a couple of the demos and is shown in the GoLayout User Guide.

Part of the reason that layout doesn't automatically recurse through subgraphs is that you'll want to use different options, or even apply completely different algorithms, to the subgraphs. In this case it's even less natural, since it appears that your GoSubGraph's Parent is a FlowNode, rather than the subgraph being a top-level node or a child of another subgraph. The latter organization is much more common.
If GoDocument.MaintainsPartID is true, each instance of GoSubGraph (since it inherits from GoNode) will have its own unique PartID. It isn't clear to me why you bother.

Thanks for your response.

When you say “you need to recursively do a layout of the child nodes and links of a subgraph, before you do the layout of the whole document”, do you mean to simply call MySubGraph.layoutChildren? Or, do you mean that I need to assign a layout (somehow) to MySubGraph, set its parameters, etc., etc., and then call PerformLayout for the subgraph, as I am doing for my document as a whole?

I have been over the section in the UserGuide and I have looked through the examples over the past few days but, I am clearly missing something.

Thanks, as always, for any suggestions you can give.

Take a look at the LayoutSubGraphs method in Form1 of SubGraphApp.

Or better yet, look at the code on page 41 of the GoLayout User Guide.

Thanks. I am getting different results now. I still have a long way to go. But, this is progress.

Thanks again.