I am trying to understand how LP formulaton for shortest path problem. However I'm having trouble understanding constrains. Why this formulation work?
http://ie.bilkent.edu.tr/~ie400/Lecture8.pdf
I am having trouble understanding how the constraints work at pages 15 and 17. I got the main idea and I understand how and why $x$ should take some values but I did not understand how the whole system works in terms of math. Can someone ELI5? In the exam, I am supposed to be able to create and modify such constraints but I am pretty far from doing that.
The variable $$x_{ij}= \begin{cases} 1 &\mbox{if the shortest path contains } i \to j,\\ 0 &\mbox{otherwise.} \end{cases}$$
In P.12, there's a formula for calculating the amount of flows at each single node $i$.
\begin{align} b(i) &= \mbox{Amount of outgoing flow from $i$} - \mbox{Amount of incoming flow to $i$} \\ &= \sum_j x_{ij} - \sum_k x_{ki} \end{align}
Since we're finding the minimum distance, an object will travel from the start until the end, and it won't disappear in the middle. Therefore, to simplify matters, we will assume that the amount of object is 1. If you draw a graph, you will realize that in the shortest path,
$$b(i) = \begin{cases} 1 &\mbox{if $i$ is the starting node,} \\ -1 &\mbox{if $i$ is the ending node,} \\ 0 &\mbox{otherwise.} \end{cases}$$
In P.15, at the start (node 1), there's no incoming flow, so $x_{j1} = 0 \;\forall j$, $x_{12} = 1$, and $x_{1j} = 0 \;\forall j \ne 2$. $s$ and $t$ denotes the indices for the source and the target respectively. In P.15, $s = 1$ and $t = 6$. The constraints are just the equations for $b(i)$ for each node $i$.
In P.17, there's $n \,(=6)$ nodes. We choose one of them to be the supplier (node 1), and all others are clients. We calculate the total shortest path. (i.e. We find the minimal distance from each path, and we sum them together, but we can just sum these $n-1$ paths up so as to formulate the problem as one single LPP.) Each client demands one object from the supplier, so $b(s) = n - 1$. I hope at this stage, you'll understand what is meant by "a demand of 1 unit at all other nodes" in the notes, and conclude that $b(i) = -1 \,\forall i \ne s$.