Example #1
0
        private static double RunMaxFlowAlgorithmAndCheck <TVertex, TEdge>(
            [NotNull] IMutableVertexAndEdgeListGraph <TVertex, TEdge> graph,
            [NotNull] EdgeFactory <TVertex, TEdge> edgeFactory,
            [NotNull] TVertex source,
            [NotNull] TVertex sink)
            where TEdge : IEdge <TVertex>
        {
            var reversedEdgeAugmentorAlgorithm = new ReversedEdgeAugmentorAlgorithm <TVertex, TEdge>(graph, edgeFactory);

            reversedEdgeAugmentorAlgorithm.AddReversedEdges();

            double flow = graph.MaximumFlow(
                edge => 1,
                source, sink,
                out _,
                edgeFactory,
                reversedEdgeAugmentorAlgorithm);

            reversedEdgeAugmentorAlgorithm.RemoveReversedEdges();

            return(flow);
        }