summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-12-03 19:09:58 +0200
committerAlon Levy <alon@pobox.com>2014-12-04 00:04:03 +0200
commitee62b20842373d346f467b6e57ea83a2a82c9221 (patch)
tree7a87b0d189caa5c2030c28ec62e7018f96069d36
parent3959ebafc6ea1afd488d00c580b112e1a5824b6a (diff)
graph: getConnectedNodesAndLinks: exclude given nodes from return
-rw-r--r--src/model/graph.js15
1 files changed, 12 insertions, 3 deletions
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";
}
});