REPOSITORY CODING · MEDIUM
Preserve independent parallel capacities
Two independently identified edges between the same nodes must both contribute capacity and retain their own costs. Endpoint identity is not an edge identity.
Residual network optimizationFlow network optimizer
Work through a real codebase.
Choose an environment, investigate the existing implementation and use the tests to check your change. Sign in to open a workspace; execution and Ono usage follow your plan’s allowances.
Task requirements and environments
PHP · 55 minute session
- Solve bounded directed networks offline with 2..8 uniquely named nodes and at most 20 uniquely identified edges. Source and sink must be distinct known nodes. Parallel edges and opposite directed edges are independent. Original capacities and costs are integers 0..1000; self-edges are rejected.
- Return maximum flow, the minimum total cost among all maximum flows, a residual minimum-cut node list and cutCapacity. Compute residual reverse capacities and negative reverse costs so previously chosen paths can be rerouted. Costs are exact integers; do not substitute hop counts for edge costs.
- Optional nodeCaps limits total throughput, including source and sink. Split each named node into in/out vertices with its capacity on the internal arc; unspecified capacity is sum(original edge capacities)+1. Reject nodeCaps entries naming unknown nodes.
- The cut lists original node names whose in-vertex is reachable from source.in in the final maximum-flow residual graph, sorted lexically. cutCapacity sums initial capacities of all forward arcs crossing that expanded-graph partition, including node-capacity arcs. It equals maximum flow even when the named node cut alone cannot express a vertex split.
- Use fresh graphs for maximum-flow and minimum-cost calculations. Return {ok:true,value:{flow,cost,cut,cutCapacity}} or a stable validation error. PHP and Symfony share domain modules and expose the same native CLI, preview and public grading command.
Symfony · 55 minute session
- Solve bounded directed networks offline with 2..8 uniquely named nodes and at most 20 uniquely identified edges. Source and sink must be distinct known nodes. Parallel edges and opposite directed edges are independent. Original capacities and costs are integers 0..1000; self-edges are rejected.
- Return maximum flow, the minimum total cost among all maximum flows, a residual minimum-cut node list and cutCapacity. Compute residual reverse capacities and negative reverse costs so previously chosen paths can be rerouted. Costs are exact integers; do not substitute hop counts for edge costs.
- Optional nodeCaps limits total throughput, including source and sink. Split each named node into in/out vertices with its capacity on the internal arc; unspecified capacity is sum(original edge capacities)+1. Reject nodeCaps entries naming unknown nodes.
- The cut lists original node names whose in-vertex is reachable from source.in in the final maximum-flow residual graph, sorted lexically. cutCapacity sums initial capacities of all forward arcs crossing that expanded-graph partition, including node-capacity arcs. It equals maximum flow even when the named node cut alone cannot express a vertex split.
- Use fresh graphs for maximum-flow and minimum-cost calculations. Return {ok:true,value:{flow,cost,cut,cutCapacity}} or a stable validation error. PHP and Symfony share domain modules and expose the same native CLI, preview and public grading command.