GoDigram for .NET Framework and .NET Core
Northwoods.Go.Layout Namespace / GoLayoutLayeredDigraph Class
Members Example
In This Topic
    GoLayoutLayeredDigraph Class
    In This Topic
    GoLayoutLayeredDigraph provides an auto-layout for layered drawings of directed graphs.
    Syntax
    [DesignerCategory("Component")]
    [Serializable()]
    public class GoLayoutLayeredDigraph : GoLayout 
    Remarks
    The method uses a hierarchical approach for creating drawings of digraphs with nodes arranged in layers. The layout algorithm consists of four-major steps: Cycle Removal, Layer Assignment, Crossing Reduction, and Straightening and Packing.
    Example
    Typical usage: To lay out only a portion of a document, you will need to construct a GoLayoutLayeredDigraphNetwork, initialize it with just the nodes and links that you want to use, and set the Network property. Read the GoLayout User Guide for more details.
    GoDocument doc = goView1.Document;
    doc.StartTransaction();
    GoLayoutLayeredDigraph layout = new GoLayoutLayeredDigraph();
    layout.Document = doc;
    layout.DirectionOption = GoLayoutDirection.Down;
    layout.ColumnSpacing = 15;
    layout.LayerSpacing = 10;
    // ...maybe set other properties...
    layout.PerformLayout();
    doc.FinishTransaction("layout");
    GoDocument doc = goView1.Document;
    doc.StartTransaction();
    GoLayoutLayeredDigraph layout = new GoLayoutLayeredDigraph();
    layout.Document = doc;
    layout.Network = layout.CreateNetwork();
    // if you want to start off with the network representing the complete document,
    // and then remove the nodes (or links) that you don't want:
    layout.Network.AddNodesAndLinksFromCollection(doc, true);
    foreach (GoObject obj in doc) {
      if (...obj is a node that you want to exclude from the layout...) {
        layout.Network.DeleteNode(obj);  // there is also a DeleteLink method
      }
    }
    layout.DirectionOption = GoLayoutDirection.Down;
    layout.ColumnSpacing = 15;
    layout.LayerSpacing = 10;
    // ...maybe set other properties...
    layout.PerformLayout();
    doc.FinishTransaction("layout");
    See Also