Layered layout on directed graph


Dear Support,
I am working on plotting a directed graph in Northwood GoDiagram. I want to know if there is any way to get the nodes in different layers of the layered diagram after performing layered layout on the goView. I want to get all the nodes in sequence from top layer till bottom layer in the layered layout. Is there any object in the layout object which can supply the above information?



After the PerformLayout… here’s how to get to the Layer info in the Network.

It isn’t sorted the way you want, though.

 public override void PerformLayout() {

    string msg = "";
        foreach (GoLayoutLayeredDigraphNode node in this.Network.Nodes)
          if (node.GoObject != null) {
          msg += getlabel(node) + ": ";
          msg += " layer: " + node.Layer.ToString();
          msg += " column: " + node.Column.ToString();
          msg += Environment.NewLine;


    private string getlabel(GoLayoutLayeredDigraphNode gn) {
      GoObject o = gn.GoObject;
      GoBasicNode n = o as GoBasicNode;
      if (n != null) return n.Text;
      GoNode n2 = o as GoNode;
      if (n2 != null) return n2.Text;
      return "unsupported node class";

node.GoObject can be null because LayeredDigraph creates “fake” nodes to fill in space. GoObject points back to your real diagram Nodes.


Dear Jake,
Thank you very much for the reply. I have implemented this code in my application, and it is working fine. Though the available information is not sorted, it serves the purpose in my application. I can sort this information.


Dear Jake,
Is it possible to use layered layout method without adding nodes in goView document and being layout that document? I just want the layer information of these nodes after layout. I do not want to create diagram on goView. If I create network or collection object, is there any way to use this layered layout method on these objects and get required information?
Thanks and regards,


Layout requires a GoDocument with GoNodes of some type and GoLinks.

There isn’t a requirement that there be a GoView associated with the GoDocument.


Thanks for the reply.
In my application, I want to create directed graph and find the layers of the nodes in it. I want to use this layer information after layout to do some other things in my application. I do not want to create goView as well. I just need to get layers of the directed graph. Is there any other method that can do same thing?


Do you already have the diagram created (and visible to the user), and you just want to do a layout to get layer info… without actually changing the layout the user is seeing?


I have specifically created the diagram (goview) to get the layer information of the directed graph (DG) as the layout works on document. The view is not visible to user. However, the purpose of creating goView was just to get the layer information of the DG.


OK… like I said, the GoDocument is required. If you aren’t viewing the diagram, I’m pretty sure you can get away without actually creating the GoView. But the cost of the GoView if it isn’t mapped to the screen is going to be very low, so it probably doesn’t matter that much either way.


Thank you.
Could you please tell me the name of algorithm implemented behind layered layout method? There are algorithms available to layout directed graphs, such as Sugiyama. Can I get the time complexity of the algorithm implemented in GoDiagram layered layout? Is it possible to view the code behind the method?


LayeredDigraphLayout uses a modified Sugiyama-style algorithm. No, I don’t have complexity numbers. Yes, we do sell source code licenses.