public ActionResult <long> Flow([FromBody] Tuple <List <string>, List <string> > sourceAndDestinationId) { var maxFlowFinder = new MaxFlowFinder(); maxFlowFinder.InitGraph(sourceAndDestinationId.Item1, sourceAndDestinationId.Item2); return(maxFlowFinder.Find()); }
public void FlowTest(Dictionary <string, HashSet <SimpleEdge> > graph, long expected) { maxFlowFinder = new MaxFlowFinder(); maxFlowFinder.Graph = graph; Assert.Equal(expected, maxFlowFinder.Find()); }
public void Test(Dictionary <string, HashSet <SimpleEdge> > graph, Dictionary <string, int> expected) { maxFlowFinder = new MaxFlowFinder(); maxFlowFinder.Graph = graph; Assert.True(maxFlowFinder.Bfs()); //yeah this could be better Assert.Equal(expected, maxFlowFinder.Levels); }
public void Test(Dictionary <string, HashSet <SimpleEdge> > graph, long expectedFlow) { maxFlowFinder = new MaxFlowFinder(); maxFlowFinder.Graph = graph; maxFlowFinder.Bfs(); var reveresedEdgesToAdd = new HashSet <SimpleEdge>(); Assert.Equal(expectedFlow, maxFlowFinder.SendFlow("s", new List <SimpleEdge>(), ref reveresedEdgesToAdd)); }
public void Test(Dictionary <string, HashSet <SimpleEdge> > graph, List <SimpleEdge> path, Dictionary <SimpleEdge, long> expectedFlowsOnEdges, long expectedFlow) { maxFlowFinder = new MaxFlowFinder(); //some dum shit maxFlowFinder.Graph = graph; var reveresedEdgesToAdd = new HashSet <SimpleEdge>(); Assert.Equal(expectedFlow, maxFlowFinder.UpdateFlow(path, ref reveresedEdgesToAdd)); foreach (var edge in path) { Assert.Equal(expectedFlowsOnEdges[edge], edge.Flow); } }