No License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Dijkstra Shortest Path Routing

4.0 | 36 ratings Rate this file 57 Downloads (last 30 days) File Size: 3.17 KB File ID: #5550 Version: 1.0
image thumbnail

Dijkstra Shortest Path Routing


Xiaodong Wang (view profile)


23 Jul 2004 (Updated )

This function and example show shortest path routing based on Dijkstra algorithm.

| Watch this File

File Information

This function performs Dijkstra algorithm based on the cost matrix, and shortest path can be found.


This file inspired Dijkstra Algorithm Consistent With Cyclic Paths, Probabilistic Flooding Simulation, A Star Search Algorithm, Dijkstra's Shortest Path Algorithm, and Dijkstra Very Simple.

MATLAB release MATLAB 6.0 (R12)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (51)
20 Feb 2017 Byron Bolaños

PLEASE the file

Comment only
16 Nov 2016 channa Silva

it is helpful

Comment only

Really i can't run it. it shows following error

index out of bounds because numel(W)=1.
Error in dijkstra (line 52)

so next what can i do please suggest me ,its urgent.send me at my

Comment only
17 Oct 2015 Zhang Huiyuan

So bad, no description on each variable!! Cant get how to use it!!!

15 Apr 2015 samantha crazy

Hi, I am trying to work on a project to find the best shotest path alogrithm in performance between DIJKSTRA AND BELLFORD algorithms. I even have code but don't know how to run it. Can someone please help me.


Comment only
04 Dec 2014 Cosy

Cosy (view profile)

Upps, commented the wrong file
Sorry for that...

Comment only
04 Dec 2014 Cosy

Cosy (view profile)

Hi there,

what is wrong with this example:

G = [ 0 1 2;
1 0 0;
2 0 0 ]


result: [3 2 2]

Can you help me?

10 Sep 2014 Yousof

Yousof (view profile)

How can I use it?

Comment only
09 Sep 2014 Hannif Mardani


Comment only
14 May 2014 alex

alex (view profile)

can you send me at my email ( how the code works ?? urgently please!!

03 Jun 2013 Raeanne

I'm having trouble using this for large datasets - it works fine for 10 start/end points, but take that up an to 1000 startpoints and endpoints, and my computer almost always runs out of memory. Any way to make it more efficient would be much appreciated.

24 Apr 2013 Barsam

Barsam (view profile)

Really helped me, thanks!

13 Aug 2012 Jesus Luevano

anyone can help to solve a problem with this algorithm!

Comment only
13 May 2012 MAOFAN

MAOFAN (view profile)

Well done

Comment only
13 May 2012 Meg

Meg (view profile)

can you please define the input such as farthestPreviousHop, farthestNextHop, and netcostmatrix?

Comment only
30 Mar 2012 Hakk1

Hakk1 (view profile)


Comment only
09 Jan 2012 Fardeen

well done

12 Nov 2011 LA

LA (view profile)

10 Nov 2011 giorgio

10 Nov 2011 giorgio

02 Oct 2011 Chandra Kurniawan


03 Aug 2011 Seifi

Seifi (view profile)

I met this Error in running the code:

??? Index exceeds matrix dimensions.
Error in ==> dijkstra at 77
if ( ( netCostMatrix(u, v) + distance(u)) < distance(v) )

Could you please tell me how do you define the input?

Comment only
15 Jun 2011 Rick

Rick (view profile)

08 Jun 2011 Matthew Bays

Worked great the first time!

01 Mar 2011 Ying liu

13 Jan 2011 Alexander Wallar

im new to MATLAB and i was just wondering if you could give an example?

Comment only
01 Nov 2010 Maxime

Maxime (view profile)

24 May 2008 avdo tukic

24 Dec 2007 Rolf Bartstra

Poor (or no!) description of input/output parameters. For large nr of nodes, n, the netCostMatrix (nxn) may require vast amounts of memory; a link-based description may be more appropriate in this case (e.g. algorithm by Joseph Kirk)

07 Nov 2007 ai yu

very good

Comment only
14 Oct 2007 neha r


29 Sep 2007 khld ab

18 Sep 2007 chrystal Amutha


Comment only
20 May 2007 momo juju

02 Apr 2007 hanan soliman

17 Mar 2007 shankar velmurugan

good but need more comments to explain the m file

30 Sep 2006 Brevetti Ge

I'm Italian...
what are "farthest..." , "...previous?"...
Help me, please...

22 Sep 2006 Eyup Cinar

Good! but can be excellent with more comments and details inside the codes.It would be better to see more explanatory m file here.

24 Jul 2006 Shahzada Rasool

good example, but farthestNextHop and PreviousHop should be explained

23 Jun 2006 Joseph Kirk

This was very nice and I wanted to give it a 5, but when I changed the random state a couple times, the algorithm did not always find the shortest path... so I wonder if there is a bug that need to be fixed? (rand states = 1, 2, 4, 8 and 10 were the ones I checked that appeared to have an obviously shorter route than the one shown)

06 Jun 2006 An Vincint

I appreciate it very much!

24 Apr 2006 john bautista

very good

03 Apr 2006 achilles boursianis

06 Mar 2006 lydiah asere

15 Oct 2005 samy jojo

not too bad

21 Jul 2005 Alg Searcher

01 Jun 2005 Babis Grouzakis

excellent work,i have to study it carefully,step by step.

25 May 2005 sanith Wijesinghe

24 Apr 2005 egis cioperiux

31 Mar 2005 Andrew Wagner

Worked beautifully. Not sure what the last couple parameters are for, but they can be initialized according the the commented out usage example at the top of the file.

04 Aug 2004 lili Woo

It is good that results are showed.

Contact us