项目作者: manoelstilpen

项目描述 :
Dijkstra Algorithm in Python
高级语言: Python
项目地址: git://github.com/manoelstilpen/dijkstra_algorithm.git
创建时间: 2017-06-20T01:32:17Z
项目社区:https://github.com/manoelstilpen/dijkstra_algorithm

开源协议:GNU General Public License v3.0

下载


Dijkstra Algorithm

Dijkstra Shortest Path implementation in Python based on: https://gist.github.com/econchick/4666413

This program has three parameters:

  • --file file: specifies the file containing the graph (should follow the format in input.txt)
  • --origin node: specifies the initial node
  • --dest node: specifies the destination node — used for printing the shortest path

Input file format

The input file format should follow the model below:

The first line should contain how many nodes(n) and edges(m) you have.

The next m lines specifies the edges, for example:

  1. a b 15

In this case, we have a -> b with 15 of weight.

In the end you should specify and enumerate your n nodes as follow:

0 a

1 b