Graph optimisation
مُقدَّم
مفردات
| English | المعنى |
|---|---|
| cuts | cuts |
| Kruskal | Kruskal |
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}
تدريب
The light edge crossing a cut is —
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
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}
تدريب
Kruskal on the course graph yields MST weight —
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
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}
تدريب
With edges A-B 5, A-C 1, C-B 1, settling-nearest Dijkstra fixes B at —
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
B settles before C relaxes it: 5 - the path of 2 through C is missed; use Bellman-Ford.