Python code!!!! Expected output will be posted as well as the sample for the 4 cases. Please read the directions carefully and write the code in python. Read and learn how Dijkstra's SSSP algorithm works  Implement the algorithm in Python including your own test driver to prove your implementation (You can use any simple graph for testing). Feel free to get help from any sources but make sure that you fully understand how the algorithm works and also show the source of your references. Then modify your code to display the entire history of the relaxation process. Also note that you need to cover at least the following 4 cases Relaxed: vertex[B]: OLD: Infinity, NEW: 4, Paths: {'B': 'A’} No edge relaxation is needed for the edge, D No un-visited outgoing edges from this node, D Then finally display the final resu

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Python code!!!!

Expected output will be posted as well as the sample for the 4 cases. Please read the directions carefully and write the code in python.

  • Read and learn how Dijkstra's SSSP algorithm works 
  • Implement the algorithm in Python including your own test driver to prove your implementation (You can use any simple graph for testing).
  • Feel free to get help from any sources but make sure that you fully understand how the algorithm works and also show the source of your references.
  • Then modify your code to display the entire history of the relaxation process.
  • Also note that you need to cover at least the following 4 cases
    • Relaxed: vertex[B]: OLD: Infinity, NEW: 4, Paths: {'B': 'A’}
    • No edge relaxation is needed for the edge, D
    • No un-visited outgoing edges from this node, D
    • Then finally display the final results

 

Example 2
4.
11
4
14
4
Undirected
8
Source node: 0 (= 0)
All other nodes: infinity
visited = {}
graph
16
4
10
min_node = None
nodes = {0..8}
Node(5) is added to Visited. Weight:11
No edge relaxation is needed for edge, 6
Node(0) is added to Visited. Weight:0
No edge relaxation is needed for edge, 2
Relaxed: vertex[1]: OLD:Infinity, NEW: 4, Paths: {'1': '0'}
Relaxed: vertex[3]: OLD:Infinity, NEW: 25, Paths: {'1': '0', '7': '0',
Relaxed: vertex[7]: OLD:Infinity, NEW: 8, Paths: {'1': '0', '7': '0'}
'2': '1', '8': '7', '6': '7', '5': '6', '3': '5'}
Node(1) is added to Visited. Weight:4
Relaxed: vertex[4]: OLD:Infinity, NEW: 21, Paths: {'1': '0', '7': '0',
No edge relaxation is needed for edge, 0
'2': '1', '8': '7', '6': '7', '5': '6', '3': '5', '4': '5'}
No edge relaxation is needed for edge, 7
No edge relaxation is needed for edge, 4
Relaxed: vertex[2]: OLD:Infinity, NEW: 12, Paths: {'1': '0', '7': '0', '2':
Node(2) is added to Visited. Weight:12
'1'}
No edge relaxation is needed for edge, 1
Node(7) is added to Visited. Weight:8
Relaxed: vertex[3]: OLD:25, NEW: 19, Paths: {'1': '0', '7': '0', '2':
'1', '8': '7', '6': '7', '5': '6', '3': '2', '4': '5'}
No edge relaxation is needed for edge, 0
No edge relaxation is needed for edge, 5
No edge relaxation is needed for edge, 1
No edge relaxation is needed for edge, 8
Relaxed: vertex[8]: OLD:Infinity, NEW: 12, Paths: {'1': '0', '7': '0', '2':
Node(8) is added to Visited. Weight:12
'1', '8': '7'}
No unvisited outgoing edges from this node, 8
Relaxed: vertex[6]: OLD:Infinity, NEW: 9, Paths: {'1': 'O', '7': '0', '2':
Node(3) is added to Visited. Weight:19
'1', '8': '7', '6': '7'}
No edge relaxation is needed for edge, 2
Node(6) is added to Visited. Weight:9
No edge relaxation is needed for edge, 4
Relaxed: vertex[5]: OLD:Infinity, NEW: 11, Paths: {'1': '0', '7': '0', '2':
No edge relaxation is needed for edge, 5
'1', '8': '7', '6': '7', '5': '6'}
Node(4) is added to Visited. Weight:21
No edge relaxation is needed for edge, 8
No edge relaxation is needed for edge, 3
No edge relaxation is needed for edge, 7
No edge relaxation is needed for edge, 5
No edge relaxation is needed for edge, 5
({'0': 0, '1': 4, '7': 8, '2': 12, '8': 12, '6': 9, '5': 11, '3': 19, '4': 21}, {'1': '0', '7':
'0', '2': '1', '8': '7', '6': '7', '5': '6', '3': '2', '4': '5'})
Transcribed Image Text:Example 2 4. 11 4 14 4 Undirected 8 Source node: 0 (= 0) All other nodes: infinity visited = {} graph 16 4 10 min_node = None nodes = {0..8} Node(5) is added to Visited. Weight:11 No edge relaxation is needed for edge, 6 Node(0) is added to Visited. Weight:0 No edge relaxation is needed for edge, 2 Relaxed: vertex[1]: OLD:Infinity, NEW: 4, Paths: {'1': '0'} Relaxed: vertex[3]: OLD:Infinity, NEW: 25, Paths: {'1': '0', '7': '0', Relaxed: vertex[7]: OLD:Infinity, NEW: 8, Paths: {'1': '0', '7': '0'} '2': '1', '8': '7', '6': '7', '5': '6', '3': '5'} Node(1) is added to Visited. Weight:4 Relaxed: vertex[4]: OLD:Infinity, NEW: 21, Paths: {'1': '0', '7': '0', No edge relaxation is needed for edge, 0 '2': '1', '8': '7', '6': '7', '5': '6', '3': '5', '4': '5'} No edge relaxation is needed for edge, 7 No edge relaxation is needed for edge, 4 Relaxed: vertex[2]: OLD:Infinity, NEW: 12, Paths: {'1': '0', '7': '0', '2': Node(2) is added to Visited. Weight:12 '1'} No edge relaxation is needed for edge, 1 Node(7) is added to Visited. Weight:8 Relaxed: vertex[3]: OLD:25, NEW: 19, Paths: {'1': '0', '7': '0', '2': '1', '8': '7', '6': '7', '5': '6', '3': '2', '4': '5'} No edge relaxation is needed for edge, 0 No edge relaxation is needed for edge, 5 No edge relaxation is needed for edge, 1 No edge relaxation is needed for edge, 8 Relaxed: vertex[8]: OLD:Infinity, NEW: 12, Paths: {'1': '0', '7': '0', '2': Node(8) is added to Visited. Weight:12 '1', '8': '7'} No unvisited outgoing edges from this node, 8 Relaxed: vertex[6]: OLD:Infinity, NEW: 9, Paths: {'1': 'O', '7': '0', '2': Node(3) is added to Visited. Weight:19 '1', '8': '7', '6': '7'} No edge relaxation is needed for edge, 2 Node(6) is added to Visited. Weight:9 No edge relaxation is needed for edge, 4 Relaxed: vertex[5]: OLD:Infinity, NEW: 11, Paths: {'1': '0', '7': '0', '2': No edge relaxation is needed for edge, 5 '1', '8': '7', '6': '7', '5': '6'} Node(4) is added to Visited. Weight:21 No edge relaxation is needed for edge, 8 No edge relaxation is needed for edge, 3 No edge relaxation is needed for edge, 7 No edge relaxation is needed for edge, 5 No edge relaxation is needed for edge, 5 ({'0': 0, '1': 4, '7': 8, '2': 12, '8': 12, '6': 9, '5': 11, '3': 19, '4': 21}, {'1': '0', '7': '0', '2': '1', '8': '7', '6': '7', '5': '6', '3': '2', '4': '5'})
Example 1 (HW6)
2
4
Source node: A (= 0)
All other nodes: infinity
visited = {}
4
min_node = None
nodes = {A,B,C,D,E}
E
Node(A) is added to Visited. Weight:0
Relaxed: vertex[B]: OLD:Infinity, NEW: 4, Paths: {'B': 'A'}
Relaxed: vertex[C]: OLD:Infinity, NEW: 2, Paths: {'B': 'A', 'C': 'A'}
Node(C) is added to Visited. Weight:2
Relaxed: vertex[D]: OLD:Infinity, NEW: 6, Paths: {'B': 'A', 'C': 'A', 'D': 'C'}
Relaxed: vertex[E]: OLD:Infinity, NEW: 7, Paths: {'B': 'A', 'C': 'A', 'D': 'C', 'E': 'C'}
Relaxed: vertex[B]: OLD:4, NEW: 3, Paths: {'B': 'C', 'C': 'A', 'D': 'C', 'E': 'C'}
Node(B) is added to Visited. Weight:3
No edge relaxation is needed for edge, C
Relaxed: vertex[E]: OLD:7, NEW: 6, Paths: {'B': 'C', 'C': 'A', 'D': 'C', ''E': 'B'}
Relaxed: vertex[D]: OLD:6, NEW: 5, Paths: {'B': 'C', 'C': 'A', 'D': 'B', 'E': 'B'}
Node(D) is added to Visited. Weight:5
No unvisited outgoing edges from this node, D
Node(E) is added to Visited. Weight:6
No edge relaxation is needed for edge, D
Final: ({'A': 0, 'B': 3, 'C': 2, 'D': 5, 'E': 6}, {'C': 'A', 'B': 'C', 'D': 'B', 'E': 'B'})
Transcribed Image Text:Example 1 (HW6) 2 4 Source node: A (= 0) All other nodes: infinity visited = {} 4 min_node = None nodes = {A,B,C,D,E} E Node(A) is added to Visited. Weight:0 Relaxed: vertex[B]: OLD:Infinity, NEW: 4, Paths: {'B': 'A'} Relaxed: vertex[C]: OLD:Infinity, NEW: 2, Paths: {'B': 'A', 'C': 'A'} Node(C) is added to Visited. Weight:2 Relaxed: vertex[D]: OLD:Infinity, NEW: 6, Paths: {'B': 'A', 'C': 'A', 'D': 'C'} Relaxed: vertex[E]: OLD:Infinity, NEW: 7, Paths: {'B': 'A', 'C': 'A', 'D': 'C', 'E': 'C'} Relaxed: vertex[B]: OLD:4, NEW: 3, Paths: {'B': 'C', 'C': 'A', 'D': 'C', 'E': 'C'} Node(B) is added to Visited. Weight:3 No edge relaxation is needed for edge, C Relaxed: vertex[E]: OLD:7, NEW: 6, Paths: {'B': 'C', 'C': 'A', 'D': 'C', ''E': 'B'} Relaxed: vertex[D]: OLD:6, NEW: 5, Paths: {'B': 'C', 'C': 'A', 'D': 'B', 'E': 'B'} Node(D) is added to Visited. Weight:5 No unvisited outgoing edges from this node, D Node(E) is added to Visited. Weight:6 No edge relaxation is needed for edge, D Final: ({'A': 0, 'B': 3, 'C': 2, 'D': 5, 'E': 6}, {'C': 'A', 'B': 'C', 'D': 'B', 'E': 'B'})
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Quicksort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education