semvec/pypi-packages huggingface dataset:
dijkstras 1.1.1
distance algorithm
License: MIT

# Dijkstra's algorithm

Dijkstra's algorithm is an algorithm for finding the shortest paths between nodes in a graph. There are plenty of ways to represent graph in ```python```. In this project, I used the ```dict()``` data-structure to represent graphs.

## Installation
```pip install dijkstras```

## Use Case

```
The idea is to get from Position A to Position B. Given multiple routes to get from A to B, 
what is the most optimal/shortest path that can be taken to reach the destination(B) from A.

dist_graph = {'baluwatar': {'putalisadak': 3.1, 'new_baneshwor': 5.5, 'koteshwor': 8.4},
              'putalisadak': {'ratnapark': 1.1}, 
              'ratnapark': {'dhulikhel': 29.9, 'panauti': 32.3},
              'new_baneshwor': {'dhulikhel': 26.6, 'panauti': 29}, 
              'koteshwor': {'panauti': 27.6, 'dhulikhel': 25.2}, 
              'dhulikhel': {'panauti': 11.2}, panauti': {'dhulikhel':11.2}}

Here, 'baluwatar': {'putalisadak': 3.1, 'new_baneshwor': 5.5, 'koteshwor': 8.4} implies
that the distance from  baluwatar to putalisadak is 3.1, the distance from  
baluwatar to new_baneshwor is 5.5 etc.

```
## How to use?

```python
from dijkstra import dijkstra as dj

# define a distance graph
dist_graph = {'baluwatar': {'putalisadak': 3.1, 'new_baneshwor': 5.5, 'koteshwor': 8.4},
             'putalisadak': {'ratnapark': 1.1},
             'ratnapark': {'dhulikhel': 29.9, 'panauti': 32.3},
             'new_baneshwor': {'dhulikhel': 26.6, 'panauti': 29},
             'koteshwor': {'panauti': 27.6, 'dhulikhel': 25.2},
             'dhulikhel': {'panauti': 11.2},
             'panauti': {'dhulikhel':11.2}}

# create a new object
distance = dj()

# define start-point and destination
start = "baluwatar"
destination = "dhulikhel"

# get the shortest route and minimum distance to cover
shortest_route,min_dist = distance.dijkstra_shortest_distance(dist_graph, start, destination)

# print 
print('The shortest distance is : ', min_dist)
print('The optimal-path is ', shortest_route) 
```

## License
© 2021 Roman Regmi
This repository is licensed under the MIT license. See LICENSE for details.