Label correcting algorithm for shortest path

Would you please write a code for Label correcting algorithm for shortest path??

11 个评论

The present version of your Question sounds like you are asking us to write code for a homework assignment for you. That is not the purpose of MATLAB Answers: MATLAB Answers is about the MATLAB language. We will help you interpret error messages and help you find information in the documentation, but we will seldom just write non-trivial code for you.
See also "Label-Correcting Shortest Path Algorithms Revisited. María G. Bardossy, Douglas R. Shier". They implemented in MATLAB. I do not know if you will be able to find their full paper for free but you can read parts of it.
I do not have much experience in programming with MATLAB. If it is possible suggest me applied materials and pamphlets.
There are a lot of good suggestions for how to learn MATLAB in this Answer. Once you've read through that thread (and possibly some of the resources linked there) then give implementing your algorithm a shot. Some of the new graph algorithm tools introduced in release R2015b may help you with your implementation. If you get stuck during your implementation, come back to MATLAB Answers, show where you're stuck, and ask a specific question about the difficulty and someone will probably give you a nudge in the right direction.
Hi, As I said before I am not good in Matlab :( I tried to write a code for "Label-Correcting Shortest Path Algorithms" but still many problems are existed. What I wrote can be seen in the following. Pls read and help me for continuing. More exactly, I do not know how I could write "for each (i,j) belong to A(i)".
d(1)=0
pred(1)=0
for j=2:6
w(j)=Inf
end
list=[1]
while list~=[]
i=list(1)
list(1)=[]
end
You can represent your set of arcs as a cell array. Or, since you will have the same amount of information for each arc, you can use a 2 dimensional numeric array. For example if for each arc you have the Source, Destination, and Cost, then you could represent as an array of three columns, such as
[1 2 5; %node 1 to 2, cost 5
1 4 3; %node 1 to 4, cost 3
2 5 2] %node 2 to 5, cost 2
Then arc #3 would be the third row of this array.
Walter, if the OP is interesting in a graph theory representation of solving this, they should look at the brand new graph functionality that went into R2015b (assuming they have R2015b).
Specifically, there are several functions related to computing shortest path problems.
Alternatively, they could just use the IPT function bwdistgeodesic if they want to use a more simple image-based approach to the problem.
Interesting, Alex; I had not noticed those yet.
Label correcting algorithm is just find the shortest path between a single source node and a single destination node. Am I right? Now how I want to find shortest path between all pairs of nodes in a network. How label correcting algorithm will be changed for this?
Did you see Alex's comment above? Did you try anything yourself? (If we had any code all ready to go, we would have given it to you.)

请先登录,再进行评论。

回答(1 个)

If you want to learn about MATLAB's capabilities, with code examples, for shortest path, see Steve's blog series: http://blogs.mathworks.com/steve/2011/11/01/exploring-shortest-paths-part-1/

类别

帮助中心File Exchange 中查找有关 Graph and Network Algorithms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by