Skip to content

Commit bb8b2a7

Browse files
author
Taras Nikulin
committed
Fixes
1 parent b1a50b4 commit bb8b2a7

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Dijkstra Algorithm/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ When all vertices are marked as visited, the algorithm's job is done. Now, you c
4444

4545
I have created **VisualizedDijkstra.playground** game/tutorial to improve your understanding of the algorithm's flow. Besides, below is step by step algorithm's description.
4646

47-
# Example
47+
## Example
4848
Let's imagine, you want to go to the shop. Your house is A vertex and there are 4 possible stores around your house. How to find the closest one/ones? Luckily, you have graph, that connects your house with all these stores. So, you know what to do :)
4949

50-
## Initialization
50+
### Initialization
5151

5252
When the algorithm starts to work initial graph looks like this:
5353

@@ -93,7 +93,7 @@ After this step graph has this state:
9393
| Path Length From Start | 0 | inf | inf | inf | inf |
9494
| Path Vertices From Start | [A] | [ ] | [ ] | [ ] | [ ] |
9595

96-
## Step 1
96+
### Step 1
9797

9898
Then we check all of its neighbors.
9999
If checking vertex path length from start + edge weigth is smaller than neighbor's path length from start, then we set neighbor's path length from start new value and append to its pathVerticesFromStart array new vertex: checkingVertex. Repeat this action for every vertex.
@@ -118,7 +118,7 @@ And its state is here:
118118
| Path Length From Start | 0 | 3 | inf | 1 | inf |
119119
| Path Vertices From Start | [A] | [A, B] | [ ] | [A, D] | [ ] |
120120

121-
## Step 2
121+
### Step 2
122122

123123
From now we repeat all actions again and fill our table with new info!
124124

@@ -130,7 +130,7 @@ From now we repeat all actions again and fill our table with new info!
130130
| Path Length From Start | 0 | 3 | inf | 1 | 2 |
131131
| Path Vertices From Start | [A] | [A, B] | [ ] | [A, D] | [A, D, E] |
132132

133-
## Step 3
133+
### Step 3
134134

135135
<img src="Images/image5.png" height="250" />
136136

@@ -140,7 +140,7 @@ From now we repeat all actions again and fill our table with new info!
140140
| Path Length From Start | 0 | 3 | 11 | 1 | 2 |
141141
| Path Vertices From Start | [A] | [A, B] |[A, D, E, C]| [A, D] | [A, D, E ] |
142142

143-
## Step 4
143+
### Step 4
144144

145145
<img src="Images/image6.png" height="250" />
146146

@@ -150,7 +150,7 @@ From now we repeat all actions again and fill our table with new info!
150150
| Path Length From Start | 0 | 3 | 8 | 1 | 2 |
151151
| Path Vertices From Start | [A] | [A, B] | [A, B, C]| [A, D] | [A, D, E ] |
152152

153-
## Step 5
153+
### Step 5
154154

155155
<img src="Images/image7.png" height="250" />
156156

@@ -300,16 +300,16 @@ Also there is a **VisualizedDijkstra.playground**. Use it to figure out algorith
300300

301301
It is up to you how to implement some specific parts of algorithm, you can use Array instead of Set, add _visited_ property to Vertex or you can create some local totalVertices Array/Set inside _func findShortestPaths(from startVertex: Vertex)_ to keep totalVertices Array/Set unchanged. This is a general explanation with one possible implementation :)
302302

303-
## About this repository
303+
# About this repository
304304

305305
This repository contains to playgrounds:
306306
* To understand how does this algorithm works, I have created **VisualizedDijkstra.playground.** It works in auto and interactive modes. Moreover there are play/pause/stop buttons.
307307
* If you need only realization of the algorithm without visualization then run **Dijkstra.playground.** It contains necessary classes and couple functions to create random graph for algorithm testing.
308308

309-
## Demo video
309+
# Demo video
310310

311311
Click the link: [YouTube](https://youtu.be/PPESI7et0cQ)
312312

313-
## Credits
313+
# Credits
314314

315315
WWDC 2017 Scholarship Project (Rejected) created by [Taras Nikulin](https://github.com/crabman448)

0 commit comments

Comments
 (0)