Skip to content

Instantly share code, notes, and snippets.

@anvaka
Forked from arikan/forEachUnlinkedNode.js
Last active December 10, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anvaka/4444579 to your computer and use it in GitHub Desktop.
Save anvaka/4444579 to your computer and use it in GitHub Desktop.
forEachUnlinkedNode : function (nodeId, callback, oriented) {
var graph = this,
node = graph.getNode(nodeId),
linkedNodeId,
currentNodeId;
if (node && typeof callback === 'function') {
var linkedNodes = {};
graph.forEachLinkedNode(nodeId, function (node) { linkedNodes[node.id] = true; }, oriented);
for (currentNodeId in nodes) {
if (nodes.hasOwnProperty(currentNodeId) &&
!linkedNodes.hasOwnProperty(currentNodeId)) {
callback(nodes[currentNodeId]);
}
}
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment