Label correcting algorithm for shortest path

Can any body provide a code for label correcting algorithm for shortest path. Thankyou!

댓글 수: 6

Describe what the "label correcting algorithm" is.
And do you already have the shortest path, or do you still need to find it?
It sort of sounds like there might be a known path but with something changed after it was calculated, and now the path needs to be "tweaked" to adjust to the new conditions. As a guess.
Here's the label correcting algorithm. It is similar to dijiktras algorithm except that we are maintaining the node list rather than the arc list. I am not really sure how to code this algorithm especially when we also have to keep track of the LIST.
algorithm MODIFIED LABEL CORRECTING;
begin
d(1) := 0 and Pred(1) := empty set ;
d(j) := infinity for each j in N \ {1};
LIST := {1};
while LIST is not empty do
begin
take out an element i from LIST;
for each (i,j) belong to A(i) if d(j) > d(i) + cij then
begin
d(j) := d(i) + cij ;
pred(j) := i;
if j doesnot belong to LIST then add j to LIST;
end;
end;
end
jana
jana 2013년 5월 27일
Regarding the second question: Yes I still need to find the shortest path.
LIST = [1]; %initialize
...
i = LIST(1); %take out element
LIST(1) = [];
...
if ~ismember(j, LIST); LIST(end+1) = j; end %add j if it is not there
jana
jana 2013년 5월 28일
thankyou! that was of great help.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

질문:

2013년 5월 26일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by