Пример #1
0
        public void graphCreationTest()
        {
            Matrix matrix = new Matrix(new int[, ] {
                { 1, 2, 3 },
                { 0, 3, 0 },
                { 3, 0, 1 }
            });

            (this.graph, this.edgeCost) = GraphCreator.Create(matrix);
            for (int i = 0; i < matrix.Height; i++)
            {
                for (int j = 0; j < matrix.Width; j++)
                {
                    if (matrix[i, j] > 0)
                    {
                        Edge <int> edge = new Edge <int>(i, j);
                        Assert.IsTrue(graphContainsEdge(this.graph, edge) && this.edgeCost(edge) == matrix[i, j]);
                    }
                    else
                    {
                        Assert.IsFalse(graphContainsEdge(this.graph, new Edge <int>(i, j)));
                    }
                }
            }
        }
Пример #2
0
        public void PDFCreatorTest()
        {
            Matrix matrix = new Matrix(new int[, ] {
                { 0, 1, 2, 3 },
                { 1, 0, 1, 2 },
                { 2, 1, 0, 4 },
                { 3, 2, 4, 0 }
            });

            (this.graph, this.edgeCost) = GraphCreator.Create(matrix);
            TryFunc <int, IEnumerable <Edge <int> > > tryGetPath = graph.ShortestPathsDijkstra(this.edgeCost, 0);

            PdfGenerator.Generate(DotGenerator <int, Edge <int> > .GetDotCode(this.graph, tryGetPath), "test");
            Assert.IsTrue(File.Exists("test.pdf"));
            File.Delete("test.pdf");
        }
Пример #3
0
 public void ReLayoutGraph()
 {
     graph = GraphCreator.Create(Directory);
     NotifyPropertyChanged("Graph");
 }