Изменения

Перейти к: навигация, поиск

Алгоритм Дейкстры

133 байта добавлено, 20:19, 14 октября 2011
Псевдокод
== Псевдокод ==
'''Dijkstra'''(<texcode>GДля всех</texcode>, <tex>wu \in V</tex>, : <texcode>sприсвоим</texcode>) <tex>d [u] \gets \infty</tex> <code>Присвоим</code> <tex>d[s] \gets 0\</tex> <code>Пока</code> <tex>S \gets exists v \varnothingnotin U</tex> '''while''' : <code>Пусть</code> <tex>V \setminus S \neq v \varnothingnotin U</tex> '''do''' <texcode>u \gets — вершина с минимальным</texcode> ''argmin''(<tex>v : v \in V \setminus S, d[v]</tex>) : <code>Для всех</code> <tex>S \gets S \cup \{u\}notin U</tex> '''for''' <code>таких, что</code> <tex>(uv) vu \in E</tex> '''do''' ''relax''(:: <code>если</code> <tex>d[u] > d[v] + w[vu]</tex>, <code>то</code>::: <tex>d[u] \gets d[v] + w [vu]</tex>, : <tex>wU \gets v </tex>)
== Обоснование корректности работы ==
Анонимный участник

Навигация