layered: tolerate non-facing-side external port dummies in boundary layers - #1193
Open
novazembla wants to merge 1 commit into
Open
layered: tolerate non-facing-side external port dummies in boundary layers#1193novazembla wants to merge 1 commit into
novazembla wants to merge 1 commit into
Conversation
…ayers (eclipse-elk#1192) The hierarchical layer sweep assumed that when the first node of a nested graph's boundary layer is an external port dummy, the WHOLE layer consists of dummies for hierarchical ports on the sweep-facing side (WEST/EAST). That assumption does not hold: dummies for NORTH/SOUTH ports carry no layer constraint (LGraphUtil.createExternalPortDummy only sets an in-layer constraint for them), so the layerer may place them in the first or last layer too. The count mismatch then threw IllegalStateException: Expected N hierarchical ports, but found only 0. sortPortDummiesByPortPositions now sorts only the dummies that belong to hierarchical ports on the sweep-facing side and leaves all other nodes of the layer in their current relative order, instead of throwing. The inverse write-back, sortPortsByDummyPositionsInLastLayer, had the same latent assumption and could silently write a NORTH/SOUTH port into an EAST/WEST port slot, corrupting the port order. It now writes back only the dummies whose origin port lies on the side facing the end of the sweep, permuting exactly the ports whose dummies were found in that layer. On graphs where the old invariant held, both methods behave exactly as before. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Vincent Van Uffelen <novazembla@gmail.com>
Contributor
|
Thank you, should you also post the test elkt graph here? It will take a while to look into this, so please do not be alarmed. |
Author
|
I've added the graph. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relating to issue #1192.
The hierarchical layer sweep assumed that when the first node of a nested graph's boundary layer is an external port dummy, the WHOLE layer consists of dummies for hierarchical ports on the sweep-facing side (
WEST/EAST). That assumption does not hold: dummies forNORTH/SOUTHports carry no layer constraint (LGraphUtil.createExternalPortDummyonly sets an in-layer constraint for them), so the layerer may place them in the first or last layer too. The count mismatch then threwIllegalStateException: Expected N hierarchical ports, but found only 0.sortPortDummiesByPortPositionsnow sorts only the dummies that belong to hierarchical ports on the sweep-facing side and leaves all other nodes of the layer in their current relative order, instead of throwing.The inverse write-back,
sortPortsByDummyPositionsInLastLayer, had the same latent assumption and could silently write aNORTH/SOUTHport into anEAST/WESTport slot, corrupting the port order. It now writes back only the dummies whose origin port lies on the side facing the end of the sweep, permuting exactly the ports whose dummies were found in that layer.On graphs where the old invariant held, both methods behave exactly as before.
I'm happy to have my contribution licenced under GPLv3 (#1185)
ELK Test Graph
This graph fails before the fix (see issue #1192) and does now pass