Fix AutoLayoutAlgorithm re-evaluation and add nested gallery sample#23
Merged
Malcolmnixon merged 2 commits intoJul 15, 2026
Merged
Conversation
Fixes a KeyNotFoundException thrown when a graph explicitly declares CoreOptions.Algorithm = auto and any nested container's own children scope inherits that value without re-declaring an algorithm override. Root cause: AutoLayoutAlgorithm's internal HierarchicalLayoutAlgorithm instance was built with a leaf-only registry (layered + containment), deliberately excluding auto to avoid infinite self-reference. When a hierarchical-routed group's cascaded options still resolved Algorithm=auto (the normal way a caller selects auto), the nested engine's own top-scope resolution tried to resolve auto against that leaf-only registry and threw. An earlier fix in this area worked around the exception by resetting Algorithm to the layered default before handing options to the nested engine. That masked the crash but broke CoreOptions.Algorithm's documented inheritance semantics: it locked in a single concrete choice at the boundary and cascaded that fixed choice to every descendant scope, instead of letting auto keep re-evaluating connectivity at each level. A container whose own children mixed a connected component with an unrelated singleton no longer got auto's distinct layered/containment routing - it was silently flattened to plain layered for the whole scope. The real fix: register the AutoLayoutAlgorithm instance itself under its own auto identifier in the registry its internal HierarchicalLayoutAlgorithm recurses with. When a nested scope's cascaded effective options resolve to auto, the recursion registry now resolves back to this same instance instead of throwing, re-running the full component classification (connected -> layered, singleton -> containment, container -> hierarchical) at that scope - exactly as if a caller had selected auto for it directly. This let the two prior "reset Algorithm to layered" workarounds (single-group fast path and multi-group split path) be reverted to their original zero-copy, unmodified-options form, since the fix is now purely additive at the registry level. A raw HierarchicalLayoutAlgorithm constructed independently of AutoLayoutAlgorithm still has zero knowledge of auto, preserving its documented independence. Adds a regression test proving auto is re-evaluated (not just non-throwing) at a nested scope with mixed connected/unconnected children, alongside the existing non-throw regression tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nerated table Adds AutoDeepNestedMixedConnectivity to the gallery: a three-level-deep container whose middle and innermost scopes each mix a connected pair with an unrelated singleton, none re-declaring CoreOptions.Algorithm. Visually demonstrates the AutoLayoutAlgorithm fix: every level correctly re-evaluates auto's connectivity classification instead of being locked to a single fixed leaf algorithm. While regenerating the gallery, found and fixed the recurring docs/gallery/README.md blank-table-line bug at its actual source. GalleryIndex.BuildTopIndex() called the shared AppendParagraph helper (which always appends a trailing blank line) separately for the table's header row and its separator row, so every regeneration reintroduced a blank line between them - silently undoing any manual fix applied directly to the committed Markdown, since the generator itself was never corrected. The header and separator rows are now written directly, matching how the data rows already were, so the table is emitted as one contiguous Markdown block on every future regeneration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
This pull request significantly improves the handling and documentation of the
"auto"layout algorithm option, ensuring that nested container scopes inherit and independently re-evaluate"auto"at every level, rather than resolving it once at the root. It fixes several bugs related to option inheritance and registry resolution, expands test coverage for these cases, and enhances the gallery documentation and test suite with new diagrams and explanations.Core algorithm and bug fixes:
AutoLayoutAlgorithmnow builds its internalHierarchicalLayoutAlgorithmwith a recursion registry that includes itself, allowing"auto"to be re-evaluated at every nested scope rather than being resolved once and locked in. This fixes bugs where nested scopes inheriting"auto"would previously throw exceptions or default to a fixed leaf algorithm. [1] [2] [3]"auto"inheritance and re-classification at all levels, ensuring no exceptions are thrown and the intended routing occurs. [1] [2]Gallery and documentation updates:
auto-deep-nested-mixed-connectivity.svg) and corresponding test are added to illustrate and verify that three-level nested containers with mixed connectivity are independently re-classified at each scope when inheriting"auto". [1] [2] [3] [4] [5]Test and infrastructure improvements: