Graph optimisation
Đã giới thiệu
Từ vựng
| English | Ý nghĩa |
|---|---|
| cuts | Partitions of a graph's vertex set into two groups. |
| Kruskal | A minimum-spanning-tree algorithm adding edges in increasing weight order while avoiding cycles. |
English
Light edges across cuts
- A cut partitions the vertices; the lightest edge crossing it is safe to accept — the property behind Kruskal (sort, accept, reject cycles) and Dijkstra's settle step.

{exercise:uni-cs1005-cut}
Luyện tập
The light edge crossing a cut is —
Độ khó 1/5 · 100 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
Tree + light edge - cycle other edge keeps or lowers the weight.
English
Kruskal on the course graph
- Sorted: C–B 1, A–C 2, D–E 2, E–F 3, A–B 4, B–D 5, D–F 6, C–D 8, C–E 10. Accept C–B, A–C, D–E, E–F, B–D; reject the rest (cycles).
- The MST weight is $1+2+2+3+5 = 13$, suite-verified. The proof: any tree plus a light crossing edge, minus the cycle's other crossing edge, keeps or lowers the weight.
{exercise:uni-cs1005-kruskal}
Luyện tập
Kruskal on the course graph yields MST weight —
Độ khó 1/5 · 100 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
CB 1 + AC 2 + DE 2 + EF 3 + BD 5 = 13.
English
Negative edges
- Dijkstra settles a node and never reconsiders: on A→B (5), A→C (1), C→B (1), settling B at 5 misses the path of 2.
- The light-edge guarantee needs non-negative weights; with negatives, Bellman-Ford's $\Theta(VE)$ relaxation rounds are the honest tool — and they detect negative cycles.
{exercise:uni-cs1005-negative}
Luyện tập
With edges A-B 5, A-C 1, C-B 1, settling-nearest Dijkstra fixes B at —
Độ khó 1/5 · 100 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
B settles before C relaxes it: 5 - the path of 2 through C is missed; use Bellman-Ford.