public void MinCostFlowSameCostPathsTest()
        {
            var fg = new FlowGraph(3);

            Assert.That(fg.AddEdge(0, 1, 1, 1), Is.Zero);
            Assert.That(fg.AddEdge(1, 2, 1), Is.EqualTo(1));
            Assert.That(fg.AddEdge(0, 2, 2, 1), Is.EqualTo(2));
            var actual = fg.MinCostSlope(0, 2).ToArray();

            Assert.That(actual[0], Is.EqualTo((0, 0)));
            Assert.That(actual[1], Is.EqualTo((3, 3)));
        }
        public void UsageTest()
        {
            var fg = new FlowGraph(2);

            fg.AddEdge(0, 1, 1, 2);
            Assert.That(fg.MinCostFlow(0, 1), Is.EqualTo((1, 2)));

            fg = new FlowGraph(2);
            fg.AddEdge(0, 1, 1, 2);
            var actual = fg.MinCostSlope(0, 1).ToArray();

            Assert.That(actual[0], Is.EqualTo((0, 0)));
            Assert.That(actual[1], Is.EqualTo((1, 2)));
        }
        public void MinCostFlowSimpleTest()
        {
            var fg = new FlowGraph(4);

            fg.AddEdge(0, 1, 1, 1);
            fg.AddEdge(0, 2, 1, 1);
            fg.AddEdge(1, 3, 1, 1);
            fg.AddEdge(2, 3, 1, 1);
            fg.AddEdge(1, 2, 1, 1);
            var actual = fg.MinCostSlope(0, 3, 10).ToArray();

            Assert.That(actual[0], Is.EqualTo((0, 0)));
            Assert.That(actual[1], Is.EqualTo((2, 4)));

            Assert.That(fg.GetEdge(0), Is.EqualTo(new FlowGraph.Edge(0, 1, 1, 1, 1)));
            Assert.That(fg.GetEdge(1), Is.EqualTo(new FlowGraph.Edge(0, 2, 1, 1, 1)));
            Assert.That(fg.GetEdge(2), Is.EqualTo(new FlowGraph.Edge(1, 3, 1, 1, 1)));
            Assert.That(fg.GetEdge(3), Is.EqualTo(new FlowGraph.Edge(2, 3, 1, 1, 1)));
            Assert.That(fg.GetEdge(4), Is.EqualTo(new FlowGraph.Edge(1, 2, 1, 0, 1)));
        }
        public void ArgumentExceptionInMinCostSlope()
        {
            var fg = new FlowGraph(2);

            Assert.Throws <ArgumentException>(() => fg.MinCostSlope(1, 1));
        }
        public void ArgumentOutOfRangeExceptionInMinCostSlope(int u, int v)
        {
            var fg = new FlowGraph(2);

            Assert.Throws <ArgumentOutOfRangeException>(() => fg.MinCostSlope(u, v));
        }