chriswongtv / node-all-paths

JavaScript implementation to find all possible paths in a graph
MIT License
6 stars 3 forks source link

Connected graphs result in RangeError: Maximum call stack size exceeded #2

Open Leoooob opened 7 years ago

Leoooob commented 7 years ago

When you are trying to build all paths for a connected graph you end up in an infinite loop in Graph.js line 113.

Example:

Graph = require('node-all-paths');
const route = new Graph();

route.addNode('A', { B:2, C:3, D:4 });
route.addNode('B', { A:2, C:4, D:5 });
route.addNode('C', { A:3, B:4, D:6 });
route.addNode('D', { A:4, B:5, C:6 });

var possible_routes = route.path('A', 'D', { cost:true });

A redesign of the findAll function in Graph.js would fix the issue.

alexnault commented 7 years ago

He's right. The current algorithm results in an infinite loop for cyclic graphs.

macasas commented 5 years ago

It's now 1 December 2018, and I am still getting this error, so I am guessing this is not fixed as stated.

I have just 13 entries, with varying values, and I either get RangeError: Maximum call stack size exceeded or it crashes my debugger in vscode.

Is this project supported, should I be looking for a different module to do this, do you have any recommendations?