DSA Explorer
QuicksortMerge SortBubble SortInsertion SortSelection SortHeap SortCounting SortRadix SortBucket SortShell SortTim SortCocktail Shaker SortComb SortGnome SortPancake SortPatience SortCycle SortStrand SortWiggle Sort (Wave Sort)Bead Sort (Gravity Sort)Binary Insertion SortBitonic SortBogo Sort (Stupid Sort)Stooge SortOdd-Even Sort (Brick Sort)Pigeonhole SortIntro Sort (Introspective Sort)Tree Sort (BST Sort)Dutch National Flag (3-Way Partitioning)
Binary SearchLinear SearchJump SearchInterpolation SearchExponential SearchTernary SearchFibonacci SearchQuick Select (k-th Smallest)Median of Medians (Deterministic Select)Hill climbingSimulated AnnealingTabu SearchBinary Tree DFS SearchSentinel Linear SearchDouble Linear SearchTernary Search (Unimodal Function)Search in 2D Matrix
Binary Search Tree (BST)StackQueueHash Table (Hash Map)Heap (Priority Queue)Linked ListTrie (Prefix Tree)Binary TreeTrie (Prefix Tree)Floyd's Cycle Detection (Tortoise and Hare)Merge Two Sorted Linked ListsCheck if Linked List is PalindromeFind Middle of Linked ListBalanced Parentheses (Valid Parentheses)Next Greater ElementInfix to Postfix ConversionMin Stack (O(1) getMin)Largest Rectangle in HistogramDaily Temperatures (Monotonic Stack)Evaluate Reverse Polish NotationInfix Expression Evaluation (Two Stacks)Min Heap & Max HeapSliding Window MaximumTrapping Rain WaterRotate Matrix 90 DegreesSpiral Matrix TraversalSet Matrix ZeroesHash Table with ChainingOpen Addressing (Linear Probing)Double HashingCuckoo Hashing
Depth-First Search (DFS)Breadth-First Search (BFS)Dijkstra's AlgorithmFloyd-Warshall AlgorithmKruskal's AlgorithmPrim's AlgorithmTopological SortA* Pathfinding AlgorithmKahn's Algorithm (Topological Sort)Ford-Fulkerson Max FlowEulerian Path/CircuitBipartite Graph CheckBorůvka's Algorithm (MST)Bidirectional DijkstraPageRank AlgorithmBellman-Ford AlgorithmTarjan's Strongly Connected ComponentsArticulation Points (Cut Vertices)Find Bridges (Cut Edges)Articulation Points (Cut Vertices)Finding Bridges (Cut Edges)
0/1 Knapsack ProblemLongest Common Subsequence (LCS)Edit Distance (Levenshtein Distance)Longest Increasing Subsequence (LIS)Coin Change ProblemFibonacci Sequence (DP)Matrix Chain MultiplicationRod Cutting ProblemPalindrome Partitioning (Min Cuts)Subset Sum ProblemWord Break ProblemLongest Palindromic SubsequenceMaximal Square in MatrixInterleaving StringEgg Drop ProblemUnique Paths in GridCoin Change II (Count Ways)Decode WaysWildcard Pattern MatchingRegular Expression MatchingDistinct SubsequencesMaximum Product SubarrayHouse RobberClimbing StairsPartition Equal Subset SumKadane's Algorithm (Maximum Subarray)
A* Search AlgorithmConvex Hull (Graham Scan)Line Segment IntersectionCaesar CipherVigenère CipherRSA EncryptionHuffman CompressionRun-Length Encoding (RLE)Lempel-Ziv-Welch (LZW)Canny Edge DetectionGaussian Blur FilterSobel Edge FilterHarris Corner DetectionHistogram EqualizationMedian FilterLaplacian FilterMorphological ErosionMorphological DilationImage Thresholding (Otsu's Method)Conway's Game of LifeLangton's AntRule 30 Cellular AutomatonFast Fourier Transform (FFT)Butterworth FilterSpectrogram (STFT)
Knuth-Morris-Pratt (KMP) AlgorithmRabin-Karp AlgorithmBoyer-Moore AlgorithmAho-Corasick AlgorithmManacher's AlgorithmSuffix ArraySuffix Tree (Ukkonen's Algorithm)Trie for String MatchingEdit Distance for StringsLCS for String MatchingHamming DistanceJaro-Winkler DistanceDamerau-Levenshtein DistanceBitap Algorithm (Shift-Or, Baeza-Yates-Gonnet)Rolling Hash (Rabin-Karp Hash)Manacher's AlgorithmZ AlgorithmLevenshtein Distance

Ford-Fulkerson Max Flow

Graph
O(E×max_flow) or O(VE²) with BFS time, O(V²) space
Advanced

Compute maximum flow in network from source to sink. Ford-Fulkerson method finds augmenting paths until none exist. Edmonds-Karp implementation uses BFS for O(VE²) complexity. Fundamental algorithm in network optimization, matching problems, and resource allocation.

Prerequisites:
Graph theory
BFS/DFS
Network flow concepts

Visualization

Interactive visualization for Ford-Fulkerson Max Flow

Edges (capacity / flow):

  • 0 → 1: 0 / 10
  • 0 → 2: 0 / 5
  • 1 → 2: 0 / 15
  • 1 → 3: 0 / 10
  • 2 → 3: 0 / 10
Maximum Flow from 0 to 3: 0

Interactive visualization with step-by-step execution

Implementation

Language:
1function fordFulkerson(graph: number[][], source: number, sink: number): number {
2  const n = graph.length;
3  const residual = graph.map(row => [...row]);
4  let maxFlow = 0;
5  
6  function bfs(): number[] | null {
7    const visited = new Array(n).fill(false);
8    const parent = new Array(n).fill(-1);
9    const queue = [source];
10    visited[source] = true;
11    
12    while (queue.length > 0) {
13      const u = queue.shift()!;
14      
15      for (let v = 0; v < n; v++) {
16        if (!visited[v] && residual[u][v] > 0) {
17          visited[v] = true;
18          parent[v] = u;
19          queue.push(v);
20          
21          if (v === sink) return parent;
22        }
23      }
24    }
25    return null;
26  }
27  
28  let parent: number[] | null;
29  while ((parent = bfs()) !== null) {
30    let pathFlow = Infinity;
31    
32    for (let v = sink; v !== source; v = parent[v]) {
33      const u = parent[v];
34      pathFlow = Math.min(pathFlow, residual[u][v]);
35    }
36    
37    for (let v = sink; v !== source; v = parent[v]) {
38      const u = parent[v];
39      residual[u][v] -= pathFlow;
40      residual[v][u] += pathFlow;
41    }
42    
43    maxFlow += pathFlow;
44  }
45  
46  return maxFlow;
47}

Deep Dive

Theoretical Foundation

Ford-Fulkerson method computes maximum flow in a flow network by finding augmenting paths from source to sink and pushing flow along them until no more paths exist. The algorithm maintains a residual graph showing remaining capacity on each edge. For each augmenting path found, it determines the bottleneck (minimum capacity along path) and augments flow by this amount. The residual graph is updated: forward edges decrease by flow amount, backward edges increase (allowing flow reversal). Edmonds-Karp uses BFS to find shortest augmenting paths, guaranteeing O(VE²) time. The Max-Flow Min-Cut theorem states that maximum flow equals minimum cut capacity.

Complexity

Time

Best

O(VE²) with BFS

Average

O(VE²)

Worst

O(E×max_flow)

Space

Required

O(V²)

Applications

Industry Use

1

Network routing and bandwidth allocation

2

Bipartite matching (marriage problem, job assignment)

3

Supply chain optimization

4

Image segmentation (min-cut for foreground/background)

5

Airline crew scheduling

6

Traffic flow optimization in transportation

7

Resource allocation in project management

8

Circulation problems in logistics

Use Cases

Network flow
Bipartite matching
Circulation problems

Related Algorithms

Depth-First Search (DFS)

Graph traversal exploring as deep as possible before backtracking. DFS is a fundamental algorithm that uses a stack (either implicitly through recursion or explicitly) to explore graph vertices. It's essential for cycle detection, topological sorting, and pathfinding problems.

Graph

Breadth-First Search (BFS)

Level-by-level graph traversal guaranteeing shortest paths in unweighted graphs. BFS uses a queue to explore vertices level by level, making it optimal for finding shortest paths and solving problems that require exploring nearest neighbors first.

Graph

Dijkstra's Algorithm

Finds shortest path from source to all vertices in weighted graph with non-negative edges. Uses greedy approach with priority queue.

Graph

Floyd-Warshall Algorithm

Floyd-Warshall is an all-pairs shortest path algorithm that finds shortest distances between every pair of vertices in a weighted graph. Unlike Dijkstra (single-source), it computes shortest paths from all vertices to all other vertices simultaneously. The algorithm can handle negative edge weights but not negative cycles. Developed independently by Robert Floyd, Bernard Roy, and Stephen Warshall in the early 1960s.

Graph
DSA Explorer

Master Data Structures and Algorithms through interactive visualizations and detailed explanations. Our platform helps you understand complex concepts with clear examples and real-world applications.

Quick Links

  • About DSA Explorer
  • All Algorithms
  • Data Structures
  • Contact Support

Legal

  • Privacy Policy
  • Terms of Service
  • Cookie Policy
  • Code of Conduct

Stay Updated

Subscribe to our newsletter for the latest algorithm explanations, coding challenges, and platform updates.

We respect your privacy. Unsubscribe at any time.

© 2026 Momin Studio. All rights reserved.

SitemapAccessibility
v1.0.0