public void MaxFlowTwiceTest() { var fg = new FlowGraph(3); Assert.That(fg.AddEdge(0, 1, 1), Is.Zero); Assert.That(fg.AddEdge(0, 2, 1), Is.EqualTo(1)); Assert.That(fg.AddEdge(1, 2, 1), Is.EqualTo(2)); Assert.That(fg.MaxFlow(0, 2), Is.EqualTo(2)); Assert.That(fg.GetEdge(0), Is.EqualTo(new FlowGraph.Edge(0, 1, 1, 1))); Assert.That(fg.GetEdge(1), Is.EqualTo(new FlowGraph.Edge(0, 2, 1, 1))); Assert.That(fg.GetEdge(2), Is.EqualTo(new FlowGraph.Edge(1, 2, 1, 1))); fg.ChangeEdge(0, 100, 10); Assert.That(fg.GetEdge(0), Is.EqualTo(new FlowGraph.Edge(0, 1, 100, 10))); Assert.That(fg.MaxFlow(0, 2), Is.Zero); Assert.That(fg.MaxFlow(0, 1), Is.EqualTo(90)); Assert.That(fg.GetEdge(0), Is.EqualTo(new FlowGraph.Edge(0, 1, 100, 100))); Assert.That(fg.GetEdge(1), Is.EqualTo(new FlowGraph.Edge(0, 2, 1, 1))); Assert.That(fg.GetEdge(2), Is.EqualTo(new FlowGraph.Edge(1, 2, 1, 1))); Assert.That(fg.MaxFlow(2, 0), Is.EqualTo(2)); Assert.That(fg.GetEdge(0), Is.EqualTo(new FlowGraph.Edge(0, 1, 100, 99))); Assert.That(fg.GetEdge(1), Is.EqualTo(new FlowGraph.Edge(0, 2, 1, 0))); Assert.That(fg.GetEdge(2), Is.EqualTo(new FlowGraph.Edge(1, 2, 1, 0))); }
public void ArgumentExceptionInChangeEdge([Values(-10, 100)] int newFlow) { var fg = new FlowGraph(3); fg.AddEdge(0, 1, 100); fg.AddEdge(1, 2, 100); Assert.Throws <ArgumentException>(() => fg.ChangeEdge(1, 10, newFlow)); }
public void ArgumentOutOfRangeExceptionInChangeEdge([Values(-1, 3)] int v) { var fg = new FlowGraph(3); fg.AddEdge(0, 1, 100); fg.AddEdge(1, 2, 100); Assert.Throws <ArgumentOutOfRangeException>(() => fg.ChangeEdge(v, 100, 10)); }