anvaka / ngraph.path

Path finding in a graph
https://anvaka.github.io/ngraph.path.demo/
MIT License
3.04k stars 187 forks source link

Turn penalties #11

Open j1mie opened 5 years ago

j1mie commented 5 years ago

Hi there,

I'm using this library to draw a network graph on top of a grid, and I was wondering if you could suggest how to best implement a "turn penalty", to avoid a stair-casing effect, using the distance and heuristic functions.

Thanks!

j1mie commented 5 years ago

Also, just to add - I'm currently adding weights to nodes rather than edges - is this acceptable to do, using ngraph.path?

leeoniya commented 5 years ago

related: https://github.com/anvaka/ngraph.path/issues/2, still no response :(

j1mie commented 5 years ago

Looking at the PR I linked above, it seems as though we'd need to access fromNode.parent in the distance function. @anvaka Any idea on how to do this?

georeith commented 12 months ago

I've made a PR to expose the parent node to the distance() function to enable this: https://github.com/anvaka/ngraph.path/pull/42