京都大学 情報学研究科 知能情報学専攻 2022年8月実施 情報学基礎 F2-1
Author
Isidore, 祭音Myyura
Description
Kai
(1)
- The shortest path is \((v_4, v_2, v_1, v_3)\)
- The distance is \(5\)
(2)
Assume that there is a cycle start and end at \(v_i\) in a shortest path \(p=(v_1, ..., v_i, ..., v_i, ...v_m)\) from \(v_1\) to \(v_m\). Then,
Since \(l(u,v) > 0\) for any edge \((u,v) \in E\), we have \(l(v_i, \ldots, v_i) > 0\). Thus, the path \(p' = (v_1...v_i...v_m)\) of weight
is shorter than \(p\), which leads to a contradiction with the assumption that \(p\) is a shortest path. Therefore, no shortest path contains a cycle.
(3)
Let \(p_{ijk}\) be a shortest path from vertex \(i\) to vertex \(j\) such that all intermediate are contained in \(\{1, \ldots, k\}\). By (2) we know that a shortest path does not contain the same vertex twice, hence there are two possibilities to construct \(p_{ijk}\).
- vertex \(k\) is not a vertex on the path, then we have \(l(p_{ijk}) = \delta (i, j, k-1)\).
- vertex \(k\) is a vertex on the path, then the path consists of a subpath from \(i\) to \(k\) and a subpath from \(k\) to \(j\). Each subpath can only contain intermediate vertices in \(\{1, \ldots , k-1\}\), and also shortest paths from \(i\) to \(k\) and \(k\) to \(j\) respectively (otherwise a shorter path from \(i\) to \(j\) can be constructed), namely they have lengths \(\delta(i, k, k-1)\) and \(\delta(k, j, k-1)\), respectively. Hence \(l(p_{ijk}) = \delta(i, k, k-1) + \delta(k, j, k-1)\).
Combining the two cases we have
(4)
(5)
By the formula proposed in (3), we have
which means the elements in the \(k\)-th row or the \(k\)-th column stays the same when deriving \(d^{(k)}\) from \(d^{(k-1)}\).
Hence we can derive each new value in-place. Thus, only one array is required.