You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Dijkstra Algorithm/README.md
+10-10Lines changed: 10 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -44,10 +44,10 @@ When all vertices are marked as visited, the algorithm's job is done. Now, you c
44
44
45
45
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.
46
46
47
-
# Example
47
+
##Example
48
48
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 :)
49
49
50
-
## Initialization
50
+
###Initialization
51
51
52
52
When the algorithm starts to work initial graph looks like this:
53
53
@@ -93,7 +93,7 @@ After this step graph has this state:
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.
| Path Vertices From Start |[A]|[A, B]|[]|[A, D]|[]|
120
120
121
-
## Step 2
121
+
###Step 2
122
122
123
123
From now we repeat all actions again and fill our table with new info!
124
124
@@ -130,7 +130,7 @@ From now we repeat all actions again and fill our table with new info!
130
130
| Path Length From Start | 0 | 3 | inf | 1 | 2 |
131
131
| Path Vertices From Start |[A]|[A, B]|[]|[A, D]|[A, D, E]|
132
132
133
-
## Step 3
133
+
###Step 3
134
134
135
135
<imgsrc="Images/image5.png"height="250" />
136
136
@@ -140,7 +140,7 @@ From now we repeat all actions again and fill our table with new info!
140
140
| Path Length From Start | 0 | 3 | 11 | 1 | 2 |
141
141
| Path Vertices From Start |[A]|[A, B]|[A, D, E, C]|[A, D]|[A, D, E ]|
142
142
143
-
## Step 4
143
+
###Step 4
144
144
145
145
<imgsrc="Images/image6.png"height="250" />
146
146
@@ -150,7 +150,7 @@ From now we repeat all actions again and fill our table with new info!
150
150
| Path Length From Start | 0 | 3 | 8 | 1 | 2 |
151
151
| Path Vertices From Start |[A]|[A, B]|[A, B, C]|[A, D]|[A, D, E ]|
152
152
153
-
## Step 5
153
+
###Step 5
154
154
155
155
<imgsrc="Images/image7.png"height="250" />
156
156
@@ -300,16 +300,16 @@ Also there is a **VisualizedDijkstra.playground**. Use it to figure out algorith
300
300
301
301
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 :)
302
302
303
-
##About this repository
303
+
# About this repository
304
304
305
305
This repository contains to playgrounds:
306
306
* 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.
307
307
* 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.
308
308
309
-
##Demo video
309
+
# Demo video
310
310
311
311
Click the link: [YouTube](https://youtu.be/PPESI7et0cQ)
312
312
313
-
##Credits
313
+
# Credits
314
314
315
315
WWDC 2017 Scholarship Project (Rejected) created by [Taras Nikulin](https://github.com/crabman448)
0 commit comments