ngraph.path icon indicating copy to clipboard operation
ngraph.path copied to clipboard

Unable to use blocked and distance

Open nalasark opened this issue 2 years ago • 1 comments

When I create a pathfinder that uses both blocked and distance, the blocked always gets ignored. Am I doing something wrong?

graph.addLink("shopA","liftA",{weight:10, wheelchair: true});
graph.addLink("liftA","liftB",{weight:1, wheelchair: true});
graph.addLink("liftB","shopB",{weight:10, wheelchair: true});
graph.addLink("shopA","stairsA",{weight:5, wheelchair: true});
graph.addLink("stairsA","stairsB",{weight:1, wheelchair: false});
graph.addLink("stairsB","shopB",{weight:5, wheelchair: true});

let pathFinder_wc = ngraphPath.aStar(graph, {
    blocked(fromNode, toNode, link) {
        return !link.data.wheelchair;
    },
    distance(fromNode, toNode, link) {
        return link.data.weight;
    },
});

let path = pathFinder_wc.find("shopA","shopB");

path always returns the shortest regardless of stairsA -> stairsB is wheelchair false

nalasark avatar Sep 09 '23 08:09 nalasark

Can you please confirm version of the ngraph.path library? blocked was added just recently by @bemisguided and if you still have an older version - you might not have it.

If indeed you have the latest version - what happens when you set a breakpoint in the blocked callback?

anvaka avatar Sep 10 '23 17:09 anvaka