This repository was archived by the owner on Jun 18, 2026. It is now read-only.
Commit d753d2e
committed
feat: add Network Flow Analyzer (Edmonds-Karp max flow)
Implements the Edmonds-Karp algorithm (BFS-based Ford-Fulkerson) for
computing maximum flow between any two vertices in the graph.
Features:
- compute(source, sink): returns max flow value using shortest
augmenting paths (O(V*E^2) time complexity)
- Treats undirected edges as bidirectional arcs with capacity
equal to edge weight (defaults to 1.0 for unweighted edges)
- getEdgeFlows(): per-edge flow assignments with net direction
- getFlowOnEdge(v1, v2): flow on specific edge
- getMinCut(): edges forming the minimum cut (max-flow min-cut
theorem), via BFS reachability in residual graph
- getSourceSide(): vertices reachable from source in residual
- getBottleneckEdges(): fully saturated edges (flow == capacity)
- getTotalCapacity(): sum of all edge capacities
- getUtilisation(): percentage of source capacity used
- decomposeFlowPaths(): decompose max flow into individual
source-to-sink paths with flow values
- getAugmentingPathCount(): number of flow paths found
- FlowResult: immutable result snapshot with all analytics
- getSummary(): formatted multi-line report with flow paths
and edge utilisation (marks saturated edges)
Applications: transportation capacity, communication bandwidth,
bipartite matching, supply chain optimization.
55 new tests covering: constructor validation, input validation,
simple/diamond/triangle/parallel/star/chain/complete graphs,
disconnected vertices, default weights, edge flows, min cut,
source side, bottleneck detection, capacity, utilisation,
flow decomposition, recomputation, flow conservation.1 parent ba7e65a commit d753d2e
2 files changed
Lines changed: 1309 additions & 0 deletions
0 commit comments