Алгоритм кратчайшего пути Дейкстры

Ниже приводится краткое изложение алгоритма, данное нам нашим профессором.

Что является родителем узла в графе, о котором говорилось в шаге 3? Я немного сбит с толку, поскольку думал, что узлы имеют только соседей и не имеют родителя?

Мои Второй вопрос касается шага 3, «забрать индексную запись в стеке». Поскольку стек позволяет вам просматривать только верхнюю часть, я не уверен , что это значит, если взять индексную запись?

Кратчайший путь Дейкстры:

Step 0: if s == d, stop.
Step 1: current node c= s, c.length = 0, stack.push (c, its length, and parent). 
        If u is the source s then no need for parent.
Step 2: min = 0, hop = infinite, index = 1
Step 3: pick up the index’th record in stack, say node u, its length u.length, 
        and its parent w.
Step 4: find a neighbor of u in the table of neighbors, say v, such that v is 
        not found in any item in stack and <u,v> +u.length< hop. 
Step 5: if such a neighbor is found, hop=min=u.length + <u,v> and record_node = v
Step 6: go to step 4 until all the neighbors of u have been tried (all can be 
        found in stack).
Step 7: index ++, go to step 3 until all the nodes have been tried (found in 
        stack).
Step 8: c = record_node, c.length = min, stack_push(c, c.length, u). If c == d 
        stop the entire process and goes to step 9 for data collection, 
        otherwise go to step 2.
Step 9: (t, d.length, and t.parent) = (d, d.length, and d.parent) in stack, 
        keep searching on (t.parent, t.parent.length, t.parent.parent), 
        until t.parent = s.
5
задан OmG 28 January 2017 в 16:00
поделиться