Graph database Analysis of the Steam Network
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
1.8 KiB

  1. sigma.pathfinding.astar.js — v1.0.0
  2. ===================================
  3. > Plugin author: [@A----](https://github.com/A----)
  4. > Main repository for this plugin is here: https://github.com/A----/sigma-pathfinding-astar
  5. > Please report issues, make PR, there.
  6. > This project is released under Public Domain license (see LICENSE for more information).
  7. *sigma.pathfinding.astar.js* is a plugin for [sigma.js](http://sigmajs.org) that computes path in a graph
  8. using a naive implementation of the [A*](http://en.wikipedia.org/wiki/A*_search_algorithm) algorithm.
  9. ## Usage
  10. Either download a tarball, `git clone` the repository or `npm install` it. Then it's pretty straight-forward.
  11. It adds a method to your `sigma.graph` called `astar(srcId, destId[, options])`.
  12. - `srcId`, identifier of the start node;
  13. - `destId`, identification of the destination node;
  14. - `options` (optional), an object containing one or more of those properties:
  15. - `undirected` (default: `false`), if set to `true`, consider the graph as non-oriented (will explore all edges, including the inbound ones);
  16. - `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`.
  17. - `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).
  18. Return value is either:
  19. - `undefined`: no path could be found between the source node and the destination node;
  20. - `[srcNode, …, destNode ]`: an array of nodes, including source and destination node.