Strange paths when linking 2 left ports with GoLinkAdjustingStyle.End

Hi there,

we are using GoDiagram, although i could reproduce the same issue with the latest version.
We have some bidirectional ports, so we put them both on the left side. When we connect them, the stroke shows some strange paths.

I created a small sample, here a breief description of it:
I have 2 nodes at 40,40 and 80,80, both having a left port which are connected. I use a right directed LayeredDigraph. If I set the source port FromSpot = GoObject.MiddleLeft andlayout the graph, the path writes a strange Z like shape. We see it in much more complex scenarios always with the path having points as if it would like to arrive on the other side of the node.

Any ideas?

Find below the source for the repro (just create a console app with this file as program.cs, and add reference to Go and Go.Layout

    using System;
    using System.Drawing;
    using System.Linq;
    using Northwoods.Go;
    using Northwoods.Go.Layout;

    namespace GoLinkProblem
        class Program
            static void Main(string[] args)
                var datafactory = new DataFactory();
                var document = datafactory.CreateTestDocument();
                var layout = datafactory.GetLayout(document);
                var link = layout.Network.Links.First();

                for (int i = 0; i < link.Stroke.PointsCount; i++)
                    var pointF = link.Stroke.GetPoint(i);
                    Console.WriteLine("{0}: x={1} y={2}", i, pointF.X, pointF.Y);

        internal class DataFactory
            public GoDocument CreateTestDocument()
                var view = new GoView();
                var result = view.Document;

                var vertex1 = new GoGeneralNode
                    Location = new PointF(40, 40),
                    Size = new SizeF(20,20),

                var vertex2 = new GoGeneralNode
                    Location = new PointF(80, 80),
                    Size = new SizeF(20, 20)

                var fromPort = new GoGeneralNodePort
                    FromSpot = GoObject.MiddleLeft // this makes all the difference
                var toPort = new GoGeneralNodePort();
                var link = new GoLink
                    FromPort = fromPort,
                    ToPort = toPort,
                link.AdjustingStyle = GoLinkAdjustingStyle.End; // this makes all the difference
                link.SetPoints(new PointF[] {new PointF(40, 50), new PointF(35, 50), new PointF(75, 90), new PointF(80, 90),    });

                return result;

            public GoLayoutLayeredDigraph GetLayout(GoDocument document)
                var result = new GoLayoutLayeredDigraph();
                result.DirectionOption = GoLayoutDirection.Right;
                result.SetsPortSpots = false;
                result.Document = document;
                return result;

You’re giving something to LayeredDigraph that it just isn’t wired to understand… it assumes a directional (in the case left to right) progression of inputs and outputs. If a node down the chain connects back to an earlier node, it will do that routing, but still assumes out on right and in on left.

My advice is to do the layout you are doing, but set those “special” links to Orthogonal true (without the AdjustingStyle) and call link.CalculateStroke() on each one after the layout. It you want AdjustingStyle, turn it off and then back on around the CalculateStroke.

It’s hard for me to tell without more context about what you want the diagram to look like, but I think that will work.