Esempio n. 1
0
        public void BucketGraph_must_work()
        {
            Graph <TwoBuckets> bucketGraph             = GraphGenerator.BucketGraph(3, 5);
            string             expectedAdjacencyMatrix = "   ||0-0|3-0|0-5|3-5|0-3|3-2|3-3|0-2|1-5|2-0|1-0|2-5|0-1|3-4|3-1|0-4\r\n" +
                                                         "======================================================================\r\n" +
                                                         "0-0|| 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" +
                                                         "3-0|| 1 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" +
                                                         "0-5|| 1 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" +
                                                         "3-5|| 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" +
                                                         "0-3|| 1 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" +
                                                         "3-2|| 0 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" +
                                                         "3-3|| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" +
                                                         "0-2|| 1 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 \r\n" +
                                                         "1-5|| 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 \r\n" +
                                                         "2-0|| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 \r\n" +
                                                         "1-0|| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 \r\n" +
                                                         "2-5|| 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 \r\n" +
                                                         "0-1|| 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 \r\n" +
                                                         "3-4|| 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 \r\n" +
                                                         "3-1|| 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 \r\n" +
                                                         "0-4|| 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 \r\n";

            string adjacencyMatrix = bucketGraph.GetAdjacencyMatrix();

            Assert.AreEqual(expectedAdjacencyMatrix, adjacencyMatrix);
        }
Esempio n. 2
0
        public void Copy_must_work()
        {
            Graph <TwoBuckets> graph     = GraphGenerator.BucketGraph(3, 5);
            Graph <TwoBuckets> graphCopy = graph.Copy();

            Assert.IsFalse(ReferenceEquals(graph.Vertices, graphCopy.Vertices));
            Assert.IsFalse(ReferenceEquals(graph.Edges, graphCopy.Edges));

            Assert.IsFalse(ReferenceEquals(graph.Vertices[0], graphCopy.Vertices[0]));
            Assert.IsFalse(ReferenceEquals(graph.Edges[0], graphCopy.Edges[0]));
        }