Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 521 Bytes

README.md

File metadata and controls

34 lines (27 loc) · 521 Bytes

example.png

Py-Dijkstra

Simple python implementation of dijkstra shortest path algorithm

Instructions

inputs.txt file looks like this -

a b 2
a d 8
a c 9
b a 3
b c 4
c d 1

Take input from text file like below -

    $ python dijkstra.py <filename.txt> <src> <dest>
Example -
> python dijkstra.py inputs.txt a d

Graph: 
-------
{'a': {'c': 9, 'b': 2, 'd': 8}, 'c': {'d': 1}, 'b': {'a': 3, 'c': 4}}

Shortest Paths: 
---------------
a -> b -> c -> d : 7