mirror of https://gitee.com/bigwinds/arangodb
GraphViewer: Added an abstract version of the adapter which does plain handling of nodes, server-connection is implemented in a more specific class
This commit is contained in:
parent
555322214a
commit
e7b735fd9a
|
@ -0,0 +1,387 @@
|
||||||
|
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||||
|
/*global $, _ */
|
||||||
|
/*global NodeReducer */
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief Graph functionality
|
||||||
|
///
|
||||||
|
/// @file
|
||||||
|
///
|
||||||
|
/// DISCLAIMER
|
||||||
|
///
|
||||||
|
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
||||||
|
///
|
||||||
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
/// you may not use this file except in compliance with the License.
|
||||||
|
/// You may obtain a copy of the License at
|
||||||
|
///
|
||||||
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
///
|
||||||
|
/// Unless required by applicable law or agreed to in writing, software
|
||||||
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
/// See the License for the specific language governing permissions and
|
||||||
|
/// limitations under the License.
|
||||||
|
///
|
||||||
|
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||||
|
///
|
||||||
|
/// @author Michael Hackstein
|
||||||
|
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
function AbstractAdapter(nodes, edges) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
if (nodes === undefined) {
|
||||||
|
throw "The nodes have to be given.";
|
||||||
|
}
|
||||||
|
if (edges === undefined) {
|
||||||
|
throw "The edges have to be given.";
|
||||||
|
}
|
||||||
|
|
||||||
|
var self = this,
|
||||||
|
initialX = {},
|
||||||
|
initialY = {},
|
||||||
|
cachedCommunities = {},
|
||||||
|
joinedInCommunities = {},
|
||||||
|
limit,
|
||||||
|
reducer,
|
||||||
|
childLimit,
|
||||||
|
exports = {},
|
||||||
|
|
||||||
|
setWidth = function(w) {
|
||||||
|
initialX.range = w / 2;
|
||||||
|
initialX.start = w / 4;
|
||||||
|
initialX.getStart = function () {
|
||||||
|
return this.start + Math.random() * this.range;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
setHeight = function(h) {
|
||||||
|
initialY.range = h / 2;
|
||||||
|
initialY.start = h / 4;
|
||||||
|
initialY.getStart = function () {
|
||||||
|
return this.start + Math.random() * this.range;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
findNode = function(id) {
|
||||||
|
var intId = joinedInCommunities[id] || id,
|
||||||
|
res = $.grep(nodes, function(e){
|
||||||
|
return e._id === intId;
|
||||||
|
});
|
||||||
|
if (res.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (res.length === 1) {
|
||||||
|
return res[0];
|
||||||
|
}
|
||||||
|
throw "Too many nodes with the same ID, should never happen";
|
||||||
|
},
|
||||||
|
|
||||||
|
findEdge = function(id) {
|
||||||
|
var res = $.grep(edges, function(e){
|
||||||
|
return e._id === id;
|
||||||
|
});
|
||||||
|
if (res.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (res.length === 1) {
|
||||||
|
return res[0];
|
||||||
|
}
|
||||||
|
throw "Too many edges with the same ID, should never happen";
|
||||||
|
},
|
||||||
|
|
||||||
|
insertNode = function(data) {
|
||||||
|
var node = {
|
||||||
|
_data: data,
|
||||||
|
_id: data._id
|
||||||
|
},
|
||||||
|
n = findNode(node._id);
|
||||||
|
if (n) {
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
node.x = initialX.getStart();
|
||||||
|
node.y = initialY.getStart();
|
||||||
|
nodes.push(node);
|
||||||
|
node._outboundCounter = 0;
|
||||||
|
node._inboundCounter = 0;
|
||||||
|
return node;
|
||||||
|
},
|
||||||
|
|
||||||
|
insertEdge = function(data) {
|
||||||
|
var source,
|
||||||
|
target,
|
||||||
|
edge = {
|
||||||
|
_data: data,
|
||||||
|
_id: data._id
|
||||||
|
},
|
||||||
|
e = findEdge(edge._id),
|
||||||
|
edgeToPush;
|
||||||
|
if (e) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
source = findNode(data._from);
|
||||||
|
target = findNode(data._to);
|
||||||
|
if (!source) {
|
||||||
|
throw "Unable to insert Edge, source node not existing " + edge._from;
|
||||||
|
}
|
||||||
|
if (!target) {
|
||||||
|
throw "Unable to insert Edge, target node not existing " + edge._to;
|
||||||
|
}
|
||||||
|
edge.source = source;
|
||||||
|
edge.target = target;
|
||||||
|
edges.push(edge);
|
||||||
|
|
||||||
|
|
||||||
|
if (cachedCommunities[source._id] !== undefined) {
|
||||||
|
edgeToPush = {};
|
||||||
|
edgeToPush.type = "s";
|
||||||
|
edgeToPush.id = edge._id;
|
||||||
|
edgeToPush.source = $.grep(cachedCommunities[source._id].nodes, function(e){
|
||||||
|
return e._id === data._from;
|
||||||
|
})[0];
|
||||||
|
edgeToPush.source._outboundCounter++;
|
||||||
|
cachedCommunities[source._id].edges.push(edgeToPush);
|
||||||
|
} else {
|
||||||
|
source._outboundCounter++;
|
||||||
|
}
|
||||||
|
if (cachedCommunities[target._id] !== undefined) {
|
||||||
|
edgeToPush = {};
|
||||||
|
edgeToPush.type = "t";
|
||||||
|
edgeToPush.id = edge._id;
|
||||||
|
edgeToPush.target = $.grep(cachedCommunities[target._id].nodes, function(e){
|
||||||
|
return e._id === data._to;
|
||||||
|
})[0];
|
||||||
|
edgeToPush.target._inboundCounter++;
|
||||||
|
cachedCommunities[target._id].edges.push(edgeToPush);
|
||||||
|
} else {
|
||||||
|
target._inboundCounter++;
|
||||||
|
}
|
||||||
|
return edge;
|
||||||
|
},
|
||||||
|
|
||||||
|
removeNode = function (node) {
|
||||||
|
var i;
|
||||||
|
for ( i = 0; i < nodes.length; i++ ) {
|
||||||
|
if ( nodes[i] === node ) {
|
||||||
|
nodes.splice( i, 1 );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
removeEdge = function (edge) {
|
||||||
|
var i;
|
||||||
|
for ( i = 0; i < edges.length; i++ ) {
|
||||||
|
if ( edges[i] === edge ) {
|
||||||
|
edges.splice( i, 1 );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
removeEdgesForNode = function (node) {
|
||||||
|
var i;
|
||||||
|
for (i = 0; i < edges.length; i++ ) {
|
||||||
|
if (edges[i].source === node) {
|
||||||
|
node._outboundCounter--;
|
||||||
|
edges[i].target._inboundCounter--;
|
||||||
|
edges.splice( i, 1 );
|
||||||
|
i--;
|
||||||
|
} else if (edges[i].target === node) {
|
||||||
|
node._inboundCounter--;
|
||||||
|
edges[i].source._outboundCounter--;
|
||||||
|
edges.splice( i, 1 );
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
combineCommunityEdges = function (nodes, commNode) {
|
||||||
|
var i, j, s, t,
|
||||||
|
cachedCommEdges = cachedCommunities[commNode._id].edges,
|
||||||
|
edgeToPush;
|
||||||
|
for (i = 0; i < edges.length; i++ ) {
|
||||||
|
edgeToPush = {};
|
||||||
|
// s and t keep old values yay!
|
||||||
|
s = edges[i].source;
|
||||||
|
t = edges[i].target;
|
||||||
|
for (j = 0; j < nodes.length; j++) {
|
||||||
|
if (s === nodes[j]) {
|
||||||
|
if (edgeToPush.type !== undefined) {
|
||||||
|
edges[i].target = edgeToPush.target;
|
||||||
|
delete edgeToPush.target;
|
||||||
|
edgeToPush.type = "b";
|
||||||
|
edgeToPush.edge = edges[i];
|
||||||
|
edges.splice( i, 1 );
|
||||||
|
i--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
edges[i].source = commNode;
|
||||||
|
edgeToPush.type = "s";
|
||||||
|
edgeToPush.id = edges[i]._id;
|
||||||
|
edgeToPush.source = s;
|
||||||
|
}
|
||||||
|
if (t === nodes[j]) {
|
||||||
|
if (edgeToPush.type !== undefined) {
|
||||||
|
edges[i].source = edgeToPush.source;
|
||||||
|
delete edgeToPush.source;
|
||||||
|
edgeToPush.type = "b";
|
||||||
|
edgeToPush.edge = edges[i];
|
||||||
|
edges.splice( i, 1 );
|
||||||
|
i--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
edges[i].target = commNode;
|
||||||
|
edgeToPush.type = "t";
|
||||||
|
edgeToPush.id = edges[i]._id;
|
||||||
|
edgeToPush.target = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (edgeToPush.type !== undefined) {
|
||||||
|
cachedCommEdges.push(edgeToPush);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Helper function to easily remove all outbound edges for one node
|
||||||
|
removeOutboundEdgesFromNode = function ( node ) {
|
||||||
|
if (node._outboundCounter > 0) {
|
||||||
|
var removed = [],
|
||||||
|
i;
|
||||||
|
for ( i = 0; i < edges.length; i++ ) {
|
||||||
|
if ( edges[i].source === node ) {
|
||||||
|
removed.push(edges[i]);
|
||||||
|
node._outboundCounter--;
|
||||||
|
edges[i].target._inboundCounter--;
|
||||||
|
edges.splice( i, 1 );
|
||||||
|
if (node._outboundCounter === 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
collapseCommunity = function (community) {
|
||||||
|
var commId = "*community_" + Math.floor(Math.random()* 1000000),
|
||||||
|
commNode = {
|
||||||
|
_id: commId,
|
||||||
|
edges: []
|
||||||
|
},
|
||||||
|
nodesToRemove = _.map(community, function(id) {
|
||||||
|
return findNode(id);
|
||||||
|
});
|
||||||
|
commNode.x = nodesToRemove[0].x;
|
||||||
|
commNode.y = nodesToRemove[0].y;
|
||||||
|
cachedCommunities[commId] = {};
|
||||||
|
cachedCommunities[commId].nodes = nodesToRemove;
|
||||||
|
cachedCommunities[commId].edges = [];
|
||||||
|
|
||||||
|
combineCommunityEdges(nodesToRemove, commNode);
|
||||||
|
_.each(nodesToRemove, function(n) {
|
||||||
|
joinedInCommunities[n._id] = commId;
|
||||||
|
removeNode(n);
|
||||||
|
});
|
||||||
|
nodes.push(commNode);
|
||||||
|
},
|
||||||
|
|
||||||
|
expandCommunity = function (commNode) {
|
||||||
|
var commId = commNode._id,
|
||||||
|
nodesToAdd = cachedCommunities[commId].nodes,
|
||||||
|
edgesToChange = cachedCommunities[commId].edges,
|
||||||
|
com;
|
||||||
|
removeNode(commNode);
|
||||||
|
if (limit < nodes.length + nodesToAdd.length) {
|
||||||
|
com = reducer.getCommunity(limit);
|
||||||
|
collapseCommunity(com);
|
||||||
|
}
|
||||||
|
_.each(nodesToAdd, function(n) {
|
||||||
|
delete joinedInCommunities[n._id];
|
||||||
|
nodes.push(n);
|
||||||
|
});
|
||||||
|
_.each(edgesToChange, function(e) {
|
||||||
|
var edge;
|
||||||
|
switch(e.type) {
|
||||||
|
case "t":
|
||||||
|
edge = findEdge(e.id);
|
||||||
|
edge.target = e.target;
|
||||||
|
break;
|
||||||
|
case "s":
|
||||||
|
edge = findEdge(e.id);
|
||||||
|
edge.source = e.source;
|
||||||
|
break;
|
||||||
|
case "b":
|
||||||
|
edges.push(e.edge);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
delete cachedCommunities[commId];
|
||||||
|
},
|
||||||
|
|
||||||
|
checkSizeOfInserted = function (inserted) {
|
||||||
|
var buckets;
|
||||||
|
if (_.size(inserted) > childLimit) {
|
||||||
|
buckets = reducer.bucketNodes(_.values(inserted), childLimit);
|
||||||
|
_.each(buckets, function(b) {
|
||||||
|
if (b.length > 1) {
|
||||||
|
var ids = _.map(b, function(n) {
|
||||||
|
return n._id;
|
||||||
|
});
|
||||||
|
collapseCommunity(ids);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
checkNodeLimit = function (focus) {
|
||||||
|
if (limit < nodes.length) {
|
||||||
|
var com = reducer.getCommunity(limit, focus);
|
||||||
|
collapseCommunity(com);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setNodeLimit = function (pLimit, callback) {
|
||||||
|
limit = pLimit;
|
||||||
|
if (limit < nodes.length) {
|
||||||
|
var com = reducer.getCommunity(limit);
|
||||||
|
collapseCommunity(com);
|
||||||
|
if (callback !== undefined) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setChildLimit = function (pLimit) {
|
||||||
|
childLimit = pLimit;
|
||||||
|
};
|
||||||
|
|
||||||
|
childLimit = Number.POSITIVE_INFINITY;
|
||||||
|
|
||||||
|
reducer = new NodeReducer(nodes, edges);
|
||||||
|
|
||||||
|
initialX.getStart = function() {return 0;};
|
||||||
|
initialY.getStart = function() {return 0;};
|
||||||
|
|
||||||
|
exports.setWidth = setWidth;
|
||||||
|
exports.setHeight = setHeight;
|
||||||
|
exports.insertNode = insertNode;
|
||||||
|
exports.insertEdge = insertEdge;
|
||||||
|
|
||||||
|
exports.removeNode = removeNode;
|
||||||
|
exports.removeEdge = removeEdge;
|
||||||
|
exports.removeEdgesForNode = removeEdgesForNode;
|
||||||
|
|
||||||
|
exports.expandCommunity = expandCommunity;
|
||||||
|
|
||||||
|
exports.setNodeLimit = setNodeLimit;
|
||||||
|
exports.setChildLimit = setChildLimit;
|
||||||
|
|
||||||
|
exports.checkSizeOfInserted = checkSizeOfInserted;
|
||||||
|
exports.checkNodeLimit = checkNodeLimit;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
/*jslint indent: 2, nomen: true, maxlen: 100, white: true plusplus: true */
|
||||||
/*global $, d3, _, console, document*/
|
/*global $, d3, _, console, document*/
|
||||||
/*global NodeReducer*/
|
/*global AbstractAdapter*/
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Graph functionality
|
/// @brief Graph functionality
|
||||||
///
|
///
|
||||||
|
@ -48,41 +48,15 @@ function ArangoAdapter(nodes, edges, config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this,
|
var self = this,
|
||||||
initialX = {},
|
absAdapter = new AbstractAdapter(nodes, edges),
|
||||||
initialY = {},
|
|
||||||
api = {},
|
api = {},
|
||||||
queries = {},
|
queries = {},
|
||||||
cachedCommunities = {},
|
|
||||||
joinedInCommunities = {},
|
|
||||||
nodeCollection,
|
nodeCollection,
|
||||||
edgeCollection,
|
edgeCollection,
|
||||||
limit,
|
|
||||||
childLimit,
|
|
||||||
reducer,
|
|
||||||
arangodb,
|
arangodb,
|
||||||
width,
|
|
||||||
height,
|
|
||||||
direction,
|
direction,
|
||||||
|
|
||||||
setWidth = function(w) {
|
|
||||||
initialX.range = w / 2;
|
|
||||||
initialX.start = w / 4;
|
|
||||||
initialX.getStart = function () {
|
|
||||||
return this.start + Math.random() * this.range;
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
setHeight = function(h) {
|
|
||||||
initialY.range = h / 2;
|
|
||||||
initialY.start = h / 4;
|
|
||||||
initialY.getStart = function () {
|
|
||||||
return this.start + Math.random() * this.range;
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
parseConfig = function(config) {
|
parseConfig = function(config) {
|
||||||
initialX.getStart = function() {return 0;};
|
|
||||||
initialY.getStart = function() {return 0;};
|
|
||||||
nodeCollection = config.nodeCollection;
|
nodeCollection = config.nodeCollection;
|
||||||
edgeCollection = config.edgeCollection;
|
edgeCollection = config.edgeCollection;
|
||||||
if (config.host === undefined) {
|
if (config.host === undefined) {
|
||||||
|
@ -91,10 +65,10 @@ function ArangoAdapter(nodes, edges, config) {
|
||||||
arangodb = config.host;
|
arangodb = config.host;
|
||||||
}
|
}
|
||||||
if (config.width !== undefined) {
|
if (config.width !== undefined) {
|
||||||
setWidth(config.width);
|
absAdapter.setWidth(config.width);
|
||||||
}
|
}
|
||||||
if (config.height !== undefined) {
|
if (config.height !== undefined) {
|
||||||
setHeight(config.height);
|
absAdapter.setHeight(config.height);
|
||||||
}
|
}
|
||||||
if (config.undirected !== undefined) {
|
if (config.undirected !== undefined) {
|
||||||
if (config.undirected === true) {
|
if (config.undirected === true) {
|
||||||
|
@ -107,208 +81,6 @@ function ArangoAdapter(nodes, edges, config) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
findNode = function(id) {
|
|
||||||
var intId = joinedInCommunities[id] || id,
|
|
||||||
res = $.grep(nodes, function(e){
|
|
||||||
return e._id === intId;
|
|
||||||
});
|
|
||||||
if (res.length === 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (res.length === 1) {
|
|
||||||
return res[0];
|
|
||||||
}
|
|
||||||
throw "Too many nodes with the same ID, should never happen";
|
|
||||||
},
|
|
||||||
|
|
||||||
findEdge = function(id) {
|
|
||||||
var res = $.grep(edges, function(e){
|
|
||||||
return e._id === id;
|
|
||||||
});
|
|
||||||
if (res.length === 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (res.length === 1) {
|
|
||||||
return res[0];
|
|
||||||
}
|
|
||||||
throw "Too many edges with the same ID, should never happen";
|
|
||||||
},
|
|
||||||
|
|
||||||
insertNode = function(data) {
|
|
||||||
var node = {
|
|
||||||
_data: data,
|
|
||||||
_id: data._id
|
|
||||||
},
|
|
||||||
n = findNode(node._id);
|
|
||||||
if (n) {
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
node.x = initialX.getStart();
|
|
||||||
node.y = initialY.getStart();
|
|
||||||
nodes.push(node);
|
|
||||||
node._outboundCounter = 0;
|
|
||||||
node._inboundCounter = 0;
|
|
||||||
return node;
|
|
||||||
},
|
|
||||||
|
|
||||||
insertEdge = function(data) {
|
|
||||||
var source,
|
|
||||||
target,
|
|
||||||
edge = {
|
|
||||||
_data: data,
|
|
||||||
_id: data._id
|
|
||||||
},
|
|
||||||
e = findEdge(edge._id),
|
|
||||||
edgeToPush;
|
|
||||||
if (e) {
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
source = findNode(data._from);
|
|
||||||
target = findNode(data._to);
|
|
||||||
if (!source) {
|
|
||||||
throw "Unable to insert Edge, source node not existing " + edge._from;
|
|
||||||
}
|
|
||||||
if (!target) {
|
|
||||||
throw "Unable to insert Edge, target node not existing " + edge._to;
|
|
||||||
}
|
|
||||||
edge.source = source;
|
|
||||||
edge.target = target;
|
|
||||||
edges.push(edge);
|
|
||||||
|
|
||||||
|
|
||||||
if (cachedCommunities[source._id] !== undefined) {
|
|
||||||
edgeToPush = {};
|
|
||||||
edgeToPush.type = "s";
|
|
||||||
edgeToPush.id = edge._id;
|
|
||||||
edgeToPush.source = $.grep(cachedCommunities[source._id].nodes, function(e){
|
|
||||||
return e._id === data._from;
|
|
||||||
})[0];
|
|
||||||
edgeToPush.source._outboundCounter++;
|
|
||||||
cachedCommunities[source._id].edges.push(edgeToPush);
|
|
||||||
} else {
|
|
||||||
source._outboundCounter++;
|
|
||||||
}
|
|
||||||
if (cachedCommunities[target._id] !== undefined) {
|
|
||||||
edgeToPush = {};
|
|
||||||
edgeToPush.type = "t";
|
|
||||||
edgeToPush.id = edge._id;
|
|
||||||
edgeToPush.target = $.grep(cachedCommunities[target._id].nodes, function(e){
|
|
||||||
return e._id === data._to;
|
|
||||||
})[0];
|
|
||||||
edgeToPush.target._inboundCounter++;
|
|
||||||
cachedCommunities[target._id].edges.push(edgeToPush);
|
|
||||||
} else {
|
|
||||||
target._inboundCounter++;
|
|
||||||
}
|
|
||||||
return edge;
|
|
||||||
},
|
|
||||||
|
|
||||||
removeNode = function (node) {
|
|
||||||
var i;
|
|
||||||
for ( i = 0; i < nodes.length; i++ ) {
|
|
||||||
if ( nodes[i] === node ) {
|
|
||||||
nodes.splice( i, 1 );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
removeEdge = function (edge) {
|
|
||||||
var i;
|
|
||||||
for ( i = 0; i < edges.length; i++ ) {
|
|
||||||
if ( edges[i] === edge ) {
|
|
||||||
edges.splice( i, 1 );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
removeEdgesForNode = function (node) {
|
|
||||||
var i;
|
|
||||||
for (i = 0; i < edges.length; i++ ) {
|
|
||||||
if (edges[i].source === node) {
|
|
||||||
node._outboundCounter--;
|
|
||||||
edges[i].target._inboundCounter--;
|
|
||||||
edges.splice( i, 1 );
|
|
||||||
i--;
|
|
||||||
} else if (edges[i].target === node) {
|
|
||||||
node._inboundCounter--;
|
|
||||||
edges[i].source._outboundCounter--;
|
|
||||||
edges.splice( i, 1 );
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
combineCommunityEdges = function (nodes, commNode) {
|
|
||||||
var i, j, s, t,
|
|
||||||
cachedCommEdges = cachedCommunities[commNode._id].edges,
|
|
||||||
edgeToPush;
|
|
||||||
for (i = 0; i < edges.length; i++ ) {
|
|
||||||
edgeToPush = {};
|
|
||||||
// s and t keep old values yay!
|
|
||||||
s = edges[i].source;
|
|
||||||
t = edges[i].target;
|
|
||||||
for (j = 0; j < nodes.length; j++) {
|
|
||||||
if (s === nodes[j]) {
|
|
||||||
if (edgeToPush.type !== undefined) {
|
|
||||||
edges[i].target = edgeToPush.target;
|
|
||||||
delete edgeToPush.target;
|
|
||||||
edgeToPush.type = "b";
|
|
||||||
edgeToPush.edge = edges[i];
|
|
||||||
edges.splice( i, 1 );
|
|
||||||
i--;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
edges[i].source = commNode;
|
|
||||||
edgeToPush.type = "s";
|
|
||||||
edgeToPush.id = edges[i]._id;
|
|
||||||
edgeToPush.source = s;
|
|
||||||
}
|
|
||||||
if (t === nodes[j]) {
|
|
||||||
if (edgeToPush.type !== undefined) {
|
|
||||||
edges[i].source = edgeToPush.source;
|
|
||||||
delete edgeToPush.source;
|
|
||||||
edgeToPush.type = "b";
|
|
||||||
edgeToPush.edge = edges[i];
|
|
||||||
edges.splice( i, 1 );
|
|
||||||
i--;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
edges[i].target = commNode;
|
|
||||||
edgeToPush.type = "t";
|
|
||||||
edgeToPush.id = edges[i]._id;
|
|
||||||
edgeToPush.target = t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (edgeToPush.type !== undefined) {
|
|
||||||
cachedCommEdges.push(edgeToPush);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Helper function to easily remove all outbound edges for one node
|
|
||||||
removeOutboundEdgesFromNode = function ( node ) {
|
|
||||||
if (node._outboundCounter > 0) {
|
|
||||||
var removed = [],
|
|
||||||
i;
|
|
||||||
for ( i = 0; i < edges.length; i++ ) {
|
|
||||||
if ( edges[i].source === node ) {
|
|
||||||
removed.push(edges[i]);
|
|
||||||
node._outboundCounter--;
|
|
||||||
edges[i].target._inboundCounter--;
|
|
||||||
edges.splice( i, 1 );
|
|
||||||
if (node._outboundCounter === 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return removed;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
sendQuery = function(query, bindVars, onSuccess) {
|
sendQuery = function(query, bindVars, onSuccess) {
|
||||||
if (query !== queries.connectedEdges) {
|
if (query !== queries.connectedEdges) {
|
||||||
bindVars["@nodes"] = nodeCollection;
|
bindVars["@nodes"] = nodeCollection;
|
||||||
|
@ -343,106 +115,37 @@ function ArangoAdapter(nodes, edges, config) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
collapseCommunity = function (community) {
|
|
||||||
var commId = "*community_" + Math.floor(Math.random()* 1000000),
|
|
||||||
commNode = {
|
|
||||||
_id: commId,
|
|
||||||
edges: []
|
|
||||||
},
|
|
||||||
nodesToRemove = _.map(community, function(id) {
|
|
||||||
return findNode(id);
|
|
||||||
});
|
|
||||||
commNode.x = nodesToRemove[0].x;
|
|
||||||
commNode.y = nodesToRemove[0].y;
|
|
||||||
cachedCommunities[commId] = {};
|
|
||||||
cachedCommunities[commId].nodes = nodesToRemove;
|
|
||||||
cachedCommunities[commId].edges = [];
|
|
||||||
|
|
||||||
combineCommunityEdges(nodesToRemove, commNode);
|
|
||||||
_.each(nodesToRemove, function(n) {
|
|
||||||
joinedInCommunities[n._id] = commId;
|
|
||||||
removeNode(n);
|
|
||||||
});
|
|
||||||
nodes.push(commNode);
|
|
||||||
},
|
|
||||||
|
|
||||||
expandCommunity = function (commNode) {
|
|
||||||
var commId = commNode._id,
|
|
||||||
nodesToAdd = cachedCommunities[commId].nodes,
|
|
||||||
edgesToChange = cachedCommunities[commId].edges,
|
|
||||||
com;
|
|
||||||
removeNode(commNode);
|
|
||||||
if (limit < nodes.length + nodesToAdd.length) {
|
|
||||||
com = reducer.getCommunity(limit);
|
|
||||||
collapseCommunity(com);
|
|
||||||
}
|
|
||||||
_.each(nodesToAdd, function(n) {
|
|
||||||
delete joinedInCommunities[n._id];
|
|
||||||
nodes.push(n);
|
|
||||||
});
|
|
||||||
_.each(edgesToChange, function(e) {
|
|
||||||
var edge;
|
|
||||||
switch(e.type) {
|
|
||||||
case "t":
|
|
||||||
edge = findEdge(e.id);
|
|
||||||
edge.target = e.target;
|
|
||||||
break;
|
|
||||||
case "s":
|
|
||||||
edge = findEdge(e.id);
|
|
||||||
edge.source = e.source;
|
|
||||||
break;
|
|
||||||
case "b":
|
|
||||||
edges.push(e.edge);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
delete cachedCommunities[commId];
|
|
||||||
},
|
|
||||||
|
|
||||||
parseResultOfTraversal = function (result, callback) {
|
parseResultOfTraversal = function (result, callback) {
|
||||||
result = result[0];
|
result = result[0];
|
||||||
var inserted = {},
|
var inserted = {},
|
||||||
n = insertNode(result[0].vertex),
|
n = absAdapter.insertNode(result[0].vertex),
|
||||||
com, buckets;
|
com, buckets;
|
||||||
_.each(result, function(visited) {
|
_.each(result, function(visited) {
|
||||||
var node = insertNode(visited.vertex),
|
var node = absAdapter.insertNode(visited.vertex),
|
||||||
path = visited.path;
|
path = visited.path;
|
||||||
inserted[node._id] = node;
|
inserted[node._id] = node;
|
||||||
_.each(path.vertices, function(connectedNode) {
|
_.each(path.vertices, function(connectedNode) {
|
||||||
var ins = insertNode(connectedNode);
|
var ins = absAdapter.insertNode(connectedNode);
|
||||||
inserted[ins._id] = ins;
|
inserted[ins._id] = ins;
|
||||||
});
|
});
|
||||||
_.each(path.edges, function(edge) {
|
_.each(path.edges, function(edge) {
|
||||||
insertEdge(edge);
|
absAdapter.insertEdge(edge);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
delete inserted[n._id];
|
delete inserted[n._id];
|
||||||
if (_.size(inserted) > childLimit) {
|
absAdapter.checkSizeOfInserted(inserted);
|
||||||
buckets = reducer.bucketNodes(_.values(inserted), childLimit);
|
absAdapter.checkNodeLimit(n);
|
||||||
_.each(buckets, function(b) {
|
|
||||||
if (b.length > 1) {
|
|
||||||
var ids = _.map(b, function(n) {
|
|
||||||
return n._id;
|
|
||||||
});
|
|
||||||
collapseCommunity(ids);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (limit < nodes.length) {
|
|
||||||
com = reducer.getCommunity(limit, n);
|
|
||||||
collapseCommunity(com);
|
|
||||||
}
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(n);
|
callback(n);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/* Archive
|
||||||
parseResultOfQuery = function (result, callback) {
|
parseResultOfQuery = function (result, callback) {
|
||||||
_.each(result, function (node) {
|
_.each(result, function (node) {
|
||||||
var n = findNode(node._id);
|
var n = findNode(node._id);
|
||||||
if (!n) {
|
if (!n) {
|
||||||
insertNode(node);
|
absAdapter.insertNode(node);
|
||||||
n = node;
|
n = node;
|
||||||
} else {
|
} else {
|
||||||
n.children = node.children;
|
n.children = node.children;
|
||||||
|
@ -454,14 +157,14 @@ function ArangoAdapter(nodes, edges, config) {
|
||||||
var check = findNode(id),
|
var check = findNode(id),
|
||||||
newnode;
|
newnode;
|
||||||
if (check) {
|
if (check) {
|
||||||
insertEdge(n, check);
|
absAdapter.insertEdge(n, check);
|
||||||
self.requestCentralityChildren(id, function(c) {
|
self.requestCentralityChildren(id, function(c) {
|
||||||
n._centrality = c;
|
n._centrality = c;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
newnode = {_id: id};
|
newnode = {_id: id};
|
||||||
insertNode(newnode);
|
absAdapter.insertNode(newnode);
|
||||||
insertEdge(n, newnode);
|
absAdapter.insertEdge(n, newnode);
|
||||||
self.requestCentralityChildren(id, function(c) {
|
self.requestCentralityChildren(id, function(c) {
|
||||||
newnode._centrality = c;
|
newnode._centrality = c;
|
||||||
});
|
});
|
||||||
|
@ -472,7 +175,7 @@ function ArangoAdapter(nodes, edges, config) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
*/
|
||||||
permanentlyRemoveEdgesOfNode = function (nodeId) {
|
permanentlyRemoveEdgesOfNode = function (nodeId) {
|
||||||
sendQuery(queries.connectedEdges, {
|
sendQuery(queries.connectedEdges, {
|
||||||
id: nodeId
|
id: nodeId
|
||||||
|
@ -536,11 +239,7 @@ function ArangoAdapter(nodes, edges, config) {
|
||||||
+ " FILTER e._to == @id"
|
+ " FILTER e._to == @id"
|
||||||
+ " || e._from == @id"
|
+ " || e._from == @id"
|
||||||
+ " RETURN e";
|
+ " RETURN e";
|
||||||
|
/* Archive
|
||||||
childLimit = Number.POSITIVE_INFINITY;
|
|
||||||
|
|
||||||
reducer = new NodeReducer(nodes, edges);
|
|
||||||
|
|
||||||
self.oldLoadNodeFromTreeById = function(nodeId, callback) {
|
self.oldLoadNodeFromTreeById = function(nodeId, callback) {
|
||||||
sendQuery(queries.nodeById, {
|
sendQuery(queries.nodeById, {
|
||||||
id: nodeId
|
id: nodeId
|
||||||
|
@ -548,7 +247,7 @@ function ArangoAdapter(nodes, edges, config) {
|
||||||
parseResultOfQuery(res, callback);
|
parseResultOfQuery(res, callback);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
self.loadNode = function(nodeId, callback) {
|
self.loadNode = function(nodeId, callback) {
|
||||||
self.loadNodeFromTreeById(nodeId, callback);
|
self.loadNodeFromTreeById(nodeId, callback);
|
||||||
};
|
};
|
||||||
|
@ -590,7 +289,7 @@ function ArangoAdapter(nodes, edges, config) {
|
||||||
data._from = edgeToAdd.source._id;
|
data._from = edgeToAdd.source._id;
|
||||||
data._to = edgeToAdd.target._id;
|
data._to = edgeToAdd.target._id;
|
||||||
delete data.error;
|
delete data.error;
|
||||||
var edge = insertEdge(data);
|
var edge = absAdapter.insertEdge(data);
|
||||||
callback(edge);
|
callback(edge);
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(data) {
|
||||||
|
@ -608,7 +307,7 @@ function ArangoAdapter(nodes, edges, config) {
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
processData: false,
|
processData: false,
|
||||||
success: function() {
|
success: function() {
|
||||||
removeEdge(edgeToRemove);
|
absAdapter.removeEdge(edgeToRemove);
|
||||||
if (callback !== undefined && _.isFunction(callback)) {
|
if (callback !== undefined && _.isFunction(callback)) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
@ -649,7 +348,7 @@ function ArangoAdapter(nodes, edges, config) {
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
processData: false,
|
processData: false,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
insertNode(data);
|
absAdapter.insertNode(data);
|
||||||
callback(data);
|
callback(data);
|
||||||
},
|
},
|
||||||
error: function(data) {
|
error: function(data) {
|
||||||
|
@ -667,9 +366,9 @@ function ArangoAdapter(nodes, edges, config) {
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
processData: false,
|
processData: false,
|
||||||
success: function() {
|
success: function() {
|
||||||
removeEdgesForNode(nodeToRemove);
|
absAdapter.removeEdgesForNode(nodeToRemove);
|
||||||
permanentlyRemoveEdgesOfNode(nodeToRemove._id);
|
permanentlyRemoveEdgesOfNode(nodeToRemove._id);
|
||||||
removeNode(nodeToRemove);
|
absAdapter.removeNode(nodeToRemove);
|
||||||
if (callback !== undefined && _.isFunction(callback)) {
|
if (callback !== undefined && _.isFunction(callback)) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
@ -714,22 +413,15 @@ function ArangoAdapter(nodes, edges, config) {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.setNodeLimit = function (pLimit, callback) {
|
self.setNodeLimit = function (pLimit, callback) {
|
||||||
limit = pLimit;
|
absAdapter.setNodeLimit(pLimit, callback);
|
||||||
if (limit < nodes.length) {
|
|
||||||
var com = reducer.getCommunity(limit);
|
|
||||||
collapseCommunity(com);
|
|
||||||
if (callback !== undefined) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.setChildLimit = function (pLimit) {
|
self.setChildLimit = function (pLimit) {
|
||||||
childLimit = pLimit;
|
absAdapter.setChildLimit(pLimit);
|
||||||
};
|
};
|
||||||
|
|
||||||
self.expandCommunity = function (commNode, callback) {
|
self.expandCommunity = function (commNode, callback) {
|
||||||
expandCommunity(commNode);
|
absAdapter.expandCommunity(commNode);
|
||||||
if (callback !== undefined) {
|
if (callback !== undefined) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
|
@ -558,7 +558,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
existNodes([c0, c1, c2, c3, c4]);
|
existNodes([c0, c1, c2, c3, c4]);
|
||||||
|
@ -619,7 +619,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(nodes[0]._data).toEqual({
|
expect(nodes[0]._data).toEqual({
|
||||||
|
@ -793,7 +793,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
var callNodesIds = _.map(callNodes, function(n) {
|
var callNodesIds = _.map(callNodes, function(n) {
|
||||||
|
@ -858,7 +858,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
var callNodesIds = _.map(callNodes, function(n) {
|
var callNodesIds = _.map(callNodes, function(n) {
|
||||||
|
@ -1005,7 +1005,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
existNodes([c0, c1, c2, c3, c4, c5, c6, c7]);
|
existNodes([c0, c1, c2, c3, c4, c5, c6, c7]);
|
||||||
|
@ -1027,7 +1027,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(toPatch._data.hello).toEqual("world");
|
expect(toPatch._data.hello).toEqual("world");
|
||||||
|
@ -1050,7 +1050,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(toPatch._data.hello).toEqual("world");
|
expect(toPatch._data.hello).toEqual("world");
|
||||||
|
@ -1073,7 +1073,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect($.ajax).toHaveBeenCalledWith(
|
expect($.ajax).toHaveBeenCalledWith(
|
||||||
|
@ -1097,7 +1097,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect($.ajax).toHaveBeenCalledWith(
|
expect($.ajax).toHaveBeenCalledWith(
|
||||||
|
@ -1152,7 +1152,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
var commId = getCommunityNodesIds()[0];
|
var commId = getCommunityNodesIds()[0];
|
||||||
|
@ -1177,7 +1177,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
var commId = getCommunityNodesIds()[0];
|
var commId = getCommunityNodesIds()[0];
|
||||||
|
@ -1236,7 +1236,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return called === 2;
|
return called === 2;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
adapter.loadNode(v2, counterCallback);
|
adapter.loadNode(v2, counterCallback);
|
||||||
|
@ -1245,7 +1245,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return called === 3;
|
return called === 3;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
var commId = commNode._id;
|
var commId = commNode._id;
|
||||||
|
@ -1264,7 +1264,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return called === 4;
|
return called === 4;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
existNodes([v0, v1, v2, v3, v4]);
|
existNodes([v0, v1, v2, v3, v4]);
|
||||||
|
@ -1320,7 +1320,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return called === 2;
|
return called === 2;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
adapter.loadNode(v2, counterCallback);
|
adapter.loadNode(v2, counterCallback);
|
||||||
|
@ -1329,7 +1329,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return called === 3;
|
return called === 3;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
adapter.setNodeLimit(20);
|
adapter.setNodeLimit(20);
|
||||||
|
@ -1338,7 +1338,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return called === 4;
|
return called === 4;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
var checkNodeWithInAndOut = function(id, inbound, outbound) {
|
var checkNodeWithInAndOut = function(id, inbound, outbound) {
|
||||||
|
@ -1413,7 +1413,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
var newCommId = getCommunityNodesIds()[0];
|
var newCommId = getCommunityNodesIds()[0];
|
||||||
|
@ -1476,7 +1476,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
existEdge(c3, firstCommId);
|
existEdge(c3, firstCommId);
|
||||||
|
@ -1523,7 +1523,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
existNodes([c0, c1, c2, c3, c4, c8, c9]);
|
existNodes([c0, c1, c2, c3, c4, c8, c9]);
|
||||||
|
@ -1557,7 +1557,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect($.ajax).toHaveBeenCalledWith(
|
expect($.ajax).toHaveBeenCalledWith(
|
||||||
|
@ -1666,7 +1666,7 @@
|
||||||
|
|
||||||
waitsFor(function() {
|
waitsFor(function() {
|
||||||
return callbackCheck;
|
return callbackCheck;
|
||||||
});
|
}, 1000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
callbackCheck = false;
|
callbackCheck = false;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue