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

View File

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

View File

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

View File

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