Skip to main content
  • Algorithms
  • Optimisation

Network flow: a powerful tool for modelling problems

From edge-disjoint paths to employee-project matching with bipartite graphs and max-flow-min-cost, network flow algorithms for real-world problems.

Nov 1, 2019By Armando
A metro ceiling of repeating triangles

Network flow is part of the graph theory toolbox, used to model transportation networks, scheduling, and resource matching. With today's libraries, a simple method call solves the optimisation, the hard part is modelling the problem correctly.

Worth repeating
The hard part is modelling the problem correctly.
01

From unique paths to bipartite matching

Given a graph, finding unique (edge-disjoint) paths from node i to j is solved by setting each edge capacity to 1 and running maximum flow. For node-disjoint paths, duplicate every node into k and k' with capacity-1 edges between them.

For employee-project matching: connect source to employees, employees to matching projects (based on skill requirements), and projects to sink. Set all edges to capacity 1. Maximum flow gives the optimal matching.

02

Extending with real-world constraints

Real problems have additional constraints: employee seniority ranks, project difficulty levels, budget limits. We modelled this with edge capacities equal to wages, source-to-worker edges based on simultaneous project capacity, and project-to-sink edges capped at project budget. Running max-flow-min-cost with networkx and filtering unsaturated edges gives budget-respecting assignments.

Want to work together

Project in mind?

Start with a conversation, or with the readiness check. Either way, you talk to the people who build it.