Skip to content

Add Successive Shortest Path algorithm for Min-Cost Flow#1349

Merged
fabratu merged 39 commits intonetworkit:masterfrom
Schwarf:feature/min_flow_shortest_successive_path
Oct 6, 2025
Merged

Add Successive Shortest Path algorithm for Min-Cost Flow#1349
fabratu merged 39 commits intonetworkit:masterfrom
Schwarf:feature/min_flow_shortest_successive_path

Conversation

@Schwarf
Copy link
Copy Markdown
Contributor

@Schwarf Schwarf commented Sep 10, 2025

Description
This PR introduces an implementation of the Successive Shortest Path (SSP) algorithm for solving the Minimum-Cost Flow problem.

  • Implements SuccessiveShortestPathMinCostFlow class
  • Validates graph requirements: directed, weighted, indexed edges, existing capacity and supply attributes
  • Ensures correctness with input checks (non-negative capacities, zero total supply/demand)
  • Computes node potentials via Bellman–Ford for reduced costs
  • Augments flow iteratively along shortest paths using residual graph updates

Provides APIs to:

  • Run the algorithm (run())
  • Retrieve total flow cost (getTotalCost())
  • Retrieve computed flow (getFlow())

@Schwarf Schwarf force-pushed the feature/min_flow_shortest_successive_path branch from 46c3647 to 58a08bb Compare September 10, 2025 19:34
@Schwarf Schwarf force-pushed the feature/min_flow_shortest_successive_path branch from 58a08bb to 4a348ec Compare September 10, 2025 19:35
@Schwarf
Copy link
Copy Markdown
Contributor Author

Schwarf commented Sep 10, 2025

@fabratu
Copy link
Copy Markdown
Member

fabratu commented Sep 11, 2025

Hi @fabratu, not sure what the problem is: https://github.com/networkit/networkit/actions/runs/17624848896/job/50079028229?pr=1349 Do you have an idea? Thanks in advance.

Yes, due to a new version of the macos toolkit, the deployment target of the wheel must be adjusted accordingly. We can ignore this error here, it is fixed in #1347.

solver.run();
EXPECT_DOUBLE_EQ(solver.getTotalCost(), 0.0);
const auto flow = solver.getFlow();
EXPECT_EQ(flow.size(), 0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
EXPECT_EQ(flow.size(), 0);
`EXPECT_THAT(flow, testing::IsEmpty());`

Copy link
Copy Markdown
Contributor Author

@Schwarf Schwarf Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NetworKit::Attribute doesn’t define empty(), but it does define size(). So I’ll use EXPECT_THAT(flow, ::testing::SizeIs(0));.

@Schwarf Schwarf requested a review from angriman October 3, 2025 13:15
angriman
angriman previously approved these changes Oct 4, 2025
@fabratu
Copy link
Copy Markdown
Member

fabratu commented Oct 6, 2025

Thanks for the contribution and review!

The main review is older than 7 days, and all findings are addressed properly without any major discussions. Will merge this now.

@fabratu fabratu merged commit 8dc4f68 into networkit:master Oct 6, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants