VictorXjoeY / Notebook

Notebook used for competitive programming!
11 stars 2 forks source link

Implement Min Cost (Max) Flow #12

Closed VictorXjoeY closed 4 years ago

VictorXjoeY commented 5 years ago

Will not be able to merge edges anymore, or at most merge only edges with the same cost per flow. So we should store in g[u] pairs (v, cost, capacity) instead of just (v, capacity).

Probably should run a SPFA/Bellman-Ford and then usa Dijkstra (same way as in Johnson's algorithm) so that we don't have to use SPFA/Bellman-Ford every iteration.

https://cp-algorithms.com/graph/min_cost_flow.html