Skip to content
This repository has been archived by the owner on Nov 13, 2020. It is now read-only.

Fix issue #71 (endless loop in mxHierarchicalLayout) #72

Merged
merged 1 commit into from May 28, 2020

Conversation

vpanfilov
Copy link
Contributor

@vpanfilov vpanfilov commented Feb 5, 2017

Changes were ported from mxgraph/javascript/src/js/layout/hierarchical/mxHierarchicalLayout.js. I don't really understand this layouting algorithm, so please double-check my code.

Fix is mainly located in traverse function, but I also found a difference in filterDescendants function between Java and JS versions.

You can find sample XML graphs that are causing endless loop in issue #71 description

(changes ported from  mxgraph/javascript/src/js/layout/hierarchical/mxHierarchicalLayout.js)
@d-amelin
Copy link

The fix works for me to.
Thanks.

Copy link

@hoijui hoijui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good! :-)

while the project is dormant, due to the nature of git, it still makes sense to go forward with this, I would say.

Comment on lines +487 to +491
// Check whether there are more edges incoming from the target vertex than outgoing
// The hierarchical model treats bi-directional parallel edges as being sourced
// from the more "sourced" terminal. If the directions are equal in number, the direction
// is that of the natural direction from the roots of the layout.
// The checks below are slightly more verbose than need be for performance reasons
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space indents should be tabs

Comment on lines +414 to +415
// Ignore ports in the layout vertex list, they are dealt with
// in the traversal mechanisms
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space indents should be tabs

@@ -456,19 +466,51 @@ protected void traverse(Object vertex, boolean directed, Object edge,

int edgeCount = model.getEdgeCount(vertex);

boolean[] edgeIsSource = new boolean[edgeCount];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a comment like: "// caching for performance reasons"

@davidjgraph davidjgraph merged commit bae5d39 into jgraph:master May 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants