-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbellman-ford.tex
More file actions
27 lines (24 loc) · 925 Bytes
/
bellman-ford.tex
File metadata and controls
27 lines (24 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
\frame{
\frametitle{Bellman-Ford}
\framesubtitle{Single source Shortest path}
\begin{itemize}[<+->]
\item Weighted graphs - with negative weights
\item Can detect negative weight cycles
\item No special datastructure needed
\item Keep the current minimal distance from the start to each node
\item $|V| - 1$ times:
\item Relax every edge\\
$dist[v] = min(dist[v], dist[u] + weight[u, v])$
\item After $|V| - 1$ iterations: every minimal distance from source found
\item $O(|V||E|)$
\end{itemize}
}
\frame{
\frametitle{Bellman-Ford}
\framesubtitle{Negative weight cycle detection}
\begin{itemize}[<+->]
\item Run the normal Bellman-Ford algorithm
\item Do one more iteration
\item If the iteration finds a shorter path $\Rightarrow$ a negative weight cycle was found
\end{itemize}
}