Definition (Reachability)
We say vertex is reachable from if there is a Walk from to .
Theorem (Connected Components)
For any , you can partition vertices into its connected components such that given , is reachable from if it is in the same connected component.
Proof: This proof comes from the idea that connectivity is an equivalence relation.
- is reachable from , so it is reflexive
- if is from reachable from , then is reachable from , so it is symmetric.
- If is reachable from , and to , then there is a walk from to , and thus reachable. It is transitive.
Thus, we can say that each connected component is an equivalence class. This gives us a formal way to partition into equivalence classes, such that are related iff they are in the same class.
graph LR u((u)) o--o mn[[many vertices]]; mn o--o v((v))
Lemma (Odd Loops, Odd Cycle)
If has a loop of odd length, it has a cycle of odd length.
Proof: If there are no repeated vertices, then it is automatically a cycle. Suppose not. Consider
graph LR; v((v)) o--P1--o w((w)); v o--P3--o w; w o--P2--o w;
where are walks and is our repeated vertex. We have two loops, and . Since is odd, either at least one is odd or all are odd. If is odd, we can repeat the process and obtain an odd cycle.
If the sole odd walk is xor , we are done.
We use loop here to mean “a walk that starts and ends at the same vertex, but may repeat edges/vertices.”
Theorem (Bipartite Cycles)
Graph is bipartite iff it contains no odd length Cycle.
Proof: Suppose we have some cycle of length that is odd, such that is our cycle. WLOG, if is white, is black. In general, all odd vertices are white, and all even vertices are black. But then is odd and so it is white. But then our edge is invalid (white to white), and so it cannot be bipartite.
WTS that
Assume is connected and has no odd cycles. Pick some vertex in this partition. We pick another in this partition, and as it is connected there exists a Walk . If is even, then let be white. If is odd, let be black.
We can have many paths. I claim that all paths will have even length or odd length. Suppose by contradiction that we have two walks, one with even and odd path.
graph LR; u((u)) o--o p1[[even path]]; u o--o p2[[odd path]]; p1 o--o v((v)); p2 o--o v;
But then we have a loop of odd length as . Note that this is a loop because the odd path may use some of the vertices in the even path.
Using Lemma (Odd Loops, Odd Cycle), the odd path gives us an odd cycle. But this contradicts the premise that we have no odd cycles, and so all paths must be even or odd.
So if all paths from to are even, color white. We need to show that any edge, it must have different colors. WLOG, we color white if any path is even, and black if any path is odd.
Let be the path. Now consider path , of length . If was odd, then is even, then is black, and is white, and vice versa.
Since is arbitrary, every edge has different coloring, and the graph is bipartite.
If is not connected then we can split it to its connected components and repeat the process. Then each connected component is bipartite.
Definition (Bridge)
A bridge is an edge where if you removed it from the Graph, it would make the graph no longer connected (create one more connected component).