Example #1
0
        public void KKLayoutAlgorithm(
            [NotNull] IBidirectionalGraph <string, Edge <string> > graph,
            int maxCrossCount)
        {
            IDictionary <string, Size> verticesSizes = GetVerticesSizes(graph.Vertices);

            var parameters = new KKLayoutParameters
            {
                Width  = 1000,
                Height = 1000
            };

            foreach (bool exchange in new[] { true, false })
            {
                parameters.ExchangeVertices = exchange;

                int iteration = 0;
                var algorithm = new KKLayoutAlgorithm <string, Edge <string>, IBidirectionalGraph <string, Edge <string> > >(
                    graph,
                    parameters)
                {
                    Rand = new Random(12345)
                };
                algorithm.IterationEnded += (sender, args) =>
                {
                    Assert.LessOrEqual(args.Iteration, parameters.MaxIterations);
                    Assert.AreEqual(iteration++, args.Iteration);
                };

                LayoutResults results = ExecuteLayoutAlgorithm(algorithm, verticesSizes, true);
                results.CheckResult(maxCrossCount);
            }
        }
        public void ISOMLayoutAlgorithm(
            [NotNull] IBidirectionalGraph <string, Edge <string> > graph,
            int maxCrossCount,
            int maxOverlapped)
        {
            IDictionary <string, Size> verticesSizes = GetVerticesSizes(graph.Vertices);

            var parameters = new ISOMLayoutParameters
            {
                Width  = 1000,
                Height = 1000
            };

            int iteration = 0;
            var algorithm = new ISOMLayoutAlgorithm <string, Edge <string>, IBidirectionalGraph <string, Edge <string> > >(
                graph,
                parameters)
            {
                Rand = new Random(123)
            };

            algorithm.IterationEnded += (sender, args) =>
            {
                Assert.LessOrEqual(args.Iteration, parameters.MaxEpochs);
                Assert.AreEqual(iteration++, args.Iteration);
            };
            algorithm.ProgressChanged += (sender, percent) =>
            {
            };

            LayoutResults results = ExecuteLayoutAlgorithm(algorithm, verticesSizes, true);

            results.CheckResult(maxCrossCount, maxOverlapped);
        }
Example #3
0
        public void LinLogLayoutAlgorithm(
            [NotNull] IBidirectionalGraph <string, Edge <string> > graph,
            int maxCrossCount)
        {
            IDictionary <string, Size> verticesSizes = GetVerticesSizes(graph.Vertices);

            var parameters = new LinLogLayoutParameters();

            int iteration = 1;
            var algorithm = new LinLogLayoutAlgorithm <string, Edge <string>, IBidirectionalGraph <string, Edge <string> > >(
                graph,
                parameters)
            {
                Rand = new Random(12345)
            };

            algorithm.IterationEnded += (sender, args) =>
            {
                Assert.LessOrEqual(args.Iteration, parameters.MaxIterations);
                Assert.AreEqual(iteration++, args.Iteration);
            };

            LayoutResults results = ExecuteLayoutAlgorithm(algorithm, verticesSizes, true);

            results.CheckResult(maxCrossCount);
        }
Example #4
0
        public void FRLayoutAlgorithm(
            [NotNull] IBidirectionalGraph <string, Edge <string> > graph,
            int maxCrossCount)
        {
            IDictionary <string, Size> verticesSizes = GetVerticesSizes(graph.Vertices);

            var parameters = new BoundedFRLayoutParameters
            {
                Width  = 1000,
                Height = 1000
            };

            foreach (FRCoolingFunction func in Enum.GetValues(typeof(FRCoolingFunction)))
            {
                parameters.CoolingFunction = func;

                int iteration = 0;
                var algorithm = new FRLayoutAlgorithm <string, Edge <string>, IBidirectionalGraph <string, Edge <string> > >(
                    graph,
                    parameters)
                {
                    Rand = new Random(12345)
                };
                algorithm.IterationEnded += (sender, args) =>
                {
                    Assert.LessOrEqual(args.Iteration, parameters.MaxIterations);
                    Assert.AreEqual(iteration++, args.Iteration);
                };

                LayoutResults results = ExecuteLayoutAlgorithm(algorithm, verticesSizes, true);
                results.CheckResult(maxCrossCount);
            }
        }
        public void SimpleTreeLayoutAlgorithm(
            [NotNull] IBidirectionalGraph <string, Edge <string> > graph,
            int maxCrossCount)
        {
            IDictionary <string, Size> verticesSizes = GetVerticesSizes(graph.Vertices);

            var parameters = new SimpleTreeLayoutParameters
            {
                LayerGap  = 15,
                VertexGap = 20
            };

            foreach (LayoutDirection direction in Enum.GetValues(typeof(LayoutDirection)))
            {
                parameters.Direction = direction;

                foreach (SpanningTreeGeneration treeGen in Enum.GetValues(typeof(SpanningTreeGeneration)))
                {
                    parameters.SpanningTreeGeneration = treeGen;

                    var algorithm = new SimpleTreeLayoutAlgorithm <string, Edge <string>, IBidirectionalGraph <string, Edge <string> > >(
                        graph,
                        verticesSizes,
                        parameters);

                    LayoutResults results = ExecuteLayoutAlgorithm(algorithm, verticesSizes);
                    results.CheckResult(maxCrossCount);
                    CheckTreeLayout(algorithm, verticesSizes);
                }
            }
        }
Example #6
0
        public void CircularLayoutAlgorithm(
            [NotNull] IBidirectionalGraph <string, Edge <string> > graph,
            int maxCrossCount)
        {
            IDictionary <string, Size> verticesSizes = GetVerticesSizes(graph.Vertices);
            var algorithm = new CircularLayoutAlgorithm <string, Edge <string>, IBidirectionalGraph <string, Edge <string> > >(
                graph,
                verticesSizes,
                new CircularLayoutParameters());

            LayoutResults results = ExecuteLayoutAlgorithm(algorithm, verticesSizes);

            results.CheckResult(maxCrossCount);
            CheckCircularLayout(algorithm);
        }
Example #7
0
        public void SugiyamaLayoutAlgorithm(
            [NotNull] IBidirectionalGraph <string, Edge <string> > graph,
            int maxCrossCount,
            int maxOverlapped)
        {
            IDictionary <string, Size> verticesSizes = GetVerticesSizes(graph.Vertices);

            var parameters = new SugiyamaLayoutParameters();

            foreach (LayoutDirection direction in Enum.GetValues(typeof(LayoutDirection)))
            {
                parameters.Direction = direction;

                foreach (int mode in new[] { -1, 0, 1, 2, 3 })
                {
                    parameters.PositionMode = mode;

                    foreach (bool optimizeWidth in new[] { false, true })
                    {
                        parameters.OptimizeWidth = optimizeWidth;

                        foreach (bool minimizeEdgeLength in new[] { false, true })
                        {
                            parameters.MinimizeEdgeLength = minimizeEdgeLength;

                            var algorithm = new SugiyamaLayoutAlgorithm <string, Edge <string>, IBidirectionalGraph <string, Edge <string> > >(
                                graph,
                                verticesSizes,
                                parameters)
                            {
                                Rand = new Random(12345)
                            };

                            LayoutResults results = ExecuteLayoutAlgorithm(algorithm, verticesSizes);
                            results.CheckResult(maxCrossCount, maxOverlapped);
                        }
                    }
                }
            }
        }