Lecture 15: Single-Source Shortest Paths Problem

  Рет қаралды 242,779

MIT OpenCourseWare

MIT OpenCourseWare

Күн бұрын

MIT 6.006 Introduction to Algorithms, Fall 2011
View the complete course: ocw.mit.edu/6-006F11
Instructor: Srini Devadas
License: Creative Commons BY-NC-SA
More information at ocw.mit.edu/terms
More courses at ocw.mit.edu

Пікірлер: 106
@SparshPaliwal
@SparshPaliwal 6 жыл бұрын
Everyone please stop saying the lecture is worthless. This lecture is a Primer for shortest path algorithms. Understanding negative weights, negative loops was pretty important. Also learning about all different problems like exponential number of vertices. Surely if you had gone through the topic already might be useless to you, so you can skip it. But if you are going through shortest path algos for the first time, its a good lecture.
@ryanc7840
@ryanc7840 2 жыл бұрын
Right. Without this one, subsequent lectures are hard to grasp at least regarding the notations. I concur that this one is a good and necessary primer.
@sergeykholkhunov1888
@sergeykholkhunov1888 2 жыл бұрын
02:30 motivation, Dijkstra, Bellman-Ford 08:25 definitions (path, weight of path, shortest-path problem) 11:10 about time complexity 14:21 weighted graphs 17:56 example 23:55 predecessor relationship definition 26:40 negative weights 32:00 negative weight cycles 37:30 general structure of shortest-path algorithms, relaxation 45:02 example (problems with exponential number of paths) 50:35 optimal substructure (shortest path's subpaths, triangle inequality)
@zvezdalion
@zvezdalion 8 жыл бұрын
This professor's lecture is so structured! He really stresses the important things. So easy to get the big picture, but also gives you the often-overlooked details (e.g., it's not the neg. weight edges, but the *cycles* that are a problem; Dijkstra is essentially *linear*)
@md.sayeedrahman2553
@md.sayeedrahman2553 3 жыл бұрын
loved it! personally i feel attached to this professor! his lecture is so amazing!!!
@SzechSauce
@SzechSauce 4 жыл бұрын
Isn’t there a mistake at 48:20? How can you relax the edge from v4 to v5 to then have d(v5) be 12? That would mean v4 can be reached in 12, and v5 can also be reached in 12? That can’t be correct...? Really great lecture otherwise, quite surprised at all the negative comments on here...
@marvinmurphy4330
@marvinmurphy4330 10 жыл бұрын
neg weights? 28:55 - What about graphs being represented as electric circuits? Some branches have passive components like resistors that cause a potential drop and some branches have active components like batteries that cause a potential gain. Intersections or splits in the circuit are vertices. The connections between splits are edges and the weights are the voltage gain (+ve) or drop (-ve) of that connection.
@surjayanghosh5872
@surjayanghosh5872 4 жыл бұрын
thats an interesting obeservation! ..... but how would we use the different paths/ because in electrical circuits, current (I) is gonna flow in all the branches, i mean we cant tell it to use only a certain path. So, can you think of any way it could be used? but good analogy nonetheless.
@iamparitosh
@iamparitosh 2 жыл бұрын
Also the total potential gain of any cycle is zero here
@Qladstone
@Qladstone 7 жыл бұрын
If each edge represents a multiplier, and you want to minimize the product of the multipliers along a path; that is equivalent to minimizing the sum of the logarithms of those multipliers. Logarithms have a range from -inf to +inf, and so include both negative, zero, and positive values. One commonly cited example is where the multipliers represent currency conversion rates; where each vertex represents one currency, and edges represent conversion rates between currencies.
@pengliu9987
@pengliu9987 10 ай бұрын
Great example of negative weight graph. Thanks for sharing.
@loganwishartcraig
@loganwishartcraig 6 жыл бұрын
This lecture was definitely fine.
@Tintak_hatpin
@Tintak_hatpin 3 жыл бұрын
I like the way he says "you could imagine"
@lockersrandom6161
@lockersrandom6161 3 жыл бұрын
Thank YOU MIT.
@MrKingoverall
@MrKingoverall 3 жыл бұрын
Operations Research Major here: LOVE YOU MAN !! :)
@cskwillreturn2473
@cskwillreturn2473 7 жыл бұрын
At 12:43, did he say O(E^2) possible weights? I think it should be V^2.
@moongumoongu
@moongumoongu 6 жыл бұрын
yeah, jotted that down and got really confused later. if there are |E| edges, the number of possible unique weights is |E|... and E=O(V^2), so yeah, i think he meant to say roughly V^2 possible weights.
@bigdildo
@bigdildo 5 жыл бұрын
agreee
@csl1384
@csl1384 4 жыл бұрын
Glad to see I am not the only one who thought this.
@ShivamPatel-ww1up
@ShivamPatel-ww1up 3 жыл бұрын
my doubt exactly
@aerronpro1133
@aerronpro1133 2 жыл бұрын
Wow this lec is genius, generalises whole shortest path in a lec
@anunaybagga2948
@anunaybagga2948 6 жыл бұрын
i understood each and everything sir said and hence i don't get the hate comments out here.
@mohitsingh-nf5vl
@mohitsingh-nf5vl 4 жыл бұрын
Can u explain me time complexity plz??
@zeronothinghere9334
@zeronothinghere9334 3 жыл бұрын
@@mohitsingh-nf5vl Look at the first video in the playlist. This is the 15th video in the series after all.
@eepassion9720
@eepassion9720 5 жыл бұрын
29:36 you will see Victor giving a example about negative weight. We would know more about MIT TA work. That is so different in my college. I don't even know who is my TA in the entire of my college.
@user-td8zb9xo9k
@user-td8zb9xo9k 2 жыл бұрын
happy to see indian professor here
@yashjain6945
@yashjain6945 5 жыл бұрын
What does he mean by at least gets credit for it 4:27
@RalyJoey
@RalyJoey 7 жыл бұрын
48:22 how did the instructor obtain 12 for the second last vertex of this directed graph?
@fredwu6812
@fredwu6812 7 жыл бұрын
that was a mistake.
@anunaybagga2948
@anunaybagga2948 6 жыл бұрын
Fred Wu no man it is not a mistake watch it again
@tu-ningting2867
@tu-ningting2867 4 жыл бұрын
Anunay Bagga It's been 2 years. Hope you now see it is a mistake. If not, watch it again
@SanghoBose5
@SanghoBose5 5 жыл бұрын
Travelling upstream in river be considered as negative weight path.
@gouravgoel2974
@gouravgoel2974 3 жыл бұрын
this is gold
@josh7910
@josh7910 10 жыл бұрын
48:20 I think he got the 13 ->12 from v5 wrong
@fabischn90
@fabischn90 10 жыл бұрын
It's perfectly correct. After relaxing the edge (v4, v6) he relaxed edge (v5, v6)
@PK-en1bm
@PK-en1bm 10 жыл бұрын
***** I am thinking about relaxation of the edge (v4, v5)??
@fabischn90
@fabischn90 10 жыл бұрын
Prasanjit Khuntia You would understand, if you just had continued watching for another 2 minutes. Keep calm :)
@JustinLiang0
@JustinLiang0 9 жыл бұрын
Yeah odd... I am not sure how he can "relax" the edge like that because nothing seems to satisfy d[v] > d[u] + w(u,v) at that point.
@botelhorui
@botelhorui 9 жыл бұрын
Justin Liang Yes, its a mistake
@Mrimadeyoufall
@Mrimadeyoufall 2 жыл бұрын
So helpful
@isbestlizard
@isbestlizard 3 жыл бұрын
why are cycles even a thing? if they add positive path length you'd obviously never take them, if they add negative path length you'd obviously go around around them forever so surely it makes no sense to even have a graph with cycles when asking the question 'what's the shortest path'.. without adding extra criteria like 'without retracing the same edge' or 'without visiting the same node more than x times'
@neuron8186
@neuron8186 3 жыл бұрын
i don't understand the hate both teacher are best and you haters are nothing more than a keyboard warrior how did you get the audacity to hate people providing free education
@mayonesacosmica
@mayonesacosmica 10 жыл бұрын
how about circuits where there are multiple paths w/ positive or negative voltage differentials for a motivation? if so, I can send you my address for a cushion... ;)
@Joshuaposada
@Joshuaposada 8 жыл бұрын
Wouldn't you just use the magnitude? I'm not really sure, but that's something to think about
@abdelrhmansamir1426
@abdelrhmansamir1426 5 жыл бұрын
I know it's too late i guess. but can anyone explain why does the asymptotic relation between edges and vertices is v^2? don't know if i said it correctly as well just didn't get that point.
@vamshidharreddy2580
@vamshidharreddy2580 5 жыл бұрын
maximum number of edges possible is of the order v^2. which is same as maximum number of handshakes among 'v' people.
@shubhankitsingh5196
@shubhankitsingh5196 5 жыл бұрын
nC2
@thehvhnk
@thehvhnk 3 жыл бұрын
discrete math? Imagine you pick two random nodes in a bunch of nodes so when total of nodes is N therefore total of number of ways is NC2 ~ n^2
@Aryan-xj1qz
@Aryan-xj1qz 3 жыл бұрын
In a complete graph, the number of edges is V choose 2 (The total number of ways by which we can pair two vertices), which equals V*(V-1)/2. This is of order V^2. Hence, E = O(V^2)
@user-nu2sz2wg3i
@user-nu2sz2wg3i 2 жыл бұрын
His lecture is very meticulous
@ChristopherPelnar
@ChristopherPelnar Жыл бұрын
Negative weights are like hitting wormholes in space-time.
@dbporter
@dbporter 6 жыл бұрын
41:20 49:00
@rithwikteja2168
@rithwikteja2168 2 жыл бұрын
I need to find victor now
@hoboishjoeishme
@hoboishjoeishme 9 жыл бұрын
45:23 sounds like someone's squeezing out a little fart
@kidsworld5584
@kidsworld5584 7 жыл бұрын
lol
@swapnilgupta9153
@swapnilgupta9153 6 жыл бұрын
I came for the this exact comment.
@osamarajput9956
@osamarajput9956 5 жыл бұрын
legend
@fredwu6812
@fredwu6812 4 жыл бұрын
What are you here for? Listening to farting or lectures?
@nikhilrajput5030
@nikhilrajput5030 4 жыл бұрын
Can anyone help me why E=O(V^2)??
@abhaikollara5811
@abhaikollara5811 4 жыл бұрын
Number of possible edges between n vertices is nC2 i.e the number of ways to pick 2 vertices from a given set of n vertices. Unless I screwed up, replacing r=2 in the equation for nC2 should derive into (V^2 - 1)/2 which is O(V^2).
@nikhilrajput5030
@nikhilrajput5030 4 жыл бұрын
@@abhaikollara5811 Thanks man!
@legendarylea560
@legendarylea560 3 жыл бұрын
@@abhaikollara5811 I think it's not about nC2 (combinations) but nP2 (permutations), so nPr -> n^r -> n^2. Am I wrong?
@cvprasanthkumar
@cvprasanthkumar 3 жыл бұрын
I think it is because every Vertex can have atmost V Edges(Unless we are talking about Multi Graph). So you have V Vertex with each having V Edges, so overall edges are V^2
@ShabbirAhmed-ug8sv
@ShabbirAhmed-ug8sv 9 жыл бұрын
22:25
@rohangupta3486
@rohangupta3486 8 жыл бұрын
how he wrote E=O(V^2) ?????????????????
@cskwillreturn2473
@cskwillreturn2473 7 жыл бұрын
Assume two vertices v1 and v2. The total number of possible edges would be 4 which is 2^2 ( 2= total number of vertices). All possible edges v1 -> v2, v2 -> v1, v1->v1, v2->v2. They all add up to 4. But this is only correct if the graph is directed. If undirected, I think it should be v(v-1)/2.
@kp2718
@kp2718 6 жыл бұрын
imagine an adjacency matrix
@legendarylea560
@legendarylea560 3 жыл бұрын
@IndiaRockLovers I think it's not about nC2 (combinations) but nP2 (permutations), so nPr -> n^r -> n^2. Am I wrong?
@legendarylea560
@legendarylea560 3 жыл бұрын
@IndiaRockLovers Perfect, thx
@mystmuffin3600
@mystmuffin3600 3 жыл бұрын
it's about how many (u,v) pairs can be formed. Directed edges would yield nP2 edges given the graph is simple (u cannot be equal to v) and nC2 edges for undirected as (u,v) and (v,u) would only be counted once
@yangyinjedi
@yangyinjedi 8 жыл бұрын
I like the other professor a little better I feel like his lectures are more random and less structured...I felt like this professor was just teaching by the book...But they're are both great sup lectures
@csl1384
@csl1384 4 жыл бұрын
14:05 If Dijkstra is "basically" linear time [O(VlogV + E)], then Bellman-Ford [O(VE)] should be "basically" quadratic time, not cubic time.
@philodev874
@philodev874 4 жыл бұрын
No, the professor explains how E’s asymptotic upper bound is V^2(imagine each vertex containing an edge to every other vertex) therefore V * E = V * V^2 = V^3 (asymptotic upper bound)
@csl1384
@csl1384 4 жыл бұрын
@@philodev874 agreed, thanks
@philodev874
@philodev874 4 жыл бұрын
c sl no problem!
@isbestlizard
@isbestlizard 3 жыл бұрын
why would anyone imagine the weight defined for an edge WOULD affect the calculation speed of an algorithm? that'd be like thinking the 'weight' of an object would affect the time it took to sort it. 'this is a really heavy object so it takes longer to add it to the list' wot no 'this is a really long path so it takes longer to calculate its length' WOT NO WHY WOULD YOU THINK THAT :V
@adhishmalviya2408
@adhishmalviya2408 3 жыл бұрын
49:30 the random relaxing of edges can be exponential and dependent on order of weights
@yettodecideahandle
@yettodecideahandle 3 жыл бұрын
Srini is very good and seem to explain thing simple, Eric makes the same lectures complicated.
@elliott8175
@elliott8175 3 жыл бұрын
Erik is the boss. I love his intuitive explanations. He gets straight to the ideas in a really down-to-earth way: "Dynamic programming is really just careful brute force". If you get DP, you realise how other teachers make it out to be much more complicated than it is.
@brendawilliams8062
@brendawilliams8062 2 жыл бұрын
Negative takes so much work with squares and cubes. People don’t want what appears to be infinities of work. They want a genesis of general and fast tracked work.
@jshellenberger7876
@jshellenberger7876 5 ай бұрын
#POW
@tchappyha4034
@tchappyha4034 4 жыл бұрын
11:55 very dangerous!
@douzigege
@douzigege 6 жыл бұрын
I can feel the pain. The reason why sometimes he is not delivering the lectures is probably the fact that Dr. Devadas is not a mathematician like Erik.
@ankushmenat
@ankushmenat 4 жыл бұрын
Nonsense
@saicharanmarrivada5077
@saicharanmarrivada5077 Жыл бұрын
He has higher h-index compared to Erik
@ravitejapothala7114
@ravitejapothala7114 5 жыл бұрын
Mm,kumms
@connectication
@connectication 9 жыл бұрын
30:32, sooo awkward
@rj-nj3uk
@rj-nj3uk 4 жыл бұрын
He did not taught dijkstra properly.
@ChrisLeeX
@ChrisLeeX 8 жыл бұрын
While I'm a big fan of this series and I like the lecturer, this particular lecture is terrible. Just skip it.
@roylee3196
@roylee3196 8 жыл бұрын
+Chris Lee Yes you're right.
@satadhi
@satadhi 6 жыл бұрын
Hi can you be more specific please ? cause i don't see anything wrong in this , maybe i am missing something ?
@xinli6243
@xinli6243 5 жыл бұрын
I like Eric.
@kp2718
@kp2718 6 жыл бұрын
You get to appreciate the quality of a lecture after watching something like this. Where's Eric??? I think this guy forgot whats' the point of lectures, so he just rambles.
@piyushsharma6811
@piyushsharma6811 5 жыл бұрын
Disappointed.
@chenzhiye633
@chenzhiye633 7 жыл бұрын
waste of time=,=
@jsridhar72
@jsridhar72 7 жыл бұрын
Just unberable. Wasted precious time. You wont gain anything by watching this. Just skip it.
Lecture 16: Dijkstra
51:26
MIT OpenCourseWare
Рет қаралды 301 М.
SHE WANTED CHIPS, BUT SHE GOT CARROTS 🤣🥕
00:19
OKUNJATA
Рет қаралды 14 МЛН
ONE MORE SUBSCRIBER FOR 6 MILLION!
00:38
Horror Skunx
Рет қаралды 11 МЛН
ДЕНЬ РОЖДЕНИЯ БАБУШКИ #shorts
00:19
Паша Осадчий
Рет қаралды 3,7 МЛН
The hidden beauty of the A* algorithm
19:22
polylog
Рет қаралды 823 М.
13. Dijkstra
57:22
MIT OpenCourseWare
Рет қаралды 26 М.
How Dijkstra's Algorithm Works
8:31
Spanning Tree
Рет қаралды 1,3 МЛН
Dijkstra's Algorithm - Computerphile
10:43
Computerphile
Рет қаралды 1,3 МЛН
MIT Introduction to Deep Learning | 6.S191
1:09:58
Alexander Amini
Рет қаралды 198 М.
26. Chernobyl - How It Happened
54:24
MIT OpenCourseWare
Рет қаралды 2,8 МЛН
14. APSP and Johnson
56:53
MIT OpenCourseWare
Рет қаралды 13 М.
SHE WANTED CHIPS, BUT SHE GOT CARROTS 🤣🥕
00:19
OKUNJATA
Рет қаралды 14 МЛН