LightMySky
به انگلیسی

Shortest Paths with Negative Weights and Between All Pairs

Dijkstra's greedy choice fails once an edge can reduce a cost, so Bellman-Ford relaxes every edge n minus one times instead, and reports a negative cycle if anything still improves. Floyd-Warshall answers every pair at once by asking which intermediate vertices are allowed.

شروع یادگیری این موضوعبه حساب کاربری نیازی نیست. پیشرفت در همین مرورگر ذخیره می‌شود.

کارهایی که یادگیرنده بعد از این درس می‌تواند انجام دهد

  • Build a graph with a negative edge where Dijkstra returns the wrong distance
  • Run Bellman-Ford and say what an improvement on the last pass proves
  • Explain what the third index in the Floyd-Warshall recurrence stands for

۱ · بخوان

Dijkstra locks in each vertex greedily and never looks back. A negative edge can later undercut a locked distance. One graph with a single reducing edge is enough to return the wrong answer.

Try it together

Start S links to A at cost 5 and to B at cost 6, and B links to A at minus 4. Dijkstra locks A at 5, but the path through B costs 2. The greedy lock missed the cheaper route.

Bellman-Ford relaxes every edge n minus one times instead of locking anything. If any edge still improves on the last pass, a negative cycle exists.

Good to know

Floyd-Warshall answers every pair at once. Its third index names which intermediate vertices may be used so far. Grow the allowed set step by step and the table converges to all-pairs answers.

Greedy fails on negative edges, full relaxation detects cycles, and allowed vertices build all pairs.

۲ · ببین

به انگلیسی

دور از صفحه‌نمایش

چاپ کاربرگکاغذ A4، با یک صفحهٔ جواب‌ها برای بزرگ‌ترها. بدون صفحه‌نمایش، بدون اینترنت.

جایگاه این موضوع

اول این‌ها را یاد بگیر

این موضوع راه این‌ها را باز می‌کند

سپس تمرین

۸ سؤال پشت این درس منتظرند، هر کدام با پاسخ توضیح‌داده‌شده. هر پاسخ آسمان را پر می‌کند: ستاره‌ها هنگام یادگیری روشن می‌شوند و وقتی زمان برگشتن است کمرنگ می‌شوند.

شروع یادگیری این موضوع