-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix handling of node id's in saveAndLoad example #2943
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me, and solves the problem. Well done.
One minor loopstyle comment
Perhaps a separate commit but maybe the util should be changed to
function getScaleFreeNetwork(nodeCount, prefix) {
....
if (i == 1) {
var from = i;
var to = 0;
edges.push({
from: prefix + from,
to: prefix + to
});
To make this easy to test (imagen that might be interesting in other examples too)
| function getNodeById(data, id) { | ||
| var foundNode; | ||
|
|
||
| data.forEach(function(node) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a minor thing but in this looping an old fashioned
for(var i=0 )
has the benefit of being able to
break;
or even a
return node;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
| function getEdgeData(data) { | ||
| var networkEdges = []; | ||
|
|
||
| data.forEach(function(node, index, array) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array variable no longer needed, could be kept for consistency perhaps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Also removed index
👍 Thanks
At this moment, I do not see the utility of adding a |
|
The reason to introduce a parameter like that was to make it easy to test
with IDs that are not array indexes. I used that to verify the issue at
hand.
…On 21 April 2017 at 10:03, wimrijnders ***@***.***> wrote:
It looks good to me, and solves the problem. Well done.
👍 Thanks
Perhaps a separate commit but maybe the util should be changed to...
At this moment, I do not see the utility of adding a prefix parameter. If
you feel that it is a worthwhile addition, feel free to make an issue for
this (preferably with motivation).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2943 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ASqgQy_H6t490QzGTgnn-EEAaSPzbCEyks5ryGK1gaJpZM4MwtxA>
.
--
------------------------------
Rasmus Hedin
CTO and CoFounder
Block Zero
+46706066776
[email protected]
|
bradh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems OK.
Fix for issue #2938.
In the
saveAndLoadexample, node id's got replaced by array id's, leading to inconsistent data. This PR ensures that node id's are always used.