Resources

Thera are three main problem types of network flow problems:

Directed Graph

We’re using regular weighted directed graphs to solve network flow problems, for example flight routes or supply chains. A directed graph consists of:

  • A set of nodes (vertices) .
  • A set of arcs (directed edges) , where each arc is defined by a start node and terminal node . An edge is undirected, meaning travel is possible in both directions, an arc is directed.
  • For each arc or edge, a cost (weight) . The weight may be positive, zero, or negative.

Minimum Cost Flow Problem

The minimum cost flow problem is to find the cheapest way of sending a certain amount of flow through a network from supply nodes to demand nodes, while respecting capacity constraints on the arcs. On top of the directed graph , we define:

  • A net flow () for each node, , where :
    • : supply node (source)
    • : demand node (sink)
    • : transshipment node (intermediate node)
  • On each arc, a variable cost per transported unit, a maximum flow and a minimum flow .

We want to determine the flow on each arc such that supply nodes serve the demand nodes at minimum cost while respecting the flow capacity constraints.

Transportation Problem

A special case of the minimum cost flow problem , where supply nodes have a certain supply capacity and demand nodes have a certain demand requirement. The goal is to minimize transportation costs while satisfying supply and demand constraints.
An example for this is mapping study abroad requests to available slots at partner universities.

A cost matrix defines the cost of transporting goods from each supply node to each demand node. The problem can be solved using linear programming techniques.

Assignment Problem

A further constrained instance of the transportation problem. Here, each supply node can supply exactly one unit, and each demand node requires exactly one unit. The goal is to minimize the total assignment cost. Therefore, decisions are binary and the cost matrix is square.

Shortest Path Problem

Another special case of the minimum cost flow problem, where the objective is to find the shortest path from one source node to one destination node in a weighted directed graph. Here, each arc’s weight could be something like time, distance or environmental impact, and the goal is to minimize the total cost of traveling from the source to the destination. Decision variables are binary, indicating whether an arc is included in the path or not.

Solving the shortest path is explained in Path-Solvers.

Linear Program Representation

The objective is to minimize the cost of transporting flow through the network:

Path Solvers

Dijkstra’s Algorithm

Dijkstra’s algorithm is a popular method for finding the shortest path from a source node to all other nodes in a weighted directed graph with non-negative edge weights. It works by iteratively selecting the node with the smallest tentative distance from the source and updating the distances of its neighbors. We use these data structures:

  • : array of distances from node to each node; is the current shortest distance from to
  • : array to store the predecessor of each node in the shortest path; is the predecessor of node on the shortest path from
  • : set of “marked” nodes whose shortest distance from is known; a node is added when a path from has been found and removed when the shortest path from has been finalized.

Initialization
is initialized with infinity for all nodes except the source node , which is set to 0. The predecessor array is initialized with null values. M is initialized with the starting node only.

Iteration
While is not empty, the node with the smallest distance in is selected from and removed from it. For each neighbor (nodes with an arc from the current node), we check if the distance to that neighbor can be improved by going through the current node. If so, we update the distance and set the predecessor accordingly. The neighbor is then added to if it is not already present.

Termination
Once all nodes have been processed (i.e., is empty), the algorithm terminates. The array contains the shortest distances from the source node to all other nodes, and the array can be used to reconstruct the shortest paths. Therefore, the shortest path from the source to any node can be found by backtracking through the predecessor array starting from the target node.

If only the shortest path to a specific target node is needed, the algorithm can terminate early once is removed from .

Floyd-Warshall Algorithm

Contrary to the Dijkstra’s algorithm, the Floyd-Warshall algorithm can handle negative edge weights and finds the shortest paths between all pairs of nodes in a weighted directed graph. It uses dynamic programming to iteratively improve the estimates of the shortest paths by considering intermediate nodes.

It uses two n x n matrices:

  • : distance matrix where represents the shortest distance from node to node .
  • : predecessor matrix where stores the predecessor of node on the shortest path from node .

Initialization
is initialized such that is the weight of the edge from node to node if it exists, and infinity otherwise. The diagonal elements are 0 (distance to self). The predecessor matrix is initialized such that if there is an edge from to , and null otherwise.

Iteration
For each node in the graph, we consider it as an intermediate node and update the distance matrix by checking if the path from any neighboring node to another neighboring node through is shorter than the current known distance. If it is, we update to and set to .

Nodes can be selected in any order. The iterations continue until all nodes have been considered as intermediate nodes.

Minimum Spending Tree Problem

The minimum spanning tree problem is to find a subset of edges in an undirected weighted graph that connects all the nodes together without any cycles and with the minimum possible total edge weight. This is used for example in designing cost-efficient networks like electricity or communication networks.

Tree

A connected graph (graph where all nodes are connected) with no cycles. A tree with nodes has exactly edges. Nodes without children are called leaves. The root is the topmost node in a tree.

Like other problems, the minimum spending tree problem can be formulated as a mixed integer linear program. However, this is inefficient, and irrelevant for this course.

Kruskal’s Algorithm

Initialization
First, all edges are sorted in increasing order based on their weights. If two edges have the same weight, they are ordered by their start and end nodes.

Iteration
Starting with an empty tree, we iterate through the sorted edges and add each edge to the tree if it does not create a cycle. This is typically done using a union-find data structure to efficiently check for cycles. If adding an edge would create a cycle, it is skipped.

The process continues until we have added edges to the tree, where is the number of nodes in the graph. Finally, the weights of the edges in the minimum spanning tree are summed to get the total cost.

Table Format

When performed manually, Kruskal’s algorithm can be organized in a table format:

Maximum Flow Problem

The maximum flow problem is to find the maximum possible flow from a source node to a sink node in a directed graph, while respecting the capacity constraints on the arcs. This is used in various applications, such as network routing, supply chain management, and project scheduling.

Linear Program Representation

The objective is to maximize the flow from the source node to the sink node , while respecting the flow conservation and capacity constraints:

Ford-Fulkerson Algorithm

The Ford-Fulkerson algorithm is a method for computing the maximum flow in a flow network. It works by repeatedly finding augmenting paths from the source to the sink and increasing the flow along these paths until no more augmenting paths can be found.

Augmenting Path

A path that is either:

  • Non-full forward edges (edges where the current flow is less than the capacity).
  • Non-empty backward edges (edges where the current flow is greater than zero, allowing flow to be reduced).

Initialization
Start with an initial flow of 0 on all edges in the network.

Iteration
In each iteration, the algorithm looks for an augmenting path: a forward path that still has capacity, or a backward path where capacity can be reduced. This can be done using depth-first search (DFS) or breadth-first search (BFS).

Once an augmenting path is found, the algorithm determines the maximum amount of flow that can be added along this path (the bottleneck capacity). This is the minimum residual capacity of the edges in the path. The flow is then updated by increasing the flow on the forward edges and decreasing it on the backward edges (and forward edges in the residual graph) along the path.

The process continues until no more augmenting paths can be found from the source to the sink. At this point, the flow value represents the maximum flow in the network.

Table Format

When performed manually, the Ford-Fulkerson algorithm can be organized in a table format:

Minimum Cut Problem

A cut divides a set of nodes into two subsets, such that one subset contains the source node and the other subset contains the sink node. The minimum cut problem is to find the cut with the smallest total capacity of edges crossing the cut, which represents the bottleneck in the network. In other words, it identifies the edges that, if removed, would disconnect the source from the sink with the least total capacity.

Capacity of a Cut

A cut’s capacity is the sum of the capacities of all edges that cross from the source side to the sink side of the cut, minus the sum of the capacities of edges crossing back from the sink side to the source side.

Relation to Maximum Flow Problem

The minimum cut problem is the dual problem to the maximum flow problem. It seeks to find the minimum capacity that, when removed, would disconnect the source from the sink in a flow network. The value of the maximum flow is equal to the capacity of the minimum cut, as stated by the max-flow min-cut theorem.

  • Max Flow: Calculating the highest rate at which material can move through the network from source to sink.
  • Min Cut: Finding the bottleneck in the system—the set of edges with the smallest total capacity that, if removed, would completely disconnect the source from the sink.

Therefore, the duality properties (weak and strong) apply, and .