public void Graph_KeepBalance_EquallyBalanced()
        {
            var loaderMock = new Mock <IDataLoader>();

            loaderMock.Setup(m => m.LoadData()).Returns(_dummyFile);
            var randomMock = new Mock <Random>();

            randomMock.Setup(s => s.Next(It.IsAny <int>(), It.IsAny <int>())).Returns(1);

            var graph = new DimacsGraph(loaderMock.Object, randomMock.Object);

            graph.InitializeGraph();
            graph.InitializeAnts(_optionTwoColors.NumberOfAnts);
            graph.ColorVerticesRandomly(_optionTwoColors.NumberOfPartitions);
            Vertex vertexWithAnt   = graph.MoveAntToAnyAdjacentVertex(0);
            int    oldColor        = vertexWithAnt.Color;
            int    vertexWithAntID = vertexWithAnt.ID;
            Vertex newVertex       = graph.ColorVertexWithBestColor(0);

            graph.KeepBalance(_optionTwoColors.NumberOfVerticesForBalance, vertexWithAntID, oldColor, newVertex.Color);

            var numberOfVerticesWithFirstColor  = graph.Vertices.Count(vertex => vertex.Color == 1);
            var numberOfVerticesWithSecondColor = graph.Vertices.Count(vertex => vertex.Color == 2);

            Assert.AreEqual(4, numberOfVerticesWithFirstColor);
            Assert.AreEqual(3, numberOfVerticesWithSecondColor);
        }
        public void Graph_UpdateLocalCostFunction_Success()
        {
            var loaderMock = new Mock <IDataLoader>();

            loaderMock.Setup(m => m.LoadData()).Returns(_dummyFile);
            var randomMock = new Mock <Random>();

            randomMock.Setup(s => s.Next(It.IsAny <int>(), It.IsAny <int>())).Returns(1);

            var graph = new DimacsGraph(loaderMock.Object, randomMock.Object);

            graph.InitializeGraph();
            graph.InitializeAnts(_optionTwoColors.NumberOfAnts);
            graph.ColorVerticesRandomly(_optionTwoColors.NumberOfPartitions);
            Vertex vertexWithAnt          = graph.MoveAntToAnyAdjacentVertex(0);
            int    oldColor               = vertexWithAnt.Color;
            int    vertexWithAntID        = vertexWithAnt.ID;
            Vertex vertexWithNewColor     = graph.ColorVertexWithBestColor(0);
            Vertex vertexWhichKeepBalance = graph.KeepBalance(_optionTwoColors.NumberOfVerticesForBalance, vertexWithAntID,
                                                              oldColor, vertexWithNewColor.Color);

            graph.UpdateLocalCostFunction(vertexWhichKeepBalance, vertexWithNewColor);

            Assert.AreEqual(0.5, graph.Vertices[0].LocalCost);
            Assert.AreEqual(0.5, graph.Vertices[1].LocalCost);
            Assert.AreEqual(0.25, graph.Vertices[2].LocalCost);
            Assert.AreEqual(0D, graph.Vertices[3].LocalCost);
            Assert.AreEqual(0.5, graph.Vertices[4].LocalCost);
            Assert.AreEqual(0.75, graph.Vertices[5].LocalCost);
            Assert.AreEqual(0, graph.Vertices[6].LocalCost);
        }
        public void Graph_MoveAntToAnyAdjacentVertex_Success()
        {
            var loaderMock = new Mock <IDataLoader>();

            loaderMock.Setup(m => m.LoadData()).Returns(_dummyFile);
            var randomMock = new Mock <Random>();

            randomMock.Setup(s => s.Next(It.IsAny <int>(), It.IsAny <int>())).Returns(1);

            var graph = new DimacsGraph(loaderMock.Object, randomMock.Object);

            graph.InitializeGraph();
            graph.InitializeAnts(_optionTwoColors.NumberOfAnts);
            graph.ColorVerticesRandomly(_optionTwoColors.NumberOfPartitions);
            graph.CalculateLocalCostFunction();

            graph.MoveAntToAnyAdjacentVertex(0);

            Assert.AreEqual(4, graph.Vertices[graph.Ants[0]].ID);

            graph.MoveAntToAnyAdjacentVertex(1);

            Assert.AreEqual(5, graph.Vertices[graph.Ants[1]].ID);
        }