You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I noticed that links created as g.addLink('a','b',data) are different from ('b','a',data).
Is there a native function to compare the links within
g.getLinks(a), and if there are links present, avoid to create new ones which are equivalent?
With nodes I was able to overcome with a solution like writing all the IDs of nodes within an array, and then check with IndexOf() to see if there are already present or not.
But withj links it is different, since I should check within an array of objects, and I am stacked.
Yes, use graph.hasLink(fromId, toId) function. Internally graph is stored as oriented, so link (a, b) and link (b, a) are different. You might wan to do something like this:
varoldLink=graph.hasLink(a,b)||graph.hasLink(b,a);if(oldLink){// the link is in the graph, do not add new link}else{// there is no such link}
Hi, I noticed that links created as g.addLink('a','b',data) are different from ('b','a',data).
Is there a native function to compare the links within
g.getLinks(a), and if there are links present, avoid to create new ones which are equivalent?
With nodes I was able to overcome with a solution like writing all the IDs of nodes within an array, and then check with IndexOf() to see if there are already present or not.
But withj links it is different, since I should check within an array of objects, and I am stacked.
I am looking at
http://stackoverflow.com/questions/2218999/remove-duplicates-from-an-array-of-objects-in-javascript
and similar but could make a solution work yet.
Any idea?
The text was updated successfully, but these errors were encountered: