Calling GoLayout multiple times


  • I am using a Text Node with a Diamond shape and the text node has 4 ports(a conditional)
  • From the right port of the conditional I have a link to another node and from the bottom port of the conditional I have a link to a third node. Nothing is linked to the left or top ports of the conditional.
  • I also have a link which goes from the bottom of the node to the right of the conditional to the top port of the node on the bottom of the conditional. (I need to represent an AND condition)
  • What is happening is that if I call the PerformLayout function a few times in a row, the node on the right moves further right with each call to the PerformLayout function.
Why is that happening.

I tried many different things, I tried calling the ComputeRoute() and CalculateStroke but no result.

I need to be able to call Perform Layout more than one time.

The funny thing is that if I remove the link going form the bottom of the node to the right of the conditional to the top of the node at the bottom of the conditional , everything works well and PerformLayout() renders the same result no matter how many times I call it.

Thanks very much.


Can you reproduce that situation with the Flowgrammer sample?

I tried that but I need to change too much of teh code.

However what I did is a very simple application and was able to reproduce the condition.

Below is the code of my simple api.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Northwoods.Go;
using Northwoods.Go.Layout;

namespace WindowsApplication1
    public partial class Form1 : Form
        GoLayoutLayeredDigraph layout = new GoLayoutLayeredDigraph(); 

        public Form1()
            layout.Document = goView1.Document;
            goView1.Dock = DockStyle.Fill;
            GoShape s = new GoDiamond();
            GoShape s1 = new GoRoundedRectangle();
            GoShape s2 = new GoRectangle();

            GoTextNode x = new GoTextNode();
            x.Background = s;
            GoTextNode x1 = new GoTextNode();
            x1.Background = s1;
            GoTextNode x2 = new GoTextNode();
            x2.Background = s2;


            GoLink l = new GoLink();
            GoLink l1 = new GoLink();
            GoLink l2 = new GoLink();

            l.FromPort = x.BottomPort;
            l.ToPort = x2.TopPort;


            l1.FromPort = x.RightPort;
            l1.ToPort = x1.TopPort;

            l2.FromPort = x1.BottomPort;
            l2.ToPort = x2.TopPort;

            layout.DirectionOption = GoLayoutDirection.Down;


        private void button1_Click(object sender, EventArgs e)

This is the entire application. It is basically 3 nodes and a button.

Notice what happens when you click on the Button1

Do you know of any workaround


If you change your button1_Click code to:

layout.Network = null;
then you won't have that problem. Or more generally, create a new GoLayoutLayeredDigraph each time you want to call PerformLayout.
I'm not sure what how that residual memory of the Network is causing the behavior you see.

Thank you Walter,

That really did help.


Similar problem.

I modified FlowCharter to illustrate the issue. Add the following code to MainForm(), replacing fileSaveAllMenuItem_Click().

protected void fileSaveAllMenuItem_Click(Object sender, EventArgs evt) 
   GraphViewWindow canvas = this.ActiveMdiChild as GraphViewWindow;
   if (canvas != null)

 public void LayoutDocument(GraphDoc doc)
   GoLayoutLayeredDigraph m_layout = new GoLayoutLayeredDigraph();

   m_layout.Network = null;
   m_layout.DirectionOption = GoLayoutDirection.Down;
   m_layout.LayeringOption = GoLayoutLayeredDigraphLayering.OptimalLinkLength;
   m_layout.PackOption = GoLayoutLayeredDigraphPack.Median;
   m_layout.AggressiveOption = GoLayoutLayeredDigraphAggressive.More;
   m_layout.Document = doc;

Add reference and using for Northwoods.Go.Layout. And if you want to be fancy replace the “Save All” menu text with “Layout”.

Build a graph in the following format:

      C - B
       |   |
      D - E

Not sure link direction matters, but A->B->C->D->E and B->E


Layout again. Notice the graph layout has changed. Slightly, typically one link is moved, but a problem when I am trying to implement a “Restore to default layout” feature.

Note further layouts do not change the graph.

Any suggestions?

Thank You

Perhaps I’m not getting the same behavior as you, but I notice that a subsequent layout just moves the nodes by a very small fraction of a pixel. It’s so small that you cannot see it.

Is that what you are referring to?

I am definitely getting noticeable movement of the second layout. On the order of several pixels.

Perhaps the initial graph layout makes a difference. I’ve sent the initial layout, after first layout and after second layout graphs from the FlowCharter example to gosales.

Also sent the code change to FlowCharter->MainForm().

Thank You

Thanks for sending the files. OK, for that particular graph (InitialLayout.dat), I get the behavior I think you are talking about.

If you don’t set the PackOption property, it doesn’t happen. In fact, I wouldn’t bother to set any of the options except for the direction. That doesn’t mean you’ll always get the same results, though.

The real point I think is that none of the layout algorithms are guaranteed to be produce the same results independent of how the initial graph was constructed.