Revision:The Shortest Path - The Student Room
The Student Room

Revision:The Shortest Path

TSR Wiki > Study Help > Subjects and Revision > Revision Notes > Mathematics > The Shortest Path



Dijkstra's algorithm is used to find the shortest path.

Contents

Labelling nodes

When performing Dijkstra's algorithm, the nodes are labelled in a certain way.

  • Box A shows the order in which the node was made permanent. I.e. the first node to be made permanent will be labelled with a 1, and so on.
  • Box B shows the shortest length possible to get to that node.
  • Box C is the box showing temporary labels.

Algorithm

  1. Box the start node by labelling it with a one in Box A and zero in Box B.
  2. Consider the nodes connected to the start node. Temporarily label these (in Box C) with the weight of the arc connecting the node to the start node.
  3. Look at the temporary labels of all nodes which have not yet been boxed. Make the node with the smallest temporary label permanent by copying the value in Box C to Box B. Also fill in Box A.
  4. Consider the nodes connected to the most recently boxed node. Temporarily label these in Box C with the value of the boxed node plus the weight of the arc connecting the node to the boxed node. (If the node has already got a value in Box C which is bigger than the value you just worked out, cross it out and replace it with your new, smaller value.)
  5. Repeat 3 and 4 until the destination node has a permanent label.
  6. Go backwards through the network retracing the path of shortest length to the start node.

Example

Advantages of Dijkstra

  • Once it has been carried out you can find the least weight path to all permanently labelled nodes.
  • You don't need a new diagram for each pass.
  • Dijkstra's algorithm has an order of n2 so it is efficient enough to use for relatively large problems.

Disadvantages

  • Dijkstra's algorithm does not work with negative weight arcs.

Also See

See the other D1 notes:

  1. Algorithms
  2. Sorting algorithms
  3. Packing algorithms
  4. Graphs and networks
  5. Minimum connector problems
  6. The shortest path
  7. Route inspection
  8. The travelling salesman problem
  9. Linear programming
  10. The simplex algorithm

Comments

Discussions Toggle
Spring Weeks 2012 Thread
started by: mel3
forum: Investment Banking Internships and Work Experience
replies: 4419
last post: 1 Minute Ago
32e boobs- too big!
started by: Anonymous
forum: Health
replies: 35
last post: 1 Minute Ago
Akala is a prophet.
started by: Bonged.
forum: Society
replies: 22
last post: 1 Minute Ago
Changes to theory test from January 2012
started by: Phil90974
forum: Learning to Drive
replies: 83
last post: 1 Minute Ago
Gay medical student - will people have issues?
started by: Aidan W
forum: Medicine
replies: 94
last post: 1 Minute Ago
Lipa 2012?
started by: Helenaa
forum: Liverpool Unis
replies: 41
last post: 1 Minute Ago
FA say Capello resigns
started by: lazy smurf
forum: Football
replies: 348
last post: 1 Minute Ago
BBC tells its staff: don’t call Qatada extremist
started by: Time Tourist
forum: News and Current Affairs
replies: 11
last post: 2 Minutes Ago
Medicine 2012 hopeful entrants II
started by: Quackers93
forum: Medicine Community Discussion
replies: 4349
last post: 2 Minutes Ago
The WWE Society
started by: LuckyMan
forum: Sport
replies: 5661
last post: 2 Minutes Ago
Speech and Language Therapy entry 2012
started by: naomiele
forum: Healthcare and Nursing
replies: 2897
last post: 2 Minutes Ago
Cabin Crew Level 2
started by: GPT11
forum: Mature Students
replies: 7
last post: 2 Minutes Ago
Discrete Maths at Warwick
started by: Bakes0011
forum: Computer Science and IT
replies: 0
last post: 2 Minutes Ago
Depression Society MKVI
started by: Idle
forum: Mental Health
replies: 1753
last post: 2 Minutes Ago
Would you want to be the England Manager
started by: NJA
forum: Football
replies: 7
last post: 3 Minutes Ago
Callifornia: Ban on gay marriage unconstitutional
started by: Rds_
forum: International
replies: 37
last post: 3 Minutes Ago
What was your first car & why did you get rid of it?
started by: GunnerBill
forum: Motoring
replies: 15
last post: 3 Minutes Ago
Newton's 3rd law and free will?
started by: JavaWizKid
forum: Religion
replies: 53
last post: 3 Minutes Ago
What do you order from your coffeé shop?
started by: PaperBoy
forum: Food and Drink
replies: 29
last post: 4 Minutes Ago
What did you aspire to be when you were young?
started by: lizolove
forum: Careers sectors and Employment
replies: 266
last post: 4 Minutes Ago
Article Updates Toggle
Contact Us | Site Rules | Staying Safe on TSR | Advertising | Staff Blog | Essays & Coursework | Terms & Conditions | Top
Customise your TSR | Life Advice | Hobbies and Interests | Debate and Current Affairs | Study Help | University and University courses
Universities and HE Colleges | Careers, Employment and Gap Years | General Discussion

Customise your TSR