AdvancedAlgorithms.MaximumFlow.GetMaximumFlow C# (CSharp) Method

GetMaximumFlow() private static method

private static GetMaximumFlow ( int source, int sink, int numVertices ) : int
source int
sink int
numVertices int
return int
        private static int GetMaximumFlow(int source, int sink, int numVertices)
        {
            int result = 0; //the resulting maximum flow
            bool augPathFound = true;

            //keep looping until we can't get an augmenting path anymore.
            while (augPathFound)
            {
                augPathFound = false;
                //find a new augmenting path and get its capacity
                int pathCapacity = FindPath(source, sink, numVertices);
                if (pathCapacity > 0)
                    augPathFound = true;

                result += pathCapacity;
            }

            return result;
        }