Single - Source SSP¶
Theorem¶
For a non - negative weighted graph, given vertices \(A\) and \(B \in S\), and any other vertex neighbor \(v \in S\) where the set \(S\) is the collection of all of the neighbor vertices of \(A\) in the graph. The \(\text{weight}(A,v)\) is the path weight directly from \(A\) to \(v\). We have:
Lemma: If \(\text{weight}(A,B)\) meets the condition for all \(v \in S\):
\[\text{weight}(A,B) \leq \text{weight}(A,v),\]
the global shortest path from \(A\) to \(B\) is the direct path from \(A\) to \(B\).
Tip
It can be improved to be Dijkstra’s Algorithm by replacing vertex \(A\) with the set \(S\).
Interface¶
Implement algorithms of BFS, dijkstra and xxxx in adjacency list graph.