Example #1
0
        public void TestDinitz()
        {
            FlowNetwork N = BuildSimpleFlowNetwork();
            var         f = N.Dinitz();

            Assert.AreEqual(1, f(N.G.GetEdge("s", "a")));
            Assert.AreEqual(1, f(N.G.GetEdge("s", "b")));
            Assert.AreEqual(1, f(N.G.GetEdge("a", "t")));
            Assert.AreEqual(1, f(N.G.GetEdge("b", "t")));
            Assert.IsTrue(N.IsValidFlow(f));

            N = BuildComplexFlowNetwork();
            f = N.Dinitz();
            Assert.AreEqual(12, f(N.G.GetEdge("s", "a")) + f(N.G.GetEdge("s", "b")));
            Assert.AreEqual(12, f(N.G.GetEdge("c", "t")) + f(N.G.GetEdge("d", "t")));
            Assert.IsTrue(N.IsValidFlow(f));
        }