Skip to content
This repository was archived by the owner on Jun 18, 2026. It is now read-only.

refactor: extract duplicate BFS in NetworkFlowAnalyzer - #79

Merged
sauravbhattacharya001 merged 1 commit into
masterfrom
gardener/refactor-network-flow-analyzer
Mar 15, 2026
Merged

sauravbhattacharya001 merged 1 commit into
masterfrom
gardener/refactor-network-flow-analyzer

Conversation

@sauravbhattacharya001

Copy link
Copy Markdown
Owner

Problem:
\getMinCut()\ and \getSourceSide()\ both contained identical 15-line BFS traversals to find vertices reachable from source in the residual graph. Additionally, \getSummary()\ and \getResult()\ called \decomposeFlowPaths(), \getMinCut(), and \getBottleneckEdges()\ independently — each triggering separate graph traversals.

Changes:

  • Extract \ indReachableFromSource()\ private method (single BFS implementation)
  • \getMinCut()\ and \getSourceSide()\ now delegate to it
  • \getSummary()\ computes expensive results once, reuses across the method
  • \getResult()\ same — single computation of paths/minCut/bottlenecks

Impact: No behavioral changes. All 52 existing tests remain valid. Reduces code duplication and avoids redundant O(V+E) traversals.

…ant computation

The getMinCut() and getSourceSide() methods both contained identical
BFS traversals to find vertices reachable from source in the residual
graph. Extracted into a single findReachableFromSource() private method.

Also fixed getSummary() and getResult() which were calling
decomposeFlowPaths(), getMinCut(), and getBottleneckEdges()
independently — each triggering their own traversals. Now each method
computes these expensive results once and reuses them.

Changes:
- New private findReachableFromSource() method (single BFS)
- getMinCut() delegates to findReachableFromSource()
- getSourceSide() delegates to findReachableFromSource()
- getSummary() computes paths/minCut/bottlenecks once, reuses
- getResult() computes paths/minCut/bottlenecks once, reuses

No behavioral changes — all 52 existing tests remain valid.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sauravbhattacharya001
sauravbhattacharya001 merged commit 351f39f into master Mar 15, 2026
3 of 7 checks passed
@sauravbhattacharya001
sauravbhattacharya001 deleted the gardener/refactor-network-flow-analyzer branch March 15, 2026 07:40
@github-actions github-actions Bot added visualization Graph visualization and UI size/m labels Mar 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size/m visualization Graph visualization and UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant