Skip to content

Commit 8e0d77f

Browse files
author
Taras Nikulin
committed
Images
1 parent 142ff2e commit 8e0d77f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Dijkstra Algorithm/README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ The best example is road network. If you wnat to find the shortest path from you
99
I have a gif example, which will show you how algorithm works. If this is not enough, then you can play with my **VisualizedDijkstra.playground**.
1010
So let's image, that your house is "A" vertex and your job is "B" vertex. And you are lucky, you have graph with all possible routes.
1111
When the algorithm starts to work initial graph looks like this:
12-
[Images/image1.png]
12+
13+
<img src="Images/image1.png" height="250" />
1314

1415
The table below will represent graph state
1516

@@ -50,42 +51,45 @@ Then we set this vertex as visited
5051
| Path Vertices From Start | [A] | [ ] | [ ] | [ ] | [ ] |
5152

5253
checkingVertex.visited = true
53-
[Images/image2.jpg]
54+
55+
<img src="Images/image2.png" height="250" />
56+
5457
Then we check all of its neighbors.
5558
If neighbor's path length from start is bigger than checking vertex path length from start + edge weigth, 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.
56-
[Images/image3.jpg]
59+
60+
<img src="Images/image3.png" height="250" />
5761

5862
| | A | B | C | D | E |
5963
|:------------------------- |:----------:|:----------:|:----------:|:----------:|:----------:|
6064
| Visited | T | F | F | F | F |
6165
| Path Length From Start | 0 | 3 | inf | 1 | inf |
6266
| Path Vertices From Start | [A] | [A, B] | [ ] | [A, D] | [ ] |
6367

64-
[Images/image4.jpg]
68+
<img src="Images/image4.png" height="250" />
6569

6670
| | A | B | C | D | E |
6771
|:------------------------- |:----------:|:----------:|:----------:|:----------:|:----------:|
6872
| Visited | T | F | F | T | F |
6973
| Path Length From Start | 0 | 3 | inf | 1 | 2 |
7074
| Path Vertices From Start | [A] | [A, B] | [ ] | [A, D] | [A, D, E] |
7175

72-
[Images/image5.jpg]
76+
<img src="Images/image5.png" height="250" />
7377

7478
| | A | B | C | D | E |
7579
|:------------------------- |:----------:|:----------:|:----------:|:----------:|:----------:|
7680
| Visited | T | F | F | T | T |
7781
| Path Length From Start | 0 | 3 | 11 | 1 | 2 |
7882
| Path Vertices From Start | [A] | [A, B] |[A, D, E, C]| [A, D] | [A, D, E ] |
7983

80-
[Images/image6.jpg]
84+
<img src="Images/image6.png" height="250" />
8185

8286
| | A | B | C | D | E |
8387
|:------------------------- |:----------:|:----------:|:----------:|:----------:|:----------:|
8488
| Visited | T | T | F | T | T |
8589
| Path Length From Start | 0 | 3 | 8 | 1 | 2 |
8690
| Path Vertices From Start | [A] | [A, B] | [A, B, C]| [A, D] | [A, D, E ] |
8791

88-
[Images/image7.jpg]
92+
<img src="Images/image7.png" height="250" />
8993

9094
| | A | B | C | D | E |
9195
|:------------------------- |:----------:|:----------:|:----------:|:----------:|:----------:|

0 commit comments

Comments
 (0)