0% found this document useful (0 votes)
6 views

Dijkstra's Algorithm - Uninformed Search Strategy or Method

ML notes

Uploaded by

mechbalaji688
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Dijkstra's Algorithm - Uninformed Search Strategy or Method

ML notes

Uploaded by

mechbalaji688
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Subject

sfff.FI If
Weighted graph
V E
G
W E R

Single source shortest paths

Find the shortest patter


from a fixed vertex to
every other vertex

Assume for now that edge weights are all


non negative

Compute shortest paths all other vertices


from 0 to
Imagine vertices are oil depots edges are pipelines

Set fire its oil depot at vertex o

Fire travels at uniform speed along each


pipeline
Subject

First oil depot to catch fire after 0 is


nearest vortex

Next oil depot if second nearest vortex

Compute expected burn time for vertex

Each time a new vertex burns update the

expected burn times of its nighbours

expected burn timeof


vertex 0 gets upgraded
from α to 0

Change
from α 50
When winter 0 burns we
can look at its outgoing edger
And
Subject
from these outgoing edges we have a better estimate
of when it neighours will burn

So I know now that vertex 1 will burn not later than10


And vertex 2 will burn not later than 80 So I can update
their time from α its 10,80 respectively

Now I look at all these expected times And hopefully there


is something which is finite And among the finite one
whichever one as smallest as the one that is going its
burn next
16

Finally

land manual
Strey scientists
very famous computer
111rem
Subject Proof of corrections

Each new shortent path we discover extends an


eariler one

choose among the list


Geltrategy which are currently available

By induction assume have found shortest


we

path its all vertices already burn

_This is our justification for thegreedy


strategy that every time when we choose
the minimum expected time to burn it
is actually alter minimum time among all
the vertices which is going to burn

Next vertex to burn is v via


Cannot find a shorter
path later from y to v via w
_Burn time Burn time
W
of of v

m n
Edge from w tv men
has weight q
0 menta
Subject

This argument breaks down if edge W v1 can

have negative weight

Can't we
Dijkstrai algorithm with
negative edge weights

Imtht tfmi dictionaries with vertices as keys

Visited initially False for all v


burnt vertices

distance initially infinity for all v


expected to burn time
The longest sequences of edges that connects two

vertices on the path has at most n 1 edges

If I take the largest weight and multiply it by

the number of vertices then this must be bigger

than the length of any path which is actually


there

in the graph
Edge
Subject
L weight

miami.sn i E
ears anywhere
Mammalianmhmah.pt

_Here we start at 5ᵗʰvertex sourcevertex

EEE

if
callingT
0 not
distance
onlyinitilize the asvisited
marked

Not yet visited

MT.fi
tEtutance look for the smallest distance
ggenpohigggnohmisited.me
µ my men on my
graph which is not this unburn vertices which is
visited and will take smallest
the minimum of there
The beginning there will be only one but in given point
there could be multiple such vertices
So I will
say that the next
distance that I am going to

explode next D Is the next distance is the minimum


distance among the unburned vertices
Now
Subject I have its find the vortex for which that is the
minimum distance So that is
my next thing I will say The
next vertex list at the list of all vertices which are notvisited
and which have this actual distance So there in a two
passes on the list So you can do it in an explicit loop
but I felt that this was the fastest way to do it

Now it Is conceivable that there are some vertices which


are never going to be visited So basically if I don't have
any vortices in this list I will just get out I will notcontinue

Now I the smallest vertex among the minimum


choose
vertex list its be the one to burn next

Set distance s to 0

Repeat untill all reable vortices are visited

Find unvisited vertex next with min distance

Set visited nextv7 its True

Recompute distance v7 for every neighous v

for nextv

So this is with an adjacency matrix and as you might


guess this is not likely to be ideal in terms of computational
complexity
Subject

selling infinity takes 0cm time

Main loop runs n times

Each iteration visits one more vertex

Oin to find next vortex its visit

Oln its update distance v7 for neighbours

f Ros

I isnitag.hn

1
In thisouterloop wehadtwonested things which are
W
problematicone issolved becausenow if I wantto update
thedegrees thisis orderO m Begonce Igeta vertexand
I wantto update allits neighbours I onlyhavetogoproportional
isthedegree ofthatvertexwhichamortized as usualacross
all ofthem isgoing tobethesum ofthedegreewhichwill
beproposional its thenumber ofedges
Buttheproblem is thatthisremains Identifying
theminvertexremains I need tofindtheminvertex
Subject
use an adjacency list
If we

setting infinity and updating distances bothO m


amortised

On bottleneck remains its find Itu next voter


visit

Better data structure later


negative

Summery when we don'thave itsedges


to
paths
Dijkstra's algorithm computer single source shortest
Use a greedy strategy to identify vertices its visit

Next vester its visit is based on shortest distance


computed so for

Need its prove that such a strategy in correct

Correctness requires edge weights to be non negative

Complexity is O N
Even with adjacency list

Bottleneck is identifying unvisited vertex with


minimum distance
Subject
Need a better data structure its identify and
remove minimum or maximum from a collection

Whenever we use such a greedy strategy where we are


ignoring everything and we are notlooking multiple steps
ahead but choosing the optimum one right now we have to
justify why it is true and we prove that if the edges
indeed have non negative weights then you can argue that you
will not find the later part which will become shorter than
the path that you have just found So in that sense
Dylestra's algorithm is correct without non negative edge weight

You might also like