diff --git a/html/admin/js/graphViewer/graph/nodeReducer.js b/html/admin/js/graphViewer/graph/nodeReducer.js
index 9ee11bd0c0..6c63570ef3 100644
--- a/html/admin/js/graphViewer/graph/nodeReducer.js
+++ b/html/admin/js/graphViewer/graph/nodeReducer.js
@@ -37,9 +37,50 @@ function NodeReducer(nodes, edges) {
throw "Edges have to be given.";
}
- var self = this;
+ var self = this,
+ getDegree = function(id) {
+ return $.grep(nodes, function(e){
+ return e._id === id;
+ })[0];
+ },
+
+ // Will Overwrite dQ, a and heap!
+ populateValues = function(dQ, a, heap) {
+ var m = edges.length,
+ twoM = 2 * m,
+ cFact = 1 / twoM;
+ _.each(nodes, function(n) {
+ a[n._id] = (n._outboundCounter + n._inboundCounter) / twoM;
+ });
+
+ _.each(edges, function(e) {
+ var sID, lID;
+ if (e.source._id < e.target._id) {
+ sID = e.source._id;
+ lID = e.target._id;
+ } else {
+ sID = e.target._id;
+ lID = e.source._id;
+ }
+ if (dQ[sID] === undefined) {
+ dQ[sID] = {};
+ heap[sID] = {};
+ heap[sID].val = -1;
+ }
+ dQ[sID][lID] = cFact - a[sID] * a[lID];
+ if (heap[sID].val < dQ[sID][lID]) {
+ heap[sID].val = dQ[sID][lID];
+ heap[sID].lID = lID;
+ }
+ });
+ };
self.getCommunity = function(limit, focus) {
+ var dQ = {},
+ a = {},
+ heap = {};
+ populateValues(dQ, a, heap);
+
return [];
};
}
diff --git a/html/admin/js/graphViewer/jasmine_test/helper/objectsHelper.js b/html/admin/js/graphViewer/jasmine_test/helper/objectsHelper.js
index c31215e15b..03394e6e52 100644
--- a/html/admin/js/graphViewer/jasmine_test/helper/objectsHelper.js
+++ b/html/admin/js/graphViewer/jasmine_test/helper/objectsHelper.js
@@ -48,7 +48,25 @@ var helper = helper || {};
});
return nodes;
};
+
+ helper.insertSimpleNodes = function (nodes, ids) {
+ _.each(ids, function(i) {
+ nodes.push({
+ _id: i,
+ _inboundCounter: 0,
+ _outboundCounter: 0,
+ position: {
+ x: 1,
+ y: 1,
+ z: 1
+ }
+ });
+ });
+ };
+
helper.createSimpleEdge = function(nodes, s, t) {
+ nodes[s]._outboundCounter++;
+ nodes[t]._inboundCounter++;
return {
source: nodes[s],
target: nodes[t]
diff --git a/html/admin/js/graphViewer/jasmine_test/specNodeReducer/nodeReducerSpec.js b/html/admin/js/graphViewer/jasmine_test/specNodeReducer/nodeReducerSpec.js
index dc3b6c41e1..0ba0441bad 100644
--- a/html/admin/js/graphViewer/jasmine_test/specNodeReducer/nodeReducerSpec.js
+++ b/html/admin/js/graphViewer/jasmine_test/specNodeReducer/nodeReducerSpec.js
@@ -106,8 +106,7 @@
describe('checking community identification', function() {
it('should be able to identify an obvious community', function() {
- nodes = helper.createSimpleNodes([0, 1, 2, 3, 4]);
- edges = [];
+ helper.insertSimpleNodes(nodes, [0, 1, 2, 3, 4]);
edges.push(helper.createSimpleEdge(nodes, 0, 1));
edges.push(helper.createSimpleEdge(nodes, 0, 2));
edges.push(helper.createSimpleEdge(nodes, 0, 3));