Example #1
0
        public void FordFulkersonMethodTest01()
        {
            var data = new double[,]
            {
                {1, 2, 12, 2},
                {1, 6, 6, 6},
                {2, 3, 2, 2},
                {3, 4, 1, 1},
                {3, 5, 5, 2},
                {5, 4, 15, 7},
                {5, 7, 2, 0},
                {6, 2, 10, 0},
                {6, 5, 5, 5},
                {6, 7, 8, 1},
                {7, 2, 2, 0},
                {7, 3, 6, 1}
            };
            Dictionary<Edge<int>, double> expectedResult;
            var graph = GraphHelper.CreateGraph(data, out expectedResult);
            var startVertex = graph.GetVertex(0);
            var endVertex = graph.GetVertex(3);

            var ffm = new FordFulkersonMethod(graph, startVertex, endVertex);
            var actualResult = ffm.Solve();
            var actualCost = ffm.ResultCost;

            Assert.AreEqual(8, actualCost);
            Assert.AreEqual(expectedResult, actualResult);
        }
Example #2
0
        public void FordFulkersonMethodTest00()
        {
            var data = new double[,]
            {
                {1, 2, 4, 4, 0, 4},
                {1, 4, 9, 5, 0, 6},
                {2, 4, 2, 2, 0, 1},
                {2, 5, 4, 2, 0, 3},
                {3, 5, 1, 1, 0, 0},
                {3, 6, 10, 0, 0, 1},
                {4, 3, 1, 1, 0, 1},
                {4, 6, 6, 6, 0, 6},
                {5, 6, 1, 1, 0, 1},
                {5, 7, 2, 2, 0, 2},
                {6, 7, 9, 7, 0, 8}
            };
            Dictionary<Edge<int>, double> startX;
            List<Edge<int>> baseU;
            Dictionary<Edge<int>, double> expectedResult;
            var graph = GraphHelper.CreateGraph(data, out startX, out baseU, out expectedResult);
            var startVertex = graph.GetVertex(0);
            var endVertex = graph.GetVertex(graph.Vertices.Count - 1);
            const double startCost = 9.0;

            var ffm = new FordFulkersonMethod(graph, startVertex, endVertex, startX, startCost);
            var actualResult = ffm.Solve();
            var actualCost = ffm.ResultCost;

            Assert.AreEqual(10, actualCost);
            Assert.AreEqual(expectedResult, actualResult);
        }
Example #3
0
        public void FordFulkersonMethodTest1()
        {
            var data = new double[,]
            {
                {1, 2, 3, 3},
                {1, 3, 2, 2},
                {1, 4, 1, 1},
                {1, 6, 6, 4},
                {2, 4, 1, 1},
                {2, 5, 2, 2},
                {3, 4, 1, 0},
                {3, 5, 2, 2},
                {3, 6, 4, 0},
                {4, 5, 7, 0},
                {4, 6, 5, 0},
                {4, 7, 4, 2},
                {4, 8, 1, 0},
                {5, 7, 3, 2},
                {5, 8, 2, 2},
                {6, 8, 4, 4},
                {7, 6, 3, 0},
                {7, 8, 5, 4}
            };
            Dictionary<Edge<int>, double> expectedResult;
            var graph = GraphHelper.CreateGraph(data, out expectedResult);
            var startVertex = graph.GetVertex(0);
            var endVertex = graph.GetVertex(graph.Vertices.Count - 1);

            var ffm = new FordFulkersonMethod(graph, startVertex, endVertex);
            /*var actualResult = */ffm.Solve();
            var actualCost = ffm.ResultCost;

            Assert.AreEqual(10, actualCost);
            //Assert.AreEqual(expectedResult, actualResult);
        }
Example #4
0
        public void FordFulkersonMethodTest7()
        {
            var data = new double[,]
            {
                {1, 5, 4, 1},
                {1, 6, 6, 6},
                {1, 7, 2, 0},
                {2, 1, 3, 0},
                {2, 3, 2, 0},
                {2, 5, 7, 0},
                {4, 2, 3, 0},
                {4, 3, 5, 0},
                {4, 5, 2, 0},
                {4, 7, 4, 0},
                {4, 9, 2, 0},
                {5, 6, 1, 1},
                {6, 9, 7, 7},
                {7, 6, 1, 0},
                {8, 4, 6, 0},
                {8, 7, 4, 0},
                {8, 9, 1, 0}
            };
            Dictionary<Edge<int>, double> expectedResult;
            var graph = GraphHelper.CreateGraph(data, out expectedResult);
            var startVertex = graph.GetVertex(0);
            var endVertex = graph.GetVertex(graph.Vertices.Count - 1);

            var ffm = new FordFulkersonMethod(graph, startVertex, endVertex);
            var actualResult = ffm.Solve();
            var actualCost = ffm.ResultCost;

            Assert.AreEqual(7, actualCost);
            Assert.AreEqual(expectedResult, actualResult);
        }