diff options
| author | Alon Levy <alon@pobox.com> | 2015-04-12 19:05:43 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-04-12 19:06:45 +0200 |
| commit | 316b2565da8f87d9252764d8a65d94adaf6a4932 (patch) | |
| tree | 8bc1cdc16de6addbf9afcec3ccd92366fb2b3691 /src | |
| parent | dc4f1a3736b77534942f6aa0d7e549f82cfc5276 (diff) | |
client/graph: extract calc_neighbours
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/model/graph.js | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/client/model/graph.js b/src/client/model/graph.js index 580ff660..5166b642 100644 --- a/src/client/model/graph.js +++ b/src/client/model/graph.js @@ -232,6 +232,18 @@ function Graph(spec) { } this._remove_node_set = _remove_node_set; + function calc_neighbours() { + return _.reduce(get_links(), function(d, link) { + d[link.__src.id].src.push(link); + d[link.__dst.id].dst.push(link); + return d; + }, _.object(_.map(get_nodes(), "id"), + get_nodes().map(function (n) { + return {node: n, src: [], dst: []}; + }) + )); + } + /** * * neighbourhood @@ -294,15 +306,7 @@ function Graph(spec) { var nodes = get_nodes(), links = get_links(), - neighbours = _.reduce(links, function(d, link) { - d[link.__src.id].src.push(link); - d[link.__dst.id].dst.push(link); - return d; - }, _.object(_.map(nodes, "id"), - get_nodes().map(function (n) { - return {node: n, src: [], dst: []}; - }) - )), + neighbours = calc_neighbours(), exit = 1, enter = 2, selected = 4, |
