Bellman-Ford cont.

Since we can have negative weights, there can be negative weight cycles:

graph LR
S-->A
A-->E
E-->B
B-->C
B-->|-11|A

What if we want to find the shortest path without negative weight cycles? This is similar to finding the longest path, which is an NP-incomplete problem.

Minimum Spanning Tree

Create an undirected graph with weights. How can we have the cheapest tree that connects all nodes?

Observation: Given $G(V,E,W)$ if $G$ is connected, then $|E| > |V| - 1$.

Therefore, $\log |E| = \Theta (\log n)$.

Let our graph $G$ where $W: E \to \mathbb{R}$.

Assume all weights are distinct.

Definition: A spanning tree $T$ is a tree on $n$ nodes and $n-1$ edges $\subseteq E$. $W(T) = \sum w(a,b)$

We can use a greedy algorithm that creates an “optimal substructure”.

Take any edge $(u,\,v) \in T$. $T$ is partitioned into $T_1$ and $T_2$. There are 3 types of edges: edges internal to $T_1$, ones to $T_2$ and ones between the two sets.

Consider some graph $G_1$ such that it includes the nodes in $T_1$ and edges internal to $T_1$.

So, $G_1$ is the subgraph induced by vertices in $T_1$ and subset of edges $(u,\,v)$ such that both $u$ and $v$ are in $T_1$.

$G_2$ similar.

Claim: $T_1$ is the MST of $G_1$ and $T_2$ is the MST of $G_2$.

Theorem: Let $T$ be some MST of $G(V,E)$. Let $A \subseteq V$. Suppose $(u,\,v)\in E$ is a minimum weight edge connection from $A$ to $\bar A$. Then $(u,\,v)$ must belong to the MST.

Proof: Assume the above theorem is wrong ($(u,\,v)$ does not belong to the MST). Then, there is some other way to get from $u$ to $v$ that is unique. Since $u$ is in $A$ and $v$ is in $\bar A$, there must be some edge crossing between $A$ and $\bar A$. Then, this edge is cheaper than $(u,\,v)$, so we arrive at a contradiction.

Claim: Any cutset (edges with only one vertex in $A$) and any cycle intersect in an even # of places.