Skip to content

Commit

Permalink
Added 6.006 lec 15
Browse files Browse the repository at this point in the history
  • Loading branch information
hrushikeshrv committed Jan 11, 2025
1 parent deffaf4 commit fc0428a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions 6.006/fall-2011/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ problems.
12. [Square Roots, Newton's Method]({% link 6.006/fall-2011/lec12.md %})
13. [Breadth-First Search]({% link 6.006/fall-2011/lec13.md %})
14. [Depth-First Search, Topological Sort]({% link 6.006/fall-2011/lec14.md %})
15. [Single Source Shortest Paths Problem]({% link 6.006/fall-2011/lec15.md %})
16. [Dijkstra]({% link 6.006/fall-2011/lec16.md %})
17. [Bellman-Ford]({% link 6.006/fall-2011/lec17.md %})
18. [Speeding up Dijkstra]({% link 6.006/fall-2011/lec18.md %})
Expand Down
28 changes: 28 additions & 0 deletions 6.006/fall-2011/lec15.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
layout: default
title: Lecture 15 - Single Source Shortest Paths Problem
parent: MIT 6.006 - Introduction to Algorithms
nav_order: 15
---

# Lecture 15 - Single Source Shortest Paths Problem
This lecture discusses the single source shortest paths problem and presents the general strategies algorithms follow to solve it.

The single source shortest paths problem is defined as follows: given a graph $G = (V, E)$ and a source vertex $s \in V$, find the shortest path from $s$ to every other vertex in $V$.

## General Strategies
Given that your graph does not have any negative weight cycles, there is a general approach to solve the single source shortest paths problem:

```
Initialize the distance of the source vertex to 0 and the distance of all other vertices to infinity.
Repeat until no more updates are possible:
For each edge (u, v) in E:
Relax the edge (u, v)
```

"Relaxing" an edge means updating the distance of the destination vertex $v$ to the minimum of its current distance and the sum of the distance of the source vertex $u$ and the weight of the edge $(u, v)$.

```python
if d[v] > d[u] + w(u, v):
d[v] = d[u] + w(u, v)
```

0 comments on commit fc0428a

Please sign in to comment.