mirror of https://gitee.com/bigwinds/arangodb
GraphViewer: Fixed a bug in the modularity joiner when removing an edge.
This commit is contained in:
parent
763c482bb6
commit
f52e234993
|
@ -326,10 +326,7 @@ function AbstractAdapter(nodes, edges, descendant) {
|
|||
case "getCommunity":
|
||||
collapseCommunity(data.result);
|
||||
break;
|
||||
case "insertEdge":
|
||||
break;
|
||||
case "deleteEdge":
|
||||
break;
|
||||
default:
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -84,12 +84,24 @@ function EdgeShaper(parent, flags, idfunc) {
|
|||
},
|
||||
|
||||
getDistance = function(s, t) {
|
||||
return Math.sqrt(
|
||||
if (!s || !s.x || !s.y) {
|
||||
console.log("Source not defined!");
|
||||
console.log(s);
|
||||
}
|
||||
if (!t || !t.x || !t.y) {
|
||||
console.log("Target not defined!");
|
||||
console.log(t);
|
||||
}
|
||||
var res = Math.sqrt(
|
||||
(t.y - s.y)
|
||||
* (t.y - s.y)
|
||||
+ (t.x - s.x)
|
||||
* (t.x - s.x)
|
||||
);
|
||||
if (res === Number.NaN) {
|
||||
console.log(t.x, t.y, s.x, s.y);
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
||||
addEvents = function (line, g) {
|
||||
|
|
|
@ -323,14 +323,26 @@ function ModularityJoiner() {
|
|||
|
||||
deleteEdge = function(s, t) {
|
||||
if (matrix[s]) {
|
||||
delete matrix[s][t];
|
||||
delete backwardMatrix[t][s];
|
||||
matrix[s][t]--;
|
||||
if (matrix[s][t] === 0) {
|
||||
delete matrix[s][t];
|
||||
}
|
||||
backwardMatrix[t][s]--;
|
||||
if (backwardMatrix[t][s] === 0) {
|
||||
delete backwardMatrix[t][s];
|
||||
}
|
||||
degrees[s]._out--;
|
||||
degrees[t]._in--;
|
||||
m--;
|
||||
revM = Math.pow(m, -1);
|
||||
if (m > 0) {
|
||||
revM = Math.pow(m, -1);
|
||||
} else {
|
||||
revM = 0;
|
||||
}
|
||||
if (_.isEmpty(matrix[s])) {
|
||||
delete matrix[s];
|
||||
}
|
||||
if (_.isEmpty(backwardMatrix[t])) {
|
||||
delete backwardMatrix[t];
|
||||
}
|
||||
if (degrees[s]._in === 0 && degrees[s]._out === 0) {
|
||||
|
@ -339,6 +351,13 @@ function ModularityJoiner() {
|
|||
if (degrees[t]._in === 0 && degrees[t]._out === 0) {
|
||||
delete degrees[t];
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
self.postMessage({
|
||||
cmd: "debug",
|
||||
result: "Source not stored",
|
||||
});
|
||||
*/
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -632,7 +651,5 @@ function ModularityJoiner() {
|
|||
|
||||
this.joinCommunity = joinCommunity;
|
||||
|
||||
this.getCommunity = getCommunity;
|
||||
|
||||
|
||||
this.getCommunity = getCommunity;
|
||||
}
|
||||
|
|
|
@ -70,23 +70,24 @@ function WebWorkerWrapper(Class, callback) {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
var msg = {
|
||||
cmd: e.data.cmd
|
||||
},
|
||||
res;
|
||||
if (w && typeof w[e.data.cmd] === "function") {
|
||||
try {
|
||||
self.postMessage({
|
||||
cmd: e.data.cmd,
|
||||
result: w[e.data.cmd].apply(w, e.data.args)
|
||||
});
|
||||
res = w[e.data.cmd].apply(w, e.data.args);
|
||||
if (res) {
|
||||
msg.result = res;
|
||||
}
|
||||
self.postMessage(msg);
|
||||
} catch (err1) {
|
||||
self.postMessage({
|
||||
cmd: e.data.cmd,
|
||||
error: err1.message || err1
|
||||
});
|
||||
msg.error = err1.message || err1;
|
||||
self.postMessage(msg);
|
||||
}
|
||||
} else {
|
||||
self.postMessage({
|
||||
cmd: e.data.cmd,
|
||||
error: "Method not known"
|
||||
});
|
||||
msg.error = "Method not known";
|
||||
self.postMessage(msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -323,9 +323,33 @@
|
|||
});
|
||||
});
|
||||
|
||||
it('should only remove one of the edges on delete', function() {
|
||||
joiner.insertEdge("1", "2");
|
||||
joiner.insertEdge("1", "2");
|
||||
|
||||
joiner.deleteEdge("1", "2");
|
||||
expect(joiner.getAdjacencyMatrix()).toEqual({
|
||||
"0": {
|
||||
"1": 1,
|
||||
"3": 1
|
||||
},
|
||||
"1": {
|
||||
"2": 2
|
||||
},
|
||||
"2": {
|
||||
"1": 1,
|
||||
"3": 1
|
||||
},
|
||||
"3": {
|
||||
"0": 1,
|
||||
"1": 1,
|
||||
"2": 1
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('the degrees', function() {
|
||||
|
||||
var m, one, two, three, initDeg;
|
||||
|
@ -382,7 +406,6 @@
|
|||
|
||||
});
|
||||
|
||||
|
||||
describe('the deltaQ', function() {
|
||||
|
||||
var m, zero, one, two, three, initDQ,
|
||||
|
@ -643,7 +666,6 @@
|
|||
|
||||
});
|
||||
|
||||
|
||||
describe('checking multiple executions', function() {
|
||||
|
||||
it('should be able to recompute the joining', function() {
|
||||
|
@ -673,7 +695,23 @@
|
|||
|
||||
});
|
||||
|
||||
|
||||
describe('checking massively insertion/deletion of edges', function() {
|
||||
|
||||
it('should be possible to keep a consistent adj. matrix', function() {
|
||||
|
||||
joiner.deleteEdge("0", "1");
|
||||
joiner.deleteEdge("0", "3");
|
||||
joiner.deleteEdge("1", "2");
|
||||
joiner.deleteEdge("2", "1");
|
||||
joiner.deleteEdge("2", "3");
|
||||
joiner.deleteEdge("3", "0");
|
||||
joiner.deleteEdge("3", "1");
|
||||
joiner.deleteEdge("3", "2");
|
||||
|
||||
expect(joiner.getAdjacencyMatrix()).toEqual({});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
@ -1114,7 +1152,7 @@
|
|||
});
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
describe('checking large networks', function() {
|
||||
|
||||
it('should be able to handle 1000 nodes', function() {
|
||||
|
@ -1673,7 +1711,7 @@
|
|||
});
|
||||
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
it('should be able to handle 10000 nodes', function() {
|
||||
|
|
Loading…
Reference in New Issue