public void CorrectlyCountCycles()
        {
            IMutableGraph <int> sut = new MutableAdjacencyListGraph <int>();

            sut.AddVertex(1);
            sut.AddVertex(2);
            sut.AddVertex(3);
            sut.AddVertex(4);
            sut.AddVertex(5);
            sut.AddVertex(6);
            sut.AddVertex(7);
            sut.AddVertex(8);

            sut.AddEdge(1, 2);
            sut.AddEdge(1, 4);
            sut.AddEdge(2, 3);
            sut.AddEdge(2, 4);
            sut.AddEdge(2, 5);
            sut.AddEdge(2, 7);
            sut.AddEdge(3, 1);
            sut.AddEdge(3, 8);
            sut.AddEdge(4, 5);
            sut.AddEdge(4, 6);
            sut.AddEdge(5, 7);
            sut.AddEdge(6, 3);
            sut.AddEdge(7, 3);
            sut.AddEdge(8, 1);

            var cycles = sut.ToImmutableGraph().GetCycles();

            Assert.AreEqual(14, cycles.Count());
        }
        public void DetectCycles()
        {
            IMutableGraph <int> sut = new MutableAdjacencyListGraph <int>();

            sut.AddVertex(1);
            sut.AddVertex(2);
            sut.AddVertex(3);
            sut.AddVertex(4);
            sut.AddVertex(5);
            sut.AddVertex(6);
            sut.AddVertex(7);
            sut.AddVertex(8);
            sut.AddVertex(9);

            sut.AddEdge(1, 2);
            sut.AddEdge(2, 3);
            sut.AddEdge(2, 4);
            sut.AddEdge(4, 7);
            sut.AddEdge(1, 3);
            sut.AddEdge(3, 7);
            sut.AddEdge(3, 5);
            sut.AddEdge(6, 7);
            sut.AddEdge(4, 3);
            sut.AddEdge(3, 6);

            Assert.IsFalse(sut.ToImmutableGraph().HasCycle());

            sut.AddEdge(6, 3);

            Assert.IsTrue(sut.ToImmutableGraph().HasCycle());
        }
        public void NotAllowDuplicateVertices()
        {
            IMutableGraph <int> sut = new MutableAdjacencyListGraph <int>();

            sut.AddVertex(1);
            sut.AddVertex(2);
            sut.AddVertex(3);
            sut.AddVertex(2);
        }
        public void NotAddNullVertices()
        {
            IMutableGraph <int?> sut = new MutableAdjacencyListGraph <int?>();

            sut.AddVertex(1);
            sut.AddVertex(2);
            sut.AddVertex(3);

            sut.AddVertex(null);
        }
        public void NotAddEdgesFromNonexistantVertices()
        {
            IMutableGraph <int> sut = new MutableAdjacencyListGraph <int>();

            sut.AddVertex(1);
            sut.AddVertex(2);
            sut.AddVertex(3);

            sut.AddEdge(1, 2);
            sut.AddEdge(1, 3);
            sut.AddEdge(2, 2);

            sut.AddEdge(4, 3);
        }
        public void NotRemoveNonexistantEdges()
        {
            IMutableGraph <int> sut = new MutableAdjacencyListGraph <int>();

            sut.AddVertex(1);
            sut.AddVertex(2);
            sut.AddVertex(3);

            sut.AddEdge(1, 2);
            sut.AddEdge(1, 3);
            sut.AddEdge(2, 2);

            sut.RemoveEdge(3, 1);
        }
        public void NotSuccessfullyCastVertexEnumberableToMutableCollection()
        {
            IMutableGraph <int> sut = new MutableAdjacencyListGraph <int>();

            sut.AddVertex(1);
            sut.AddVertex(2);
            sut.AddVertex(3);
            sut.AddVertex(4);

            sut.AddEdge(1, 2);
            sut.AddEdge(1, 4);
            sut.AddEdge(2, 3);
            sut.AddEdge(2, 4);

            var immutable = sut.ToImmutableGraph();
            var verts     = (MutableAdjacencyListGraph <int>)immutable.Vertices;
        }
        public void NotSuccessfullyCastToMutableGraph()
        {
            IMutableGraph <int> sut = new MutableAdjacencyListGraph <int>();

            sut.AddVertex(1);
            sut.AddVertex(2);
            sut.AddVertex(3);
            sut.AddVertex(4);

            sut.AddEdge(1, 2);
            sut.AddEdge(1, 4);
            sut.AddEdge(2, 3);
            sut.AddEdge(2, 4);

            var immutable = sut.ToImmutableGraph();
            var mutable   = (MutableAdjacencyListGraph <int>)immutable;
        }