Download free for 30 days
Sign in
Upload
Language (EN)
Support
Business
Mobile
Social Media
Marketing
Technology
Art & Photos
Career
Design
Education
Presentations & Public Speaking
Government & Nonprofit
Healthcare
Internet
Law
Leadership & Management
Automotive
Engineering
Software
Recruiting & HR
Retail
Sales
Services
Science
Small Business & Entrepreneurship
Food
Environment
Economy & Finance
Data & Analytics
Investor Relations
Sports
Spiritual
News & Politics
Travel
Self Improvement
Real Estate
Entertainment & Humor
Health & Medicine
Devices & Hardware
Lifestyle
Change Language
Language
English
Español
Português
Français
Deutsche
Cancel
Save
EN
Uploaded by
Jhoveran Cuno
103 views
Visual explanation of Dijkstra's Algorithm using Python
Visual explanation of Dijkstra's algorithm using Python step by step
Software
◦
Read more
0
Save
Share
Embed
Embed presentation
Download
Download to read offline
1
/ 26
2
/ 26
Most read
3
/ 26
4
/ 26
Most read
5
/ 26
6
/ 26
Most read
7
/ 26
8
/ 26
9
/ 26
10
/ 26
11
/ 26
12
/ 26
13
/ 26
14
/ 26
15
/ 26
16
/ 26
17
/ 26
18
/ 26
19
/ 26
20
/ 26
21
/ 26
22
/ 26
23
/ 26
24
/ 26
25
/ 26
26
/ 26
More Related Content
PPT
Dijesktra 1.ppt
by
DEEPAK948083
PPTX
Dijkstra Algorithm Presentation -the shortest path finding algorithm.pptx
by
GhazalaAnjum9
PPTX
Dijkstra’s algorithm
by
faisal2204
PPT
Dijkstra algorithm _
by
swati463221
PPT
Dijkstra algorithm ds 57612334t4t44.ppt
by
ssuser7b9bda1
PPT
Dijkstra Shortest Path Algorithm in Network.ppt
by
RAJASEKARAN G
PPTX
Deixtras Algorithm.pptxdjjdjdjdjddddddddddddddd
by
OrxanMirzzad
PPT
Dijkstra c
by
shrikant00786
Dijesktra 1.ppt
by
DEEPAK948083
Dijkstra Algorithm Presentation -the shortest path finding algorithm.pptx
by
GhazalaAnjum9
Dijkstra’s algorithm
by
faisal2204
Dijkstra algorithm _
by
swati463221
Dijkstra algorithm ds 57612334t4t44.ppt
by
ssuser7b9bda1
Dijkstra Shortest Path Algorithm in Network.ppt
by
RAJASEKARAN G
Deixtras Algorithm.pptxdjjdjdjdjddddddddddddddd
by
OrxanMirzzad
Dijkstra c
by
shrikant00786
Similar to Visual explanation of Dijkstra's Algorithm using Python
PDF
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
by
Khoa Mac Tu
PPT
Dijkstra's algorithm for computer science
by
ajmalnajath4
PPT
2.3 shortest path dijkstra’s
by
Krish_ver2
PPT
Dijkstra.ppt
by
Ruchika Sinha
PDF
P5 - Routing Protocols
by
Kurniawan Dwi Irianto
PPT
Dijsktra’s Sortest path algorithm
by
Delowar Hossain
PDF
Shortest Path in Graph
by
Dr Sandeep Kumar Poonia
PDF
All pairs shortest path algorithm
by
Srikrishnan Suresh
PPTX
Dijkstra Searching Algorithms Shortest.pptx
by
sandeep54552
PPTX
15-bellmanFord.pptx...........................................
by
ejazayesha485
PPT
graph in Data Structures and Algorithm.ppt
by
RAJASEKARAN G
PPTX
Dijkstras-Algorithm-Finding-the-Shortest-Path.pptx
by
GhazalaAnjum9
PPTX
Graph theory
by
iranian translate
PPTX
Randomized algorithms all pairs shortest path
by
Mohammad Akbarizadeh
PPTX
Dijkstra's Algorithm short presentation sem 4
by
yaderyeka
PPT
Graphs
by
Ghaffar Khan
PPTX
SEMINAR ON SHORTEST PATH ALGORITHMS.pptx
by
bharatherltech
PDF
Chap10 slides
by
HJ DS
PPTX
Algo labpresentation a_group
by
Umme habiba
PPTX
Dijkstra’s Algorithm and Prim’s Algorithm in Graph Theory and Combinatorics
by
Shouvic Banik0139
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
by
Khoa Mac Tu
Dijkstra's algorithm for computer science
by
ajmalnajath4
2.3 shortest path dijkstra’s
by
Krish_ver2
Dijkstra.ppt
by
Ruchika Sinha
P5 - Routing Protocols
by
Kurniawan Dwi Irianto
Dijsktra’s Sortest path algorithm
by
Delowar Hossain
Shortest Path in Graph
by
Dr Sandeep Kumar Poonia
All pairs shortest path algorithm
by
Srikrishnan Suresh
Dijkstra Searching Algorithms Shortest.pptx
by
sandeep54552
15-bellmanFord.pptx...........................................
by
ejazayesha485
graph in Data Structures and Algorithm.ppt
by
RAJASEKARAN G
Dijkstras-Algorithm-Finding-the-Shortest-Path.pptx
by
GhazalaAnjum9
Graph theory
by
iranian translate
Randomized algorithms all pairs shortest path
by
Mohammad Akbarizadeh
Dijkstra's Algorithm short presentation sem 4
by
yaderyeka
Graphs
by
Ghaffar Khan
SEMINAR ON SHORTEST PATH ALGORITHMS.pptx
by
bharatherltech
Chap10 slides
by
HJ DS
Algo labpresentation a_group
by
Umme habiba
Dijkstra’s Algorithm and Prim’s Algorithm in Graph Theory and Combinatorics
by
Shouvic Banik0139
Recently uploaded
PPTX
GraphQL Day Paris 2025 | Bringing DevOps to GraphQL with the Apollo GraphOS O...
by
apidays
PDF
AI-native development: from Prompt to Platform
by
Maxim Salnikov
PDF
Azure DevOps Services: Complete Guide to DevOps Tools, Automation & End-to-En...
by
johncarterjn
PDF
Why I Volunteer at FOSDEM and You Should Too
by
Imma Valls Bernaus
PPTX
Best Digital Marketing Company in Lucknow
by
digitallearning9277
PDF
Windows Server 2025 Administration Fundamentals 4ED
by
raynasolomon136
PPTX
Salesforce Spring '26 Release presentation - Melbourne Salesforce User Group
by
Anne N
PDF
Build a Scalable On-Demand Courier Service App.pdf
by
V3CUBE TECHNOLABS
PDF
software architecture for busy developers
by
MuhammadAwaisQaisran
PDF
Track Phone Location on iPhone (2026)_ What Actually Works, What’s a Scam, an...
by
Olive Dimitrescu
PPTX
HR Software for Construction: Smarter Workforce & Payroll Management
by
helixtahr
PPTX
BUSY Software Business Management Solution.pptx
by
Moving Cloud
PDF
Water Delivery App Development Solutions.pdf
by
eSiteWorld TechnoLabs Pvt. Ltd.
PDF
Image and video processing: From Mars to Hollywood with a stop at the hospita...
by
Harinath Palavalli
PPTX
HackYourBrain_JFokusConference_03022026.pptx
by
SimonedeGijt
PPTX
Edison MuleSoft Meetup : Vibe Coding | MuleSoft Meetups
by
Sravan Lingam
PDF
Massage Booking App Development Company.pdf
by
V3CUBE TECHNOLABS
PDF
Animated Safety Induction: A Smarter Way to Onboard for Workplace Safety
by
TECH EHS Solution
PDF
Attendance Dashboard – Time & Attendance Analytics
by
Hajir Pro
PDF
2026 Safety Roadmap: Systems, Skills, and Scale for EHS Leaders
by
TECH EHS Solution
GraphQL Day Paris 2025 | Bringing DevOps to GraphQL with the Apollo GraphOS O...
by
apidays
AI-native development: from Prompt to Platform
by
Maxim Salnikov
Azure DevOps Services: Complete Guide to DevOps Tools, Automation & End-to-En...
by
johncarterjn
Why I Volunteer at FOSDEM and You Should Too
by
Imma Valls Bernaus
Best Digital Marketing Company in Lucknow
by
digitallearning9277
Windows Server 2025 Administration Fundamentals 4ED
by
raynasolomon136
Salesforce Spring '26 Release presentation - Melbourne Salesforce User Group
by
Anne N
Build a Scalable On-Demand Courier Service App.pdf
by
V3CUBE TECHNOLABS
software architecture for busy developers
by
MuhammadAwaisQaisran
Track Phone Location on iPhone (2026)_ What Actually Works, What’s a Scam, an...
by
Olive Dimitrescu
HR Software for Construction: Smarter Workforce & Payroll Management
by
helixtahr
BUSY Software Business Management Solution.pptx
by
Moving Cloud
Water Delivery App Development Solutions.pdf
by
eSiteWorld TechnoLabs Pvt. Ltd.
Image and video processing: From Mars to Hollywood with a stop at the hospita...
by
Harinath Palavalli
HackYourBrain_JFokusConference_03022026.pptx
by
SimonedeGijt
Edison MuleSoft Meetup : Vibe Coding | MuleSoft Meetups
by
Sravan Lingam
Massage Booking App Development Company.pdf
by
V3CUBE TECHNOLABS
Animated Safety Induction: A Smarter Way to Onboard for Workplace Safety
by
TECH EHS Solution
Attendance Dashboard – Time & Attendance Analytics
by
Hajir Pro
2026 Safety Roadmap: Systems, Skills, and Scale for EHS Leaders
by
TECH EHS Solution
Visual explanation of Dijkstra's Algorithm using Python
1.
Dijkstra's Algorithm #Función para
construir adyacencia def constructAdj(edges, V): adj = [[] for _ in range(V)] for edge in edges: u, v, wt = edge adj[u].append([v, wt]) adj[v].append([u, wt]) return adj def dijkstra(V, edges, src): adj = constructAdj(edges, V) pq = [] # Cola de prioridad (min-heap) dist = [sys.maxsize] * V heapq.heappush(pq, [0, src]) dist[src] = 0 while pq: u = heapq.heappop(pq)[1] for x in adj[u]: v, weight = x[0], x[1] if dist[v] > dist[u] + weight: # Actualizar la distancia de v dist[v] = dist[u] + weight heapq.heappush(pq, [dist[v], v]) return dist 1 2 3 4 5 7 0 6 Source 1 5 2 3 1 9 2 9 4 9 3
2.
Dijkstra's Algorithm #Función para
construir adyacencia def constructAdj(edges, V): adj = [[] for _ in range(V)] for edge in edges: u, v, wt = edge adj[u].append([v, wt]) adj[v].append([u, wt]) return adj def dijkstra(V, edges, src): adj = constructAdj(edges, V) pq = [] # Cola de prioridad (min-heap) dist = [sys.maxsize] * V heapq.heappush(pq, [0, src]) dist[src] = 0 while pq: u = heapq.heappop(pq)[1] for x in adj[u]: v, weight = x[0], x[1] if dist[v] > dist[u] + weight: # Actualizar la distancia de v dist[v] = dist[u] + weight heapq.heappush(pq, [dist[v], v]) return dist Edsger W. Dijkstra (1930-2002)
3.
1 2 3 4 5 7 0 6 Source 1 5 2
3 Dijkstra's Algorithm 1 9 2 9 4 9 3 adj = [[ ], [ ], [ ], [ ], [ ], [ ], [ ], [ ],] edges = [[0, 1, 9], [0, 2, 4], [0, 3, 3], [1, 4, 2], [1, 6, 1], [2, 5, 1], [2, 7, 9], [3, 4, 2], [3, 5, 9], [4, 6, 5], [5, 7, 3]] u v wt #Función para construir adyacencia def constructAdj(edges, V): adj = [[] for _ in range(V)] for edge in edges: u, v, wt = edge adj[u].append([v, wt]) adj[v].append([u, wt]) return adj Input v = 8 adj = [[1,9], [0,9], [ ], [ ], [ ], [ ], [ ], [ ],] adj[0] adj[1] adj = [[1,9], [2,4], [0,9], [0,4], [ ], [ ], [ ], [ ], [ ],] adj = [[1,9], [2,4], [3,3] [0,9], [0,4], [0,3], [ ], [ ], [ ], [ ],] adj = [[1,9], [2,4], [3,3] [0,9], [4,2] [0,4], [0,3], [1,2], [ ], [ ], [ ],] adj = [[1,9], [2,4], [3,3] [0,9], [4,2], [6,1] [0,4], [0,3], [1,2], [ ], [1,1], [ ],] adj = [[1,9], [2,4], [3,3] [0,9], [4,2], [6,1] [0,4], [5,1] [0,3], [1,2], [2,1], [1,1], [ ],] adj = [[1,9], [2,4], [3,3] [0,9], [4,2], [6,1] [0,4], [5,1], [7,9] [0,3], [1,2], [2,1], [1,1], [2,9],] adj = [[1,9], [2,4], [3,3] [0,9], [4,2], [6,1] [0,4], [5,1], [7,9] [0,3], [4, 2] [1,2], [3, 2] [2,1], [1,1], [2,9],] adj = [[1,9], [2,4], [3,3] [0,9], [4,2], [6,1] [0,4], [5,1], [7,9] [0,3], [4, 2], [5, 9] [1,2], [3, 2] [2,1], [3, 9] [1,1], [2,9],] adj = [[1,9], [2,4], [3,3] [0,9], [4,2], [6,1] [0,4], [5,1], [7,9] [0,3], [4, 2], [5, 9] [1,2], [3, 2], [6, 5] [2,1], [3, 9] [1,1], [4, 5] [2,9],] adj = [[1,9], [2,4], [3,3] [0,9], [4,2], [6,1] [0,4], [5,1], [7,9] [0,3], [4, 2], [5, 9] [1,2], [3, 2], [6, 5] [2,1], [3, 9], [7, 3] [1,1], [4, 5] [2,9], [5, 3]]
4.
1 2 3 4 5 7 0 6 ∞
Source ∞ ∞ ∞ ∞ ∞ ∞ 0 dist[ ] = vértice = 0 1 2 3 4 5 6 7 0 ∞ ∞ ∞ ∞ ∞ ∞ ∞ 1 5 2 3 Dijkstra's Algorithm 1 9 2 9 4 9 3 def dijkstra(V, edges, src): adj = constructAdj(edges, V) pq = []# Cola de prioridad (min-heap) dist = [sys.maxsize] * V heapq.heappush(pq, [0, src]) dist[src] = 0 pq = [0, 0] dist nodo
5.
1 2 3 4 5 7 0 6 Source ∞
∞ ∞ ∞ 0 1 5 2 3 Dijkstra's Algorithm 1 9 2 9 4 9 3 while pq: u = heapq.heappop(pq)[1] for x in adj[u]: v, weight = x[0], x[1] if dist[v] > dist[u] + weight: # Actualizar la distancia de v dist[v] = dist[u] + weight heapq.heappush(pq, [dist[v], v]) return dist ∞ ∞ ∞ adj[0] = [1,9], [2,4], [3,3] 0 dist[ ] = vértice = 0 1 2 3 4 5 6 7 ∞ ∞ ∞ ∞ ∞ ∞ ∞ pq = [0, 0]
6.
1 2 3 4 5 7 0 6 Source ∞
∞ ∞ ∞ 0 1 5 2 3 Dijkstra's Algorithm 1 9 2 9 4 9 3 pq = [0, 0], [9, 1] ∞ ∞ adj[0] = [1,9], [2,4], [3,3] 0 9 dist[ ] = vértice = 0 1 2 3 4 5 6 7 ∞ ∞ ∞ ∞ ∞ ∞ 9 while pq: u = heapq.heappop(pq)[1] for x in adj[u]: v, weight = x[0], x[1] if dist[v] > dist[u] + weight: # Actualizar la distancia de v dist[v] = dist[u] + weight heapq.heappush(pq, [dist[v], v]) return dist
7.
1 2 3 4 5 7 0 6 Source ∞
∞ ∞ ∞ 0 1 5 2 3 Dijkstra's Algorithm 1 9 2 9 4 9 3 pq = [0, 0], [9, 1] ∞ adj[0] = [1,9], [2,4], [3,3] 0 9 3 dist[ ] = vértice = 0 1 2 3 4 5 6 7 ∞ ∞ ∞ ∞ ∞ 9 while pq: u = heapq.heappop(pq)[1] for x in adj[u]: v, weight = x[0], x[1] if dist[v] > dist[u] + weight: # Actualizar la distancia de v dist[v] = dist[u] + weight heapq.heappush(pq, [dist[v], v]) return dist ∞
8.
1 2 3 4 5 7 0 6 Source ∞
∞ ∞ ∞ 0 1 5 2 3 Dijkstra's Algorithm 1 9 2 9 4 9 3 pq = [0, 0], [4, 2], [9, 1] adj[0] = [1,9], [2,4], [3,3] 0 9 3 dist[ ] = vértice = 0 1 2 3 4 5 6 7 ∞ ∞ ∞ ∞ ∞ 9 while pq: u = heapq.heappop(pq)[1] for x in adj[u]: v, weight = x[0], x[1] if dist[v] > dist[u] + weight: # Actualizar la distancia de v dist[v] = dist[u] + weight heapq.heappush(pq, [dist[v], v]) return dist 4 ∞
9.
1 2 3 4 5 7 0 6 Source ∞
∞ ∞ ∞ 0 1 5 2 3 Dijkstra's Algorithm 1 9 2 9 4 9 3 adj[0] = [1,9], [2,4], [3,3] 0 9 3 dist[ ] = vértice = 0 1 2 3 4 5 6 7 ∞ ∞ ∞ ∞ ∞ 9 while pq: u = heapq.heappop(pq)[1] for x in adj[u]: v, weight = x[0], x[1] if dist[v] > dist[u] + weight: # Actualizar la distancia de v dist[v] = dist[u] + weight heapq.heappush(pq, [dist[v], v]) return dist 4 ∞ pq = [0, 0], [4, 2], [9, 1]
10.
1 2 3 4 5 7 0 6 Source ∞
∞ ∞ ∞ 0 1 5 2 3 Dijkstra's Algorithm 1 9 2 9 4 9 3 pq = [0, 0], [3, 3], [4, 2], [9, 1] adj[0] = [1,9], [2,4], [3,3] dist[ ] = vértice = 0 1 2 3 4 5 6 7 9 3 4 0 9 4 3 ∞ ∞ ∞ ∞ while pq: u = heapq.heappop(pq)[1] for x in adj[u]: v, weight = x[0], x[1] if dist[v] > dist[u] + weight: # Actualizar la distancia de v dist[v] = dist[u] + weight heapq.heappush(pq, [dist[v], v]) return dist
11.
1 2 3 4 5 7 0 6 9
Source 4 3 ∞ ∞ ∞ ∞ 0 0 9 4 3 dist[ ] = vértice = 0 1 2 3 4 5 6 7 push pop 1 5 2 3 {0,0} {4,2} Dijkstra's Algorithm 1 9 2 9 4 9 3 {9,1} {3,3}
12.
1 2 3 4 5 7 0 6 9
Source 4 3 ∞ ∞ ∞ ∞ 0 0 9 4 3 dist[ ] = vértice = 0 1 2 3 4 5 6 7 push pop 1 5 2 3 {3,3} {4,2} Dijkstra's Algorithm 1 9 2 9 4 9 3 {9,1}
13.
1 2 3 4 5 7 0 6 9
Source 4 3 5 11 ∞ ∞ 0 dist[ ] = vértice = 0 1 2 3 4 5 6 7 push pop 1 5 2 3 {9,1} Dijkstra's Algorithm 1 9 2 9 4 9 3 {11,5} {5,4} 0 9 4 3 5 11 {4,2}
14.
1 2 3 4 5 7 0 6 9
Source 4 3 5 11 ∞ ∞ 0 dist[ ] = vértice = 0 1 2 3 4 5 6 7 push pop 1 5 2 3 {9,1} Dijkstra's Algorithm 1 9 2 9 4 9 3 {11,5} {5,4} 0 9 4 3 5 11 {4,2}
15.
1 2 3 4 5 7 0 6 9
Source 4 3 5 5 13 ∞ 0 dist[ ] = vértice = 0 1 2 3 4 5 6 7 push pop 1 5 2 3 {9,1} Dijkstra's Algorithm 1 9 2 9 4 9 3 {13,7} {5,5} 0 9 4 3 5 5 13 {5,4}
16.
1 2 3 4 5 7 0 6 9
Source 4 3 5 5 13 ∞ 0 dist[ ] = vértice = 0 1 2 3 4 5 6 7 push pop 1 5 2 3 {9,1} Dijkstra's Algorithm 1 9 2 9 4 9 3 {13,7} {5,5} 0 9 4 3 5 5 13 {5,4}
17.
1 2 3 4 5 7 0 6 7
Source 4 3 5 5 13 10 0 dist[ ] = vértice = 0 1 2 3 4 5 6 7 push pop 1 5 2 3 {10,6} Dijkstra's Algorithm 1 9 2 9 4 9 3 {13,7} {7,1} 0 7 4 3 5 5 10 13 {5,5}
18.
1 2 3 4 5 7 0 6 7
Source 4 3 5 5 13 10 0 dist[ ] = vértice = 0 1 2 3 4 5 6 7 push pop 1 5 2 3 {10,6} Dijkstra's Algorithm 1 9 2 9 4 9 3 {13,7} {7,1} 0 7 4 3 5 5 10 13 {5,5}
19.
1 2 3 4 5 7 0 6 7
Source 4 3 5 5 8 10 0 push pop 1 5 2 3 {8,7} Dijkstra's Algorithm 1 9 2 9 4 9 3 {10,6} {7,1} {5,5 dist[ ] = vértice = 0 1 2 3 4 5 6 7 0 7 4 3 5 5 10 8
20.
1 2 3 4 5 7 0 6 7
Source 4 3 5 5 8 10 0 push pop 1 5 2 3 {8,7} Dijkstra's Algorithm 1 9 2 9 4 9 3 {10,6} dist[ ] = vértice = 0 1 2 3 4 5 6 7 0 7 4 3 5 5 10 8 {7,1}
21.
1 2 3 4 5 7 0 6 7
Source 4 3 5 5 8 8 0 push pop 1 5 2 3 {8,6} Dijkstra's Algorithm 1 9 2 9 4 9 3 {8,7} {5,5 dist[ ] = vértice = 0 1 2 3 4 5 6 7 0 7 4 3 5 5 8 8
22.
1 2 3 4 5 7 0 6 7
Source 4 3 5 5 8 8 0 push pop 1 5 2 3 Dijkstra's Algorithm 1 9 2 9 4 9 3 {8,7} {5,5 dist[ ] = vértice = 0 1 2 3 4 5 6 7 0 7 4 3 5 5 8 8 {8,6}
23.
1 2 3 4 5 7 0 6 7
Source 4 3 5 5 8 8 0 push pop 1 5 2 3 {8,6} Dijkstra's Algorithm 1 9 2 9 4 9 3 {8,7} {5,5 dist[ ] = vértice = 0 1 2 3 4 5 6 7 0 7 4 3 5 5 8 8
24.
1 2 3 4 5 7 0 6 7
Source 4 3 5 5 8 8 0 push pop 1 5 2 3 {8,6} Dijkstra's Algorithm 1 9 2 9 4 9 3 {5,5 dist[ ] = vértice = 0 1 2 3 4 5 6 7 0 7 4 3 5 5 8 8 {8,7}
25.
1 2 3 4 5 7 0 6 7
Source 4 3 5 5 8 8 0 push pop 1 5 2 3 Dijkstra's Algorithm 1 9 2 9 4 9 3 {5,5 dist[ ] = vértice = 0 1 2 3 4 5 6 7 0 7 4 3 5 5 8 8
26.
1 2 3 4 5 7 0 6 7
Source 4 3 5 5 8 8 0 1 2 3 {8,7} Dijkstra's Algorithm 1 2 4 3 {5,5 dist[ ] = vértice = 0 1 2 3 4 5 6 7 0 7 4 3 5 5 8 8 5 9 9 9
Download