1632
 правки
Изменения
м
      '''function''' findHamiltonianCycle(<tex>\mathttleft \langle {findHamiltonianCycleV, E}(queue\right \rangle</tex>):      '''for''' <tex> v \in V</tex>:                                          <font color = "green">// Добавляем все вершины графа в очередь</font>        queue.pushBack(<tex>v</tex>)      '''for''' k = 0...n*(n - 1)        '''if''' <tex>(queue.\mathtt{at}(0), queue.\mathtt{at}(1)) <tex> \notin E</tex>                                 <font color = "green">// Проверяем существования ребра между первой и второй вершинами очереди</font>          <tex>i = 2</tex>                                                       '''while''' <tex>(queue.\mathtt{at}(0), queue.\mathtt{at}(i)) <tex> \notin E</tex> '''or''' <tex>(queue.at(1), queue.at(i + 1)) <tex> \notin E</tex>              <tex>i</tex>++                                         <font color = "green">// Ищем индекс удовлетворяющую условию вершины</font>          <tex>queue.\mathtt{swapSubQueue}(21, i)</tex>                        <font color = "green">// Разворачиваем часть перестановки от 21-й до найденной позиции включительно</font>        <tex>queue.\mathtt{pushBack}(queue.\mathtt{top}())</tex>        <tex>queue.\mathtt{pop}()</tex>
rollbackEdits.php mass rollback
== Псевдокод ==
Функция <tex>\mathtt{findHamiltonianCycle}</tex> получает на вход очередь вершин граф <tex> G </tex > и находит гамильтонов цикл в графенем.
* <tex> queue </tex> {{---}} очередь вершин графа <tex>G = \left \langle {V, E} \right \rangle</tex>
{| width = 100%
|-
| 
|}
