[go: up one dir, main page]

Skip to content

A----/sigma-pathfinding-astar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sigma.pathfinding.astar.js — v1.0.1

sigma.pathfinding.astar.js is a plugin for sigma.js that computes path in a graph using a naive implementation of the A* algorithm.

Usage

Either download a tarball, git clone the repository or npm install it. Then it's pretty straight-forward.

It adds a method to your sigma.graph called astar(srcId, destId[, options]).

  • srcId, identifier of the start node;
  • destId, identification of the destination node;
  • options (optional), an object containing one or more of those properties:
    • undirected (default: false), if set to true, consider the graph as non-oriented (will explore all edges, including the inbound ones);
    • pathLengthFunction (default is the geometrical distance), a function(node1, node2, previousLength) that should return the new path length between the start node and node2, knowing that the path length between the start node and node1 is contained in previousLength.
    • heuristicLengthFunction (default: undefined), a function(node1, node2) guesses the path length between node1 and node2 (node2 actually is the destination node). If left undefined, takes the pathLengthFunction option (third parameter will be left undefined).

Return value is either:

  • undefined: no path could be found between the source node and the destination node;
  • [srcNode, …, destNode ]: an array of nodes, including source and destination node.

Check example/index.html for a live example.

Build

Use grunt or grunt watch.

Changelog

### v1.0.1 – 2015-09-16

  • Fixing suboptimal path (missing parameter in heuristic, #1)

### v1.0.0 – 2015-01-26

  • Initial release