Daniel Sutantyo, Department of Computing, Macquarie University
8.1 - Single-Source Shortest Path
8.1 - Single-Source Shortest Path
8.1 - Single-Source Shortest Path
8.1 - Single-Source Shortest Path
ShortestPath(\(u\),\(v\))
ShortestPath(\(y_1\),\(v\))
ShortestPath(\(y_2\),\(v\))
ShortestPath(\(y_\ell\),\(v\))
\(\dots\)
where the vertices \(y_i\), \(1 \le i \le \ell\), are all the other vertices in the graph
8.1 - Single-Source Shortest Path
ShortestPath(\(u\),\(v\))
\(w(u,y_1)\) + ShortestPath(\(y_1\),\(v\))
\(w(u,v)\)
\(\dots\)
\[\text{ShortestPath}(u,v) = \begin{cases} \displaystyle \min\left(w(u,v),\min_{1 \le i \le \ell} \left(w(u,y_i) + \text{ShortestPath}(y_i,v)\right)\right) & \text{if $u \ne v$} \\ 0 &\text{if $u = v$} \end{cases}\]
\(w(u,y_2)\) +ShortestPath(\(y_2\),\(v\))
\(w(u,y_\ell)\) +ShortestPath(\(y_\ell\),\(v\))
8.1 - Single-Source Shortest Path
ShortestPath(\(u\),\(v\))
\(w(u,y_1)\) + ShortestPath(\(y_1\),\(v\))
\(w(u,v)\)
\(\dots\)
\[\text{ShortestPath}(u,v) = \begin{cases} \displaystyle \min\left(w(u,v),\min_{1 \le i \le \ell} \left(w(u,y_i) + \text{ShortestPath}(y_i,v)\right)\right) & \text{if $u \ne v$} \\ 0 &\text{if $u = v$} \end{cases}\]
\(w(u,y_2)\) +ShortestPath(\(y_2\),\(v\))
\(w(u,y_\ell)\) +ShortestPath(\(y_\ell\),\(v\))
8.1 - Single-Source Shortest Path
ShortestPath(\(u\),\(v\))
\(w(u,y_1)\) + ShortestPath(\(y_1\),\(v\))
\(w(u,v)\)
\(\dots\)
\(w(u,y_2)\) +ShortestPath(\(y_2\),\(v\))
\(w(u,y_\ell)\) +ShortestPath(\(y_\ell\),\(v\))
8.1 - Single-Source Shortest Path
\(u\)
\(v\)
\(x_i\)
\(x_j\)
\(\cdots\)
\(\cdots\)
\(\cdots\)
\(\cdots\)
8.1 - Single-Source Shortest Path
5
2
1
4
3
4
8
3
1
2
5
9
1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
0 | 4 | inf | inf | 8 |
8.1 - Single-Source Shortest Path
5
2
1
4
3
4
8
3
1
2
5
9
1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
0 | 4 | inf | inf | 8 |
\(S = \{1,2\}\)
8.1 - Single-Source Shortest Path
5
2
1
4
3
4
8
3
1
2
5
9
1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
0 | 4 | inf | 13 | 7 |
\(S = \{1,2\}\)
8.1 - Single-Source Shortest Path
5
2
1
4
3
4
8
3
1
2
5
9
1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
0 | 4 | inf | 8 | 7 |
\(S = \{1,2,5\}\)
8.1 - Single-Source Shortest Path
5
2
1
4
3
4
8
3
1
2
5
9
1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
0 | 4 | 13 | 8 | 7 |
\(S = \{1,2,5,4\}\)
8.1 - Single-Source Shortest Path
8.1 - Single-Source Shortest Path
5
2
1
4
3
4
2
-5
6
7
-5
9
8.1 - Single-Source Shortest Path
1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
0 | 4 | inf | inf | 2 |
\(S = \{1,5\}\)
5
2
1
4
3
4
2
-5
6
7
-5
9
8.1 - Single-Source Shortest Path
1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
0 | 4 | inf | 8 | 2 |
\(S = \{1,5\}\)
5
2
1
4
3
4
2
-5
6
7
-5
9
8.1 - Single-Source Shortest Path
1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
0 | 4 | inf | 8 | 2 |
\(S = \{1,5,2\}\)
5
2
1
4
3
4
2
-5
6
7
-5
9
8.1 - Single-Source Shortest Path
1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
0 | 4 | 3 | 8 | 2 |
\(S = \{1,5,2,4\}\)
5
2
1
4
3
4
2
-5
6
7
-5
9
8.1 - Single-Source Shortest Path
1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
0 | 4 | 0 | 5 | -1 |
5
2
1
4
3
4
2
-5
6
7
-5
9
1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
0 | 4 | 3 | 8 | 2 |
\(S = \{1,5,2,4\}\)
8.1 - Single-Source Shortest Path
1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
0 | ? | ? | ? | ? |
5
2
1
4
3
4
2
-5
-6
7
-5
9
8.1 - Single-Source Shortest Path
1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|
0 | -5 | ? | ? | ? |
5
2
1
4
3
4
2
-5
-6
7
-5
9
8.1 - Single-Source Shortest Path
8.1 - Single-Source Shortest Path
\(u\)
\(v\)
\(x_i\)
\(\cdots\)
\(\cdots\)
\(\cdots\)
\(\cdots\)
\(\cdots\)
8.1 - Single-Source Shortest Path
8.1 - Single-Source Shortest Path
m
u
4
10
1
n
8.1 - Single-Source Shortest Path