Esempio n. 1
0
        public void GivenNullArcsWhenTryToFindMaximumFlowThenThrowError()
        {
            // arrange
            var source      = new SimpleNode("START");
            var destination = new SimpleNode("DESTINATION");

            // act & assert
            Assert.Throws <ArgumentNullException>(() => FordFulkerson.FindMaximumFlow(null, source, destination));
            Assert.Throws <ArgumentNullException>(() => FordFulkerson.FindMaximumFlow <IArcWithFlow <SimpleNode> >(null));
        }
        //https://github.com/lucasrabiec/MaximumFlowProblem
        public double Calculate(Graph g)
        {
            if (g.order == 0 || !InvariantBool.IsConnected.Calculate(g))
            {
                return(0);
            }
            FordFulkerson fordF = new FordFulkerson(g.adjacencyMatrix);

            return(fordF.FindMaximumFlow());
        }