public void NodeShapeChange()
        {
            // Setup
            string        filePath = Path.Combine(this.TestContext.TestDir, "Out\\Dots", "chat.dot");
            GeometryGraph graph    = this.LoadGraph(filePath);
            var           settings = new SugiyamaLayoutSettings();

            // Initial layout
            LayeredLayout layeredLayout = new LayeredLayout(graph, settings);

            layeredLayout.Run();
            SortedList <double, SortedList <double, Node> > originalLayers = SugiyamaValidation.GetLayers(graph, true);

            // Incremental layout
            List <Node> nodes = graph.Nodes.ToList();

            for (int i = 0; i < nodes.Count; i++)
            {
                // Resize a node
                Node node = nodes[i];
                node.BoundaryCurve = node.BoundaryCurve.ScaleFromOrigin(2.0, 2.0);

                // Run incremental layout
                LayeredLayout.IncrementalLayout(graph, node);

                // Verify - the layering and ordering of nodes should not have changed.
                SortedList <double, SortedList <double, Node> > newLayers = SugiyamaValidation.GetLayers(graph, true);
                VerifyLayersAreEqual(originalLayers, newLayers);
            }
        }
Exemplo n.º 2
0
        public void ConstraintWithTransformation()
        {
            Random random = new Random(999);

            GeometryGraph graph = GraphGenerator.GenerateOneSimpleGraph();

            GraphGenerator.SetRandomNodeShapes(graph, random);
            SugiyamaLayoutSettings settings = new SugiyamaLayoutSettings();

            //layer direction to be left to right
            settings.Transformation = PlaneTransformation.Rotation(Math.PI / 2);

            List <Node> nodes = graph.Nodes.ToList();

            settings.AddUpDownConstraint(nodes[0], nodes[1]);
            settings.AddLeftRightConstraint(nodes[3], nodes[4]);
            settings.AddUpDownVerticalConstraint(nodes[0], nodes[3]);
            settings.AddSameLayerNeighbors(nodes[2], nodes[4]);

            LayeredLayout layeredLayout = new LayeredLayout(graph, settings);

            layeredLayout.Run();

            ShowGraphInDebugViewer(graph);

            SugiyamaValidation.ValidateUpDownConstraint(nodes[0], nodes[1]);
            SugiyamaValidation.ValidateLeftRightConstraint(nodes[3], nodes[4]);
            SugiyamaValidation.ValidateUpDownVerticalConstraint(nodes[0], nodes[3]);
            SugiyamaValidation.ValidateNeighborConstraint(graph, nodes[2], nodes[4], settings);
        }
Exemplo n.º 3
0
        public void TreeWithConstraints()
        {
            var graph = new GeometryGraph();

            var closed    = new Node(CreateEllipse(), "closed");
            var line      = new Node(CreateEllipse(), "line");
            var bezier    = new Node(CreateEllipse(), "bezier");
            var arc       = new Node(CreateEllipse(), "arc");
            var rectangle = new Node(CreateEllipse(), "rectangle");
            var ellipse   = new Node(CreateEllipse(), "ellipse");
            var polygon   = new Node(CreateEllipse(), "polygon");
            var shapes    = new Node(CreateEllipse(), "shapes");
            var open      = new Node(CreateEllipse(), "open");

            graph.Nodes.Add(closed);
            graph.Nodes.Add(line);
            graph.Nodes.Add(bezier);
            graph.Nodes.Add(arc);
            graph.Nodes.Add(rectangle);
            graph.Nodes.Add(ellipse);
            graph.Nodes.Add(polygon);
            graph.Nodes.Add(shapes);
            graph.Nodes.Add(open);

            var so = new Edge(shapes, open);
            var sc = new Edge(shapes, closed);
            var ol = new Edge(open, line);
            var ob = new Edge(open, bezier);
            var oa = new Edge(open, arc);
            var cr = new Edge(closed, rectangle);
            var ce = new Edge(closed, ellipse);
            var cp = new Edge(closed, polygon);

            graph.Edges.Add(so);
            graph.Edges.Add(sc);
            graph.Edges.Add(ol);
            graph.Edges.Add(ob);
            graph.Edges.Add(oa);
            graph.Edges.Add(cr);
            graph.Edges.Add(ce);
            graph.Edges.Add(cp);

            var settings = new SugiyamaLayoutSettings();

            settings.AddUpDownVerticalConstraint(closed, ellipse);
            settings.AddUpDownVerticalConstraint(open, bezier);
            settings.AddUpDownConstraint(closed, open);
            settings.AddSameLayerNeighbors(polygon, open);
            settings.AddLeftRightConstraint(closed, open);

            //To verify 444585, just turn on this following commented line
            settings.AddLeftRightConstraint(ellipse, rectangle);
            settings.AddLeftRightConstraint(ellipse, bezier);

            LayeredLayout layeredLayout = new LayeredLayout(graph, settings);

            layeredLayout.Run();

            ShowGraphInDebugViewer(graph);

            Assert.IsTrue(Math.Abs(closed.Center.X - ellipse.Center.X) < 0.01);
            Assert.IsTrue(Math.Abs(open.Center.X - bezier.Center.X) < 0.01);

            foreach (var n0 in graph.Nodes)
            {
                foreach (var n1 in graph.Nodes)
                {
                    if (n0 == n1)
                    {
                        continue;
                    }
                    Assert.IsFalse(n0.BoundingBox.Intersects(n1.BoundingBox));
                }
            }

            SugiyamaValidation.ValidateUpDownVerticalConstraint(closed, ellipse);
            SugiyamaValidation.ValidateUpDownVerticalConstraint(open, bezier);
            SugiyamaValidation.ValidateUpDownConstraint(closed, open);
            SugiyamaValidation.ValidateNeighborConstraint(graph, polygon, open, settings);
            SugiyamaValidation.ValidateLeftRightConstraint(closed, open);

            //To verify 444585, also turn on this following commented line
            //SugiyamaValidation.ValidateLeftRightConstraint(ellipse, rectangle);
            SugiyamaValidation.ValidateLeftRightConstraint(ellipse, bezier);
        }