dijkstra v1.0

Dijkstra's algorithm, conceived by computer scientist Edsger Dijkstra, is a graph search algorithm that solves in single-source shortest path problem for a graph with non-negative edge path costs, producing a shortest path tree.



Details

Author
Adrian Statescu
Current version
v1.0
GitHub
thinkphp/dijkstra
Downloads
1224
Category
Utilities
Tags
Report
GitHub Issues

Releases


Dependencies

  • core/1.5.1: *

How to use

Include the latest version MooTools Framework, then dijkstra.js into the page:


Sample

#JS

 var road = [[1, 2, 1],
            [1, 3, 9],
            [1, 5, 3],
            [2, 4, 3],
            [2, 3, 7],
            [4, 3, 2],
            [4, 1, 1],
            [5, 2, 4],
            [5, 4, 2]]

var start = 1, 
    end   = 3;

var dij = new Dijkstra(start, end, road );

console.log("Cost = " + dij.getCost() )

console.log("Shortest path from the node "+ start + " to "+ end + " -> "+ dij.getShortestPath() )

References

http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm


Discuss

A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.

Found a bug in this plugin? Please report it this repository's Github Issues.

blog comments powered by Disqus