From ee62b20842373d346f467b6e57ea83a2a82c9221 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Wed, 3 Dec 2014 19:09:58 +0200 Subject: graph: getConnectedNodesAndLinks: exclude given nodes from return --- src/model/graph.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/model/graph.js') diff --git a/src/model/graph.js b/src/model/graph.js index b6ab95ea..ea715655 100644 --- a/src/model/graph.js +++ b/src/model/graph.js @@ -132,6 +132,13 @@ function Graph() { link2, ret = {'nodes':[], 'links':[]}; + function addNode(node) { + if (chosen_nodes.filter(function (n) { return n.id == node.id; }).length == 1) { + return; + } + ret.nodes.push(node); + } + if (chosen_nodes === undefined) { console.log('getConnectedNodesAndLinks: bug: called with undefined node'); return; @@ -152,7 +159,7 @@ function Graph() { if (compareNames(link.__src.name, n.name)) { adjacentnode = findNode(link.__dst.id, null); if (adjacentnode.state !== "temp") { - ret.nodes.push({type: 'exit', node: adjacentnode}); + addNode({type: 'exit', node: adjacentnode}); } ret.links.push({type: 'exit', link: link}); @@ -164,7 +171,7 @@ function Graph() { link2.__dst.state !== "temp") { adjacentnode = findNode(link2.__src.id, null); if (adjacentnode.state !== "temp") { - ret.nodes.push({type: 'enter', node: adjacentnode}); + addNode({type: 'enter', node: adjacentnode}); } ret.links.push({type: 'enter', link: link2}); } @@ -175,7 +182,9 @@ function Graph() { } if (compareNames(links[i].__dst.name, n.name)) { adjacentnode = findNode(links[i].__src.id, null); - if (adjacentnode.state !== "temp") adjacentnode.state = "enter"; + if (adjacentnode.state !== "temp") { + adjacentnode.state = "enter"; + } links[i].state = "enter"; } }); -- cgit v1.3.1