public ActionResult <long> Flow([FromBody] Tuple <List <string>, List <string> > sourceAndDestinationId)
        {
            var maxFlowFinder = new MaxFlowFinder();

            maxFlowFinder.InitGraph(sourceAndDestinationId.Item1, sourceAndDestinationId.Item2);
            return(maxFlowFinder.Find());
        }
示例#2
0
        public void FlowTest(Dictionary <string, HashSet <SimpleEdge> > graph, long expected)
        {
            maxFlowFinder       = new MaxFlowFinder();
            maxFlowFinder.Graph = graph;

            Assert.Equal(expected, maxFlowFinder.Find());
        }
示例#3
0
        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);
        }
示例#4
0
        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));
        }
示例#5
0
        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);
            }
        }