Example #1
0
        public void Compute(CancellationToken cancellationToken)
        {
            var eslaParameters = new EfficientSugiyamaLayoutParameters
            {
                MinimizeEdgeLength = true,
                LayerDistance      = 120
            };
            var esla = new EfficientSugiyamaLayoutAlgorithm <TVertex, TEdge, TGraph>(m_Graph, eslaParameters, VertexPositions, VertexSizes);

            esla.Compute(cancellationToken);
            VertexPositions = new Dictionary <TVertex, Point>();
            double offsetY = esla.VertexPositions.Values.Min(p => p.X);

            if (offsetY < 0)
            {
                m_OffsetY = -offsetY;
            }
            foreach (KeyValuePair <TVertex, Point> kvp in esla.VertexPositions)
            {
                VertexPositions.Add(
                    kvp.Key,
                    new Point(
                        kvp.Value.Y * m_RateX + m_OffsetX,
                        kvp.Value.X * m_RateY + m_OffsetY));
            }
        }
Example #2
0
        public void AutoLayout()
        {
            var w   = ((VM.MainWindow)DataContext).CurrentWorkspace;
            var alg = new EfficientSugiyamaLayoutAlgorithm <IGraphNode, VM.ProducibleItem, Workspace>(w, new EfficientSugiyamaLayoutParameters(), new Dictionary <IGraphNode, Point>(), new Dictionary <IGraphNode, Size>());

            alg.Compute();
        }
Example #3
0
        public void Compute()
        {
            var eslaParameters = new EfficientSugiyamaLayoutParameters()
            {
                MinimizeEdgeLength = true,
                LayerDistance      = 80
            };

            var esla = new EfficientSugiyamaLayoutAlgorithm <TVertex, TEdge, TGraph>(_graph, eslaParameters, null, VertexSizes);

            esla.Compute();

            vertexPositions = new Dictionary <TVertex, Point>();

            double offsetY = esla.VertexPositions.Values.Min(p => p.X);

            if (offsetY < 0)
            {
                _offsetY = -offsetY;
            }
            //vertexPositions = esla.VertexPositions;
            foreach (var item in esla.VertexPositions)
            {
                vertexPositions.Add(item.Key, new Point(item.Value.Y * 1.5 + this._offsetX, item.Value.X + this._offsetY));
            }
        }
Example #4
0
        /// <summary>
        /// Performs the actual layout algorithm.
        /// </summary>
        /// <param name="graph">The object containing the graph data</param>
        /// <param name="rootNode">Root node</param>
        protected override void PerformLayout(GraphMapData graph, INode rootNode)
        {
            AdjacencyGraph<string, Edge<string>> adjacencyGraph = GraphSharpUtility.GetAdjacencyGraph(graph);
            EfficientSugiyamaLayoutParameters efficientSugiyamaLayoutParameters = new EfficientSugiyamaLayoutParameters();
            IDictionary<string, Vector> nodePositions = GraphSharpUtility.GetNodePositions(graph);
            IDictionary<string, Size> nodeSizes = GraphSharpUtility.GetNodeSizes(graph);

            EfficientSugiyamaLayoutAlgorithm<string, Edge<string>, AdjacencyGraph<string, Edge<string>>> efficientSugiyamaLayoutAlgorithm = new EfficientSugiyamaLayoutAlgorithm<string, Edge<string>, AdjacencyGraph<string, Edge<string>>>(adjacencyGraph, efficientSugiyamaLayoutParameters, nodePositions, nodeSizes);
            efficientSugiyamaLayoutAlgorithm.Compute();

            GraphSharpUtility.SetNodePositions(graph, efficientSugiyamaLayoutAlgorithm.VertexPositions);
        }
        public void Compute(CancellationToken cancellationToken)
        {
            var pars = new EfficientSugiyamaLayoutParameters {
                LayerDistance = 200
            };
            var algo = new EfficientSugiyamaLayoutAlgorithm <DataVertex, DataEdge, IMutableBidirectionalGraph <DataVertex, DataEdge> >(_graph, pars, _vertexPositions, VertexSizes);

            algo.Compute(cancellationToken);

            // now you can use = algo.VertexPositions for custom manipulations

            //set this algo calculation windowResult
            _vertexPositions = algo.VertexPositions;
        }
Example #6
0
        public void Compute()
        {
            var pars = new EfficientSugiyamaLayoutParameters {
                LayerDistance = 200
            };
            var algo = new EfficientSugiyamaLayoutAlgorithm <DataVertex, DataEdge, IVertexAndEdgeListGraph <DataVertex, DataEdge> >(Graph, pars, vertexPositions, VertexSizes);

            algo.Compute();

            // now you can use = algo.VertexPositions for custom manipulations

            //set this algo calculation results
            vertexPositions = algo.VertexPositions;
        }
Example #7
0
        public static string Test()
        {
            var g    = new AdjacencyGraph <Vertex, Edge <Vertex> >();
            var dict = new Dictionary <Vertex, SKSize>();

            var A = new Vertex("A"); dict[A] = new SKSize(10, 10);
            var B = new Vertex("B"); dict[B] = new SKSize(10, 10);
            var C = new Vertex("C"); dict[C] = new SKSize(10, 10);
            var D = new Vertex("D"); dict[D] = new SKSize(10, 10);

            g.AddVertex(A);
            g.AddVertex(B);
            g.AddVertex(C);
            g.AddVertex(D);
            g.AddEdge(new Edge <Vertex>(A, B));
            g.AddEdge(new Edge <Vertex>(A, C));
            g.AddEdge(new Edge <Vertex>(B, D));
            g.AddEdge(new Edge <Vertex>(C, D));

            // INPUT

            // Do not give the opional vertextPosition dictionary parameters:
            // they are always thrown away and can be useful only to set its initial size of the separate output dictionary
            // Edge predicate cannot be null

            //var alg1 = new SugiyamaLayoutAlgorithm<Vertex, Edge<Vertex>, AdjacencyGraph<Vertex, Edge<Vertex>>>(
            //    visitedGraph: g,
            //    vertexSizes: dict,
            //    parameters:null,
            //    edgePredicate:null);

            var alg2 = new EfficientSugiyamaLayoutAlgorithm <Vertex, Edge <Vertex>, AdjacencyGraph <Vertex, Edge <Vertex> > >(
                visitedGraph: g,
                parameters: null,
                vertexSizes: dict);

            // COMPUTE

            //alg1.Compute();
            alg2.Compute();

            // OUTPUT
            return
                //Report(alg1.VertexPositions, alg1.EdgeRoutes) +
                //Environment.NewLine + Environment.NewLine +
                (Report(alg2.VertexPositions, alg2.EdgeRoutes));
        }
Example #8
0
        public ComputeLayout(AdjacencyGraph <Vertex, Kaemika.Edge <Vertex> > GRAPH, float textHeight, float nodePadding, float nodeHeight)
        {
            this.nodePadding = nodePadding;
            this.nodeHeight  = nodeHeight;
            this.vertexSizes = ComputeUniformVertexSizes(GRAPH.Vertices, textHeight, nodePadding);
            var alg = new EfficientSugiyamaLayoutAlgorithm <Vertex, Kaemika.Edge <Vertex>, AdjacencyGraph <Vertex, Kaemika.Edge <Vertex> > >(
                visitedGraph: GRAPH,
                parameters: new EfficientSugiyamaLayoutParameters {
                LayerDistance = nodeHeight, VertexDistance = nodeHeight,
                EdgeRouting   = SugiyamaEdgeRoutings.Traditional,   // Orthogonal is no good
            },
                vertexSizes: vertexSizes);

            alg.Compute(); // COMPUTE LAYOUT
            this.vertexPositions = alg.VertexPositions;
            this.edgeRoutes      = alg.EdgeRoutes;
        }
Example #9
0
        /// <summary>
        /// Performs the actual layout algorithm.
        /// </summary>
        /// <param name="graph">The object containing the graph data</param>
        /// <param name="rootNode">Root node</param>
        protected override void PerformLayout(GraphMapData graph, INode rootNode)
        {
            AdjacencyGraph <string, Edge <string> > adjacencyGraph = GraphSharpUtility.GetAdjacencyGraph(graph);
            EfficientSugiyamaLayoutParameters       efficientSugiyamaLayoutParameters = new EfficientSugiyamaLayoutParameters();
            IDictionary <string, Vector>            nodePositions = GraphSharpUtility.GetNodePositions(graph);
            IDictionary <string, Size> nodeSizes = GraphSharpUtility.GetNodeSizes(graph);

            EfficientSugiyamaLayoutAlgorithm <string, Edge <string>, AdjacencyGraph <string, Edge <string> > > efficientSugiyamaLayoutAlgorithm = new EfficientSugiyamaLayoutAlgorithm <string, Edge <string>, AdjacencyGraph <string, Edge <string> > >(adjacencyGraph, efficientSugiyamaLayoutParameters, nodePositions, nodeSizes);

            efficientSugiyamaLayoutAlgorithm.Compute();

            GraphSharpUtility.SetNodePositions(graph, efficientSugiyamaLayoutAlgorithm.VertexPositions);
        }