public void GenerateGraphGeneratesBackTriangleGraphStructure2()
        {
            var target = GraphGenerator.GenerateGraph(3, 4, 2);

            GraphTestHelper.AssertConsistsOfSequences(target, new[]
            {
                new[] { 0, 2 },
                new[] { 0, 3 },
                new[] { 0, 4 },
                new[] { 0, 5 },
                new[] { 1, 2 },
                new[] { 1, 3 },
                new[] { 1, 4 },
                new[] { 1, 5 },
                new[] { 2, 6 },
                new[] { 2, 7 },
                new[] { 2, 8 },
                new[] { 2, 9 },
                new[] { 3, 6 },
                new[] { 3, 7 },
                new[] { 3, 8 },
                new[] { 3, 9 },
                new[] { 4, 10 },
                new[] { 4, 11 },
                new[] { 4, 12 },
                new[] { 4, 13 },
                new[] { 5, 10 },
                new[] { 5, 11 },
                new[] { 5, 12 },
                new[] { 5, 13 },
            });
        }
        public void GenerateGraphGeneratesTriangleGraphStructure2()
        {
            var target = GraphGenerator.GenerateGraph(3, 2, 4);

            GraphTestHelper.AssertConsistsOfSequences(target, new[]
            {
                new[] { 0, 8 },
                new[] { 1, 8 },
                new[] { 2, 8 },
                new[] { 3, 8 },
                new[] { 0, 9 },
                new[] { 1, 9 },
                new[] { 2, 9 },
                new[] { 3, 9 },
                new[] { 4, 10 },
                new[] { 5, 10 },
                new[] { 6, 10 },
                new[] { 7, 10 },
                new[] { 4, 11 },
                new[] { 5, 11 },
                new[] { 6, 11 },
                new[] { 7, 11 },
                new[] { 8, 12 },
                new[] { 9, 12 },
                new[] { 10, 12 },
                new[] { 11, 12 },
                new[] { 8, 13 },
                new[] { 9, 13 },
                new[] { 10, 13 },
                new[] { 11, 13 },
            });
        }
Exemple #3
0
        public void SingleNodeSequenceIsAllowed()
        {
            var graph = GraphTestHelper.CreateEmptyGraph(TargetGraph);

            graph.AddSequence(new[] { 1 });
            GraphTestHelper.AssertCollectionsConsistsOfNodes(new[] { 1 }, graph.GetRootNodes());
            GraphTestHelper.AssertCollectionsConsistsOfNodes(new[] { 1 }, graph.GetLeafNodes());
            GraphTestHelper.AssertConsistsOfSequences(graph, new[]
            {
                new[] { 1 },
            });
        }
Exemple #4
0
        public void ConstructorWithInitialSequenceArgumentInitializesGraph()
        {
            var target = GraphTestHelper.CreateEmptyGraph(TargetGraph);

            target.AddSequence(new[] { 1, 2, 3, 4, 5 });
            Assert.AreEqual(5, target.CountNodes);
            GraphTestHelper.AssertConsistsOfSequences(target, new[]
            {
                new[] { 1, 2 },
                new[] { 2, 3 },
                new[] { 3, 4 },
                new[] { 4, 5 },
                new[] { 1, 2, 3, 4, 5 },
            });
        }
        public void GenerateGraphGeneratesSquareGraphStructure()
        {
            var target = GraphGenerator.GenerateGraph(3, 2, 2);

            GraphTestHelper.AssertConsistsOfSequences(target, new[]
            {
                new[] { 0, 2 },
                new[] { 0, 3 },
                new[] { 1, 2 },
                new[] { 1, 3 },
                new[] { 2, 4 },
                new[] { 2, 5 },
                new[] { 3, 4 },
                new[] { 3, 5 },
            });
        }
        public void GenerateGraphGeneratesVerticalGraphStructure()
        {
            var target = GraphGenerator.GenerateGraph(10, 1, 1);

            GraphTestHelper.AssertConsistsOfSequences(target, new[]
            {
                new[] { 0, 1 },
                new[] { 1, 2 },
                new[] { 2, 3 },
                new[] { 3, 4 },
                new[] { 4, 5 },
                new[] { 5, 6 },
                new[] { 6, 7 },
                new[] { 7, 8 },
                new[] { 8, 9 },
            });
        }
        public void GenerateGraphGeneratesTriangleGraphStructure1()
        {
            var target = GraphGenerator.GenerateGraph(3, 3, 1);

            GraphTestHelper.AssertConsistsOfSequences(target, new[]
            {
                new[] { 0, 1 },
                new[] { 0, 2 },
                new[] { 0, 3 },
                new[] { 1, 4 },
                new[] { 1, 5 },
                new[] { 1, 6 },
                new[] { 2, 7 },
                new[] { 2, 8 },
                new[] { 2, 9 },
                new[] { 3, 10 },
                new[] { 3, 11 },
                new[] { 3, 12 },
            });
        }
Exemple #8
0
        public void AddAddsSequence()
        {
            var target = GraphTestHelper.CreateEmptyGraph(TargetGraph);

            target.AddSequence(new[] { 0, 1 });
            target.AddSequence(new[] { 1, 2 });
            target.AddSequence(new[] { 2, 3 });
            target.AddSequence(new[] { 3, 4 });
            target.AddSequence(new[] { 4, 5 });
            target.AddSequence(new[] { 5, 6 });
            target.AddSequence(new[] { 6, 7 });
            target.AddSequence(new[] { 7, 8 });
            target.AddSequence(new[] { 8, 9 });
            Assert.AreEqual(10, target.CountNodes);
            GraphTestHelper.AssertConsistsOfSequences(target, new[]
            {
                new[] { 0, 1 },
                new[] { 1, 2 },
                new[] { 2, 3 },
                new[] { 3, 4 },
                new[] { 4, 5 },
                new[] { 5, 6 },
                new[] { 6, 7 },
                new[] { 7, 8 },
                new[] { 8, 9 },
                new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
            });
            GraphTestHelper.AssertConsistsOfBackSequences(target, new[]
            {
                new[] { 1, 0 },
                new[] { 2, 1 },
                new[] { 3, 2 },
                new[] { 4, 3 },
                new[] { 5, 4 },
                new[] { 6, 5 },
                new[] { 7, 6 },
                new[] { 8, 7 },
                new[] { 9, 8 },
                new[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
            });
        }
Exemple #9
0
        public void AddRangeAddsSequences()
        {
            var graph = GraphTestHelper.CreateEmptyGraph(TargetGraph);

            graph.AddSequences(new[]
            {
                new[] { 41, 51, 61, 100 },
                new[] { 42, 52, 62, 100 },
            });
            Assert.AreEqual(7, graph.CountNodes);
            GraphTestHelper.AssertConsistsOfSequences(graph, new[]
            {
                new[] { 41, 51 },
                new[] { 51, 61 },
                new[] { 61, 100 },
                new[] { 42, 52 },
                new[] { 52, 62 },
                new[] { 62, 100 },
                new[] { 41, 51, 61, 100 },
                new[] { 42, 52, 62, 100 },
            });
        }
Exemple #10
0
        public void AddAddsExistingSequence()
        {
            // {41, 51, 61, 100},
            // {42, 52, 62, 100},
            var graph = GraphTestHelper.CreateSimpleGraph(TargetGraph);

            Assert.AreEqual(7, graph.CountNodes);
            graph.AddSequence(new[] { 51, 61 });
            graph.AddSequence(new[] { 42, 52 });
            Assert.AreEqual(7, graph.CountNodes);

            GraphTestHelper.AssertConsistsOfSequences(graph, new[]
            {
                new[] { 41, 51 },
                new[] { 51, 61 },
                new[] { 61, 100 },
                new[] { 42, 52 },
                new[] { 52, 62 },
                new[] { 62, 100 },
                new[] { 41, 51, 61, 100 },
                new[] { 42, 52, 62, 100 },
            });
        }