single source shortest path

14
Single-Source Shortest Single-Source Shortest Path Problem Path Problem Prepare by Prepare by Dweep Sarker Dweep Sarker Mohibulla Noman Mohibulla Noman Stamford University Bangladesh Stamford University Bangladesh

Upload: dweep-sarker

Post on 11-Apr-2017

256 views

Category:

Engineering


1 download

TRANSCRIPT

Page 1: Single source shortest path

Single-Source Shortest Path Single-Source Shortest Path Problem Problem Prepare byPrepare byDweep SarkerDweep Sarker

Mohibulla NomanMohibulla NomanStamford University BangladeshStamford University Bangladesh

Page 2: Single source shortest path

Outline• Approach Dijksra’s Algorithm• Use Application• Improvement• Advantages• Disadvantages• In Future

Page 3: Single source shortest path

Algorithms Solving the Problem

• Dijkstra’s algorithm – Solves only the problems with

nonnegative costs.• Floyd-Warshall and Bellman-Ford

algorithm solve the problems on graphs that do not have a cycle with negative cost

Page 4: Single source shortest path

Complexity

Weights Time complexity Authorℝ+ O(E + V log V) Dijkstra 1959

ℕ O(E)Thorup (requires constant-time multiplication).

Page 5: Single source shortest path

Point-to-point Shortest Path Problem

o

Z

R

Vs

D

C

B

A

Page 6: Single source shortest path

Dijkstra’s Idea

s x y

tentative d[y]

length(x,y)settled d[x]

priority queue

Qsettled

nearest unsettled neighbor of x

1. Shortest distance from s to all nodes initially “unsettled”.2. Shortest distance to s is zero. Tentative distance to others is ∞.3. Put all nodes in queue ordered by tentative distance from s.4. Take out nearest unsettled node, x. Settle its distance from s.5. For each unsettled immediate neighbor y of x6. If going from s to y through x is shorter than shortest path through

settled nodes, update tentative distance to y.7. Repeat from step 4, until distance to destination is settled.

Page 7: Single source shortest path

1. Google maps2. Road routing

Example Application

Page 8: Single source shortest path

Improve

• Heap sort requires only space of one record, quick sort O(logn) and merge sort requires O(n) node J&T(v) represent the label of node 0 to end D.

• The cost from node 0 to D is the sum of cost WOA and cost w.

• Reuse Dijkstra algorithm to get the optional path SPAD from A to D node.

Page 9: Single source shortest path

Advantage & Disadvantage

Advantage:Finds shortest path in O( E+ V Log(V) ) if you use a min priority queue. This is true only if you implement priority queue with Fibonacci heap, then amortized operation over it will take O(1). Otherwise, if you use any other implementation of priority_queue (like standard C++ STL) it should take E log(E) + V.

Page 10: Single source shortest path

Advantage & Disadvantage

Disadvantage:

Fails in cases where you have a negative edge

It has a blind searching method for this it take a huge amount of time.

Page 11: Single source shortest path

Run time:For a dance graph it is:

O{E+(V*V)}

For a sparse graph it is:O(E+ VlogV)

Page 12: Single source shortest path

In Future

Using in mapping.Using in city distance measurement. Traffic criteria management.Will use in networking Station distance.Will use in space distance

measurement.

Page 13: Single source shortest path

Conclusion

• The compute time complexity for each of the Dijkstra’s algorithm are acceptable in items of their overall performance in solving the shortest path problem. All of algorithm produce only one solution.

Page 14: Single source shortest path

Thank you honorable Teacher Nazia Hossain(Briti)

Prepared by :Dweep sarkerMohibulla Noman CSE 052 06625CSE 052 06646