Browse Source

Network: Block recalculation of level in LayoutEngine._determineLevelsDirected() (#3294)

* Levels of direct hierarchical network only incremented

* Cleaned up old code

* Quick fix on presence  globaOptions in mergeOptions()

* Revert fix, doesn't work

* Network: Block recalculation of level in LayoutEngine._determineLevelsDirected()

Fix for #2311.

Nodes with bidirectional edges got their levels shifted due to the handling of both edge directions.
This fix adds a check on bidirectionality and blocks any subsequent level adjustment.
Pure tree layouts are unaffected by this change.
revert-3409-performance
wimrijnders 6 years ago
committed by Yotam Berkowitz
parent
commit
6b191f8bc9
1 changed files with 23 additions and 1 deletions
  1. +23
    -1
      lib/network/modules/LayoutEngine.js

+ 23
- 1
lib/network/modules/LayoutEngine.js View File

@ -1414,7 +1414,7 @@ class LayoutEngine {
}
/**
* this function allocates nodes in levels based on the direction of the edges
* Allocate nodes in levels based on the direction of the edges.
*
* @param hubsize
* @private
@ -1422,8 +1422,30 @@ class LayoutEngine {
_determineLevelsDirected() {
let minLevel = 10000;
/**
* Check if there is an edge going the opposite direction for given edge
*/
let self = this;
let isBidirectional = (edge) => {
for (let key in self.body.edges) {
let otherEdge = self.body.edges[key];
if (otherEdge.toId === edge.fromId && otherEdge.fromId === edge.toId) {
return true;
}
}
return false;
};
let levelByDirection = (nodeA, nodeB, edge) => {
let levelA = this.hierarchical.levels[nodeA.id];
let levelB = this.hierarchical.levels[nodeB.id];
if (isBidirectional(edge) && levelA !== undefined && levelB !== undefined) {
// Don't redo the level determination if already done in this case.
return;
}
// set initial level
if (levelA === undefined) { levelA = this.hierarchical.levels[nodeA.id] = minLevel;}
if (edge.toId == nodeB.id) {

Loading…
Cancel
Save