Bellman-Ford
Bellman-Ford implementation
Overview
This application computes the shortest paths between all vertex pairs in a directed
graph using the
Bellman-Ford algorithm.
It returns the total cost of the shortest of the shortest paths, and detects
if there is a negative-cost directed cycle within the graph (in which case the cost
of the shortest paths is invalid).
The graph must be represented by an adjacency list in a text file. The first line
must contain the number of verticies in the graph. Each additional line must contain
three integers representing an edge, with the first integer being the id of the tail
vertex, the second the id of the head vertex, and the third the edge cost. Vertex ids
must range from 1 to n, the total number of verticies.
Usage
go run main.go -i paths.txt
2018/04/24 14:48:12 The min path was of cost -4
2018/04/24 14:48:12 There was a negative cost cycle detected.