1
0
Fork 0

GraphViewer: Improved Similarity Join of Nodes

This commit is contained in:
Michael Hackstein 2013-05-27 10:50:24 +02:00
parent 133ca7c360
commit e024f1b0fe
4 changed files with 22 additions and 17 deletions

View File

@ -408,10 +408,10 @@ function ArangoAdapter(nodes, edges, config) {
_.each(result, function(visited) {
var node = insertNode(visited.vertex),
path = visited.path;
inserted[node._id] = true;
inserted[node._id] = node;
_.each(path.vertices, function(connectedNode) {
var ins = insertNode(connectedNode);
inserted[ins._id] = true;
inserted[ins._id] = ins;
});
_.each(path.edges, function(edge) {
insertEdge(edge);
@ -419,9 +419,12 @@ function ArangoAdapter(nodes, edges, config) {
});
delete inserted[n._id];
if (_.size(inserted) > childLimit) {
buckets = reducer.bucketNodes(_.keys(inserted), childLimit);
buckets = reducer.bucketNodes(_.values(inserted), childLimit);
_.each(buckets, function(b) {
collapseCommunity(b);
var ids = _.map(b, function(n) {
return n._id;
});
collapseCommunity(ids);
});
}
if (limit < nodes.length) {
@ -474,12 +477,8 @@ function ArangoAdapter(nodes, edges, config) {
}, function(res) {
_.each(res, self.deleteEdge);
});
},
combineNodesBySimilarity = function () {
return;
};
parseConfig(config);
api.base = arangodb.lastIndexOf("http://", 0) === 0

View File

@ -275,7 +275,7 @@ function NodeReducer(nodes, edges) {
getSimilarityValue = function(bucket, node) {
if (bucket.length === 0) {
return 1;
}
}
var comp = bucket[0],
props = _.union(_.keys(comp), _.keys(node)),
countMatch = 0,
@ -284,11 +284,11 @@ function NodeReducer(nodes, edges) {
if (comp[key] !== undefined && node[key]!== undefined) {
countMatch++;
if (comp[key] === node[key]) {
countMatch++;
countMatch += 4;
}
}
});
propCount = props.length * 2;
propCount = props.length * 5;
propCount++;
countMatch++;
return countMatch / propCount;
@ -333,7 +333,7 @@ function NodeReducer(nodes, edges) {
self.bucketNodes = function(toSort, numBuckets) {
var res = [],
threshold = 0.3;
threshold = 0.5;
if (toSort.length <= numBuckets) {
res = _.map(toSort, function(n) {
return [n];

View File

@ -112,13 +112,14 @@ function GraphViewer(svg, width, height, adapterConfig, config) {
switch (adapterConfig.type.toLowerCase()) {
case "arango":
adapterConfig.width = width;
adapterConfig.height = height;
adapterConfig.width = width;
adapterConfig.height = height;
self.adapter = new ArangoAdapter(
nodes,
edges,
adapterConfig
);
self.adapter.setChildLimit(5);
break;
case "json":
self.adapter = new JSONAdapter(

View File

@ -745,7 +745,7 @@
});
it('should add at most the upper bound of children in one step', function() {
var inNodeCol;
var inNodeCol, callNodes;
runs(function() {
var addNNodes = function(n) {
@ -778,6 +778,7 @@
var i = 0,
res = [],
pos;
callNodes = ns;
for (i = 0; i < 5; i++) {
pos = i*4;
res.push(ns.slice(pos, pos + 4));
@ -795,10 +796,14 @@
});
runs(function() {
var callNodesIds = _.map(callNodes, function(n) {
return n._id;
});
expect(this.fakeReducerBucketRequest).toHaveBeenCalledWith(
inNodeCol.slice(1),
jasmine.any(Array),
5
);
expect(callNodesIds).toEqual(inNodeCol.slice(1));
expect(nodes.length).toEqual(6);
});