Browse Source

- Fixed clustering bug

flowchartTest
Alex de Mulder 9 years ago
parent
commit
b2eaf589a7
6 changed files with 13269 additions and 13226 deletions
  1. +3
    -0
      HISTORY.md
  2. +13123
    -13129
      dist/vis.js
  3. +3
    -2
      lib/network/Network.js
  4. +21
    -34
      lib/network/modules/Clustering.js
  5. +6
    -2
      lib/network/modules/NodesHandler.js
  6. +113
    -59
      test/networkTest.html

+ 3
- 0
HISTORY.md View File

@ -11,6 +11,9 @@ http://visjs.org
- Fixed dynamic edges not correctly handling non-existent nodes.
- Accepted pull from @killerDJO for fixing selected and hover colors for edges.
- Fixed bug with rightmouse button, scroll center and popup positions using the wrong coordinates.
- Fixed click to use.
- Fixed getConnectedEdges method.
- Fixed clustering bug.
### Graph2d & Timeline

+ 13123
- 13129
dist/vis.js
File diff suppressed because it is too large
View File


+ 3
- 2
lib/network/Network.js View File

@ -435,6 +435,7 @@ Network.prototype.findNode = function() {return this.clustering.findN
Network.prototype.isCluster = function() {return this.clustering.isCluster.apply(this.clustering,arguments);};
Network.prototype.openCluster = function() {return this.clustering.openCluster.apply(this.clustering,arguments);};
Network.prototype.cluster = function() {return this.clustering.cluster.apply(this.clustering,arguments);};
Network.prototype.getNodesInCluster = function() {return this.clustering.getNodesInCluster.apply(this.clustering,arguments);};
Network.prototype.clusterByConnection = function() {return this.clustering.clusterByConnection.apply(this.clustering,arguments);};
Network.prototype.clusterByHubsize = function() {return this.clustering.clusterByHubsize.apply(this.clustering,arguments);};
Network.prototype.clusterOutliers = function() {return this.clustering.clusterOutliers.apply(this.clustering,arguments);};
@ -443,7 +444,7 @@ Network.prototype.enableEditMode = function() {return this.manipulation.ena
Network.prototype.disableEditMode = function() {return this.manipulation.disableEditMode.apply(this.manipulation,arguments);};
Network.prototype.addNodeMode = function() {return this.manipulation.addNodeMode.apply(this.manipulation,arguments);};
Network.prototype.editNode = function() {return this.manipulation.editNode.apply(this.manipulation,arguments);};
Network.prototype.editNodeMode = function() {console.log("please use editNode instead of editNodeMode"); return this.manipulation.editNode.apply(this.manipulation,arguments);};
Network.prototype.editNodeMode = function() {console.log("Depricated: Please use editNode instead of editNodeMode."); return this.manipulation.editNode.apply(this.manipulation,arguments);};
Network.prototype.addEdgeMode = function() {return this.manipulation.addEdgeMode.apply(this.manipulation,arguments);};
Network.prototype.editEdgeMode = function() {return this.manipulation.editEdgeMode.apply(this.manipulation,arguments);};
Network.prototype.deleteSelected = function() {return this.manipulation.deleteSelected.apply(this.manipulation,arguments);};
@ -458,7 +459,7 @@ Network.prototype.getConnectedNodes = function(objectId) {
return this.edgesHandler.getConnectedNodes.apply(this.edgesHandler,arguments);
}
};
Network.prototype.getEdges = function() {return this.nodesHandler.getEdges.apply(this.nodesHandler,arguments);};
Network.prototype.getConnectedEdges = function() {return this.nodesHandler.getConnectedEdges.apply(this.nodesHandler,arguments);};
Network.prototype.startSimulation = function() {return this.physics.startSimulation.apply(this.physics,arguments);};
Network.prototype.stopSimulation = function() {return this.physics.stopSimulation.apply(this.physics,arguments);};
Network.prototype.stabilize = function() {return this.physics.stabilize.apply(this.physics,arguments);};

+ 21
- 34
lib/network/modules/Clustering.js View File

@ -498,7 +498,6 @@ class ClusterEngine {
delete this.body.edges[edgeId];
}
else {
// one of the nodes connected to this edge is in a cluster. We give the edge to that cluster so it will be released when that cluster is opened.
if (this.clusteredNodes[edge.fromId] !== undefined || this.clusteredNodes[edge.toId] !== undefined) {
let fromId, toId;
@ -507,17 +506,17 @@ class ClusterEngine {
let clusterNode = this.body.nodes[clusterId];
clusterNode.containedEdges[edgeId] = edge;
// if both from and to nodes are visible, we create a new temporary edge
if (edge.from.options.hidden !== true && edge.to.options.hidden !== true) {
if (this.clusteredNodes[edge.fromId] !== undefined) {
fromId = clusterId;
toId = edge.toId;
}
else {
fromId = edge.fromId;
toId = clusterId;
}
if (this.clusteredNodes[edge.fromId] !== undefined) {
fromId = clusterId;
toId = edge.toId;
}
else {
fromId = edge.fromId;
toId = clusterId;
}
// if both from and to nodes are visible, we create a new temporary edge
if (this.body.nodes[fromId].options.hidden !== true && this.body.nodes[toId].options.hidden !== true) {
let clonedOptions = this._cloneOptions(edge, 'edge');
let id = 'clusterEdge:' + util.randomUUID();
util.deepExtend(clonedOptions, clusterNode.clusterEdgeProperties);
@ -553,30 +552,18 @@ class ClusterEngine {
}
}
/**
* Connect an edge that was previously contained from cluster A to cluster B if the node that it was originally connected to
* is currently residing in cluster B
* @param edge
* @param nodeId
* @param from
* @private
*/
_connectEdge(edge, nodeId, from) {
let clusterStack = this.findNode(nodeId);
if (from === true) {
edge.from = clusterStack[clusterStack.length - 1];
edge.fromId = clusterStack[clusterStack.length - 1].id;
clusterStack.pop();
edge.fromArray = clusterStack;
}
else {
edge.to = clusterStack[clusterStack.length - 1];
edge.toId = clusterStack[clusterStack.length - 1].id;
clusterStack.pop();
edge.toArray = clusterStack;
getNodesInCluster(clusterId) {
let nodesArray = []
if (this.isCluster(clusterId) === true) {
let containedNodes = this.body.nodes[clusterId].containedNodes;
for (let nodeId in containedNodes) {
if (containedNodes.hasOwnProperty(nodeId)) {
nodesArray.push(nodeId)
}
}
}
edge.connect();
return nodesArray;
}
/**

+ 6
- 2
lib/network/modules/NodesHandler.js View File

@ -400,7 +400,7 @@ class NodesHandler {
* @param nodeId
* @returns {*}
*/
getEdges(nodeId) {
getConnectedEdges(nodeId) {
let edgeList = [];
if (this.body.nodes[nodeId] !== undefined) {
let node = this.body.nodes[nodeId];
@ -408,7 +408,11 @@ class NodesHandler {
edgeList.push(node.edges[i].id)
}
}
return nodeList;
else {
console.log("NodeId provided for getConnectedEdges does not exist. Provided: ", nodeId)
}
console.log(edgeList)
return edgeList;
}
}

+ 113
- 59
test/networkTest.html
File diff suppressed because it is too large
View File


Loading…
Cancel
Save