PDA

نسخه کامل مشاهده نسخه کامل : الگوریتم در متلب



rshafiiy
12-04-2014, 15:07
سلام . من میخوام الگوریتم زیر رو تو متلب پیاده سازی کنم کسی می تونه واسم انجامش بده ؟



INPUT:
G (V, E) be a directed graph with a set of V nodes and set of E
directed edges.
PARAMETERS:
R (s ,d) , a nonnegative number stands for the cost where ‘‘ o’’
start node and ‘‘ d’’ is last node.
i , j, k; loop index, G(1, i ) is array of vertexes source; G(2, i )is
array of vertexes destination.
G(3, i ) is array of edge distance(or cost); CostArray(i )is
arrayed of node costs(node weights) table
for each node and SP(i ) is arrayed of the shortest path from
the origin to final node.
OUPUT:
CostArray(k) is a cost data table for all nodes. SP(k), a
shortest path data table for a graph.
INITIALIZATION:
// All nodes from last to first nodes are examined for the
route’s connected nodes.
// For each edge do the operation in two steps as follows:
set CostArray[1... node-1] = 999, CostArray(node) = 0,
SP(i )= 0;
BEGIN
for all nodes
for j = first to last edges // j is set to the destination node
of edges.
if (G (2, j)= i)// k is set to the source node of edges.
cost = CostArray(i )+ G (3, j);
end if
end for
end for
for i = first to last edges
while (the origin (k) is the same in graph, G)
if (G (3, i) = CostArray(k) CostArray(j))
SP(k)= G(2, i );
else
i = i +1;
k = G (1, i);
end if
end while
end for
END