fkling / fkling/JSNetworkX

jsnx.allPairsDijkstraPath fails with complex node types

Open
#57 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
779
Forks
178
PR merge metrics
No merged PRs in 30d

Description

The following code will work when nodes are primitive objects, but not when complex objects.

``` javascript
function test(p) {
var G = new jsnx.Graph();
G.addStar(p, {weight: 1.0});
return jsnx.allPairsDijkstraPath(G)
}

test([1,2,3,4]); // works
test([{name: "cat"},{name: "dog"},{name: "mouse"}]); // fails
test([[0,0],[0,1],[1,0]]); // fails
```

The error message is

> Uncaught TypeError: Cannot read property 'toString' of undefined(…)
> n @ jsnetworkx.js:1
> d @ jsnetworkx.js:3
> s @ jsnetworkx.js:3
> b @ jsnetworkx.js:3

Note, that the code will work when allPairsDijkstraPath is replaced with allPairsShortestPath.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.