From: Virtualized on 12 Apr 2010 15:14 Hi Everyone I have a simple question about the use of graphshortestpath Matlab function. I have the following code: W = [10 10 10 10 15 20 50 10 20 10 10]; DG = sparse([1 1 2 2 2 3 3 4 5 6 7],[2 4 3 5 6 6 5 5 6 7 3],W); UG = tril(DG + DG'); h = view(biograph(UG,[],'ShowArrows','off','ShowWeights','on')); % 1st Method: Bellman-Ford disp('Bellman Ford'); [dist,path] = graphshortestpath(UG, 3,5,'directed',false,'Method','Bellman-Ford') % 2nd Method: Dijkstra disp('Dijkstra'); [dist,path] = graphshortestpath(UG, 3,5,'directed',false,'Method','Dijkstra') When i run it i get the following output both for "Bellman Ford" as well as "Dijkstra". dist = 20 path = 3 2 5 This is absolutely fine as well as "Dijkstra" is concerned. However for "Bellman Ford" the output should be: dist = 50 path = 3 5 Can anybody please guide me about this. Any help in this regard is highly appreciated. Best Regards
|
Pages: 1 Prev: GUI: create a pushbutton to restart from the beginning Next: regarding histograms.. |