Skip to main content

Overview

The Max Flow algorithm computes the maximum amount of flow that can be routed through a directed, weighted graph from one or more source nodes to one or more sink (target) nodes. Edge weights represent capacities — the upper bound on how much flow an edge can carry. Max Flow is commonly applied in scenarios such as:
  • Network throughput optimization (bandwidth, pipelines, logistics)
  • Traffic routing and congestion analysis
  • Supply chain and distribution planning
  • Bipartite matching and scheduling problems

Algorithm Details

The procedure implements a capacity-scaling max-flow algorithm over the subgraph induced by the specified node labels and relationship types. It builds a residual graph from the selected edges (using the configured capacity property), then repeatedly finds augmenting paths from the source super-node to the sink super-node and pushes flow along them until no augmenting path exists. Multiple source or sink nodes are supported by introducing a virtual super-source connected to every source node, and a virtual super-sink connected from every sink node, each with infinite capacity. The algorithm returns the set of nodes and edges that carry positive flow, together with the per-edge flow values and the total maximum flow.

Performance

The algorithm operates with a time complexity of O(V · E²), where:
  • |V| represents the total number of nodes in the subgraph
  • |E| represents the total number of edges in the subgraph
For sparse graphs this is typically much faster in practice.

Syntax

Parameters

The procedure accepts a required configuration Map with the following parameters:

Return Values

The procedure yields a single record with the following fields:

Examples

Consider this pipeline network:
Node A is the source, node C is the sink. There are two routes from A to C:
  • A → C directly, with capacity 5
  • A → B → C, with a bottleneck of 8 (min of 10 and 8)
The maximum flow is therefore 13.

Create the Graph

Example: Compute the maximum flow between two nodes

Expected Results

Example: Inspect per-edge flow on the solution

Expected Results

Example: Restrict the subgraph by node label

When the graph contains multiple node labels, use nodeLabels to limit the algorithm to a specific subset of nodes:

Example: Multiple sources and multiple sinks

sourceNodes and targetNodes each accept arrays, allowing multi-commodity-style problems to be modelled with virtual super-nodes: