Browse Source

re-adds edges if they are now connected and add does not add invalid edges (#3516)

jittering-top
justinharrell 7 years ago
committed by Yotam Berkowitz
parent
commit
3581561f10
1 changed files with 34 additions and 2 deletions
  1. +34
    -2
      lib/network/modules/EdgesHandler.js

+ 34
- 2
lib/network/modules/EdgesHandler.js View File

@ -422,12 +422,23 @@ class EdgesHandler {
} }
/** /**
* Scan for missing nodes and remove corresponding edges, if any.
*
* There is no direct relation between the nodes and the edges DataSet, * There is no direct relation between the nodes and the edges DataSet,
* so the right place to do call this is in the handler for event `_dataUpdated`. * so the right place to do call this is in the handler for event `_dataUpdated`.
*/ */
_updateState() { _updateState() {
this._addMissingEdges();
this._removeInvalidEdges();
}
/**
* Scan for missing nodes and remove corresponding edges, if any.
* @private
*/
_removeInvalidEdges() {
let edgesToDelete = []; let edgesToDelete = [];
util.forEach(this.body.edges, (edge, id) => { util.forEach(this.body.edges, (edge, id) => {
@ -447,6 +458,27 @@ class EdgesHandler {
this.remove(edgesToDelete, false); this.remove(edgesToDelete, false);
} }
/**
* add all edges from dataset that are not in the cached state
* @private
*/
_addMissingEdges() {
let edges = this.body.edges;
let edgesData = this.body.data.edges;
let addIds = [];
edgesData.forEach((edgeData, edgeId) => {
let edge = edges[edgeId];
if(edge===undefined)
{
addIds.push(edgeId);
}
});
this.add(addIds,true);
}
} }
export default EdgesHandler; export default EdgesHandler;

Loading…
Cancel
Save