diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-05-21 00:14:38 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2014-05-21 00:14:38 +0200 |
commit | 57bfa4fe42c10e254a96817586d5e64de45cdf9d (patch) | |
tree | 2b91710f2b9e772b7c7d921ad1be0356b8e8a314 | |
parent | 14b7ade4dbeb1c62e43ac80498534c703e0dbf43 (diff) | |
download | d3viz-57bfa4fe42c10e254a96817586d5e64de45cdf9d.tar.gz |
preprocess: split edge filtering for possible re-use
Also drop a useless users assignment.
-rw-r--r-- | preprocess.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/preprocess.js b/preprocess.js index 03af077..2055382 100644 --- a/preprocess.js +++ b/preprocess.js @@ -5,14 +5,13 @@ 'use strict'; -function preprocess(data, options) { +/* find user nodes and remove invalid edges */ +function filterEdges(data) { // map userID to nodes var users = {}; data.nodes.forEach(function (user, i) { users[user.group] = user; }); - console.log('Initial nodes count:', data.nodes.length); - console.log('Initial edges count:', data.edges.length); var ratelimit_count = 0, ratelimit_max = 10; function ratelimit() { @@ -41,6 +40,12 @@ function preprocess(data, options) { if (ratelimit_count > ratelimit_max) { console.log('Supressed', ratelimit_count, 'messages'); } +} + +function preprocess(data, options) { + console.log('Initial nodes count:', data.nodes.length); + console.log('Initial edges count:', data.edges.length); + filterEdges(data); console.log('Valid edges count:', data.edges.length); // find all related users by userID @@ -61,7 +66,6 @@ function preprocess(data, options) { // prepare data for force layout: map user IDs to indices var userIds_indices = {}; data.nodes.forEach(function (user, i) { - users[user.group] = user; userIds_indices[user.group] = i; }); console.log('UserID to index map:', userIds_indices); |