anvaka / anvaka/ngraph.forcelayout

defaultNodeMass returns NaN

Open
#18 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
215
Forks
33
PR merge metrics
No merged PRs in 30d

Description

defaultNodeMass returns NaN and *Node mass should be a number* is thrown

https://github.com/anvaka/ngraph.forcelayout/blob/f1c47b57035869750a9bfbe9336dee63eba1e90d/index.js#L388

seems that *links* does not have *length* but *size*, as newer **graph.getLinks** does not return *array* anymore

as a temporary workaround **nodeMass** function in physicsSettings helps..

```
nodeMass : (nodeId) => {
const links = graph.getLinks(nodeId);
if (links && links.length) return 1 + links.length / 3.0;
else if (links && links.size) return 1 + links.size / 3.0;
else return 1
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at index.js line 388, where defaultNodeMass uses graph.getLinks(nodeId), and compare the returned object's size behavior with the issue's nodeMass workaround. Confirm that the default mass is numeric for graphs whose links collection has size rather than length, and verify that the *Node mass should be a number* error no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.