Shortest Path: LP Formulation

Formulate the shortest path problem on a directed graph as a linear program: set up the decision variables and objective, write the per-node flow conservation constraints, and express the LP in compact matrix form using the node-arc incidence matrix.

Step 1 of 157%

Tutorial

Decision Variables and Objective

Given a directed graph G=(N,A)G = (N, A) with a cost cijc_{ij} on each arc (i,j)A,(i,j) \in A, the shortest path problem asks for a minimum-cost path from a source node ss to a sink node t.t.

We model this as a linear program by sending one unit of flow from ss to t.t. For each arc (i,j)A,(i,j) \in A, introduce a decision variable

xij0x_{ij} \geq 0

representing the amount of flow on arc (i,j).(i,j). The total cost of the flow is

(i,j)Acijxij,\sum_{(i,j)\in A} c_{ij}\, x_{ij},

and this is the quantity we minimize.

For example, consider a network with nodes {1,2,3}\{1, 2, 3\} and arcs (1,2),(1,3),(2,3),(1,2),\,(1,3),\,(2,3), with costs c12=4,c_{12} = 4, c13=9,c_{13} = 9, c23=2.c_{23} = 2. Taking s=1s = 1 and t=3,t = 3, the objective is

min    4x12+9x13+2x23.\min \;\; 4 x_{12} + 9 x_{13} + 2 x_{23}.

This objective alone is not enough. Without constraints, x=0\mathbf{x} = \mathbf{0} gives cost 00 at zero flow. We need constraints that force one unit of flow to travel from ss to t.t. Those come next.

navigate · Enter open · Esc close · ⌘K/Ctrl K toggle