[Simulation] Mapping graph visitors#6087
Draft
alxbilger wants to merge 36 commits intosofa-framework:masterfrom
Draft
[Simulation] Mapping graph visitors#6087alxbilger wants to merge 36 commits intosofa-framework:masterfrom
alxbilger wants to merge 36 commits intosofa-framework:masterfrom
Conversation
0adee88 to
583fbd5
Compare
Adds support for targeted node traversal in `MappingGraph::traverseTopDown` using defined scopes: * `ONLY_MAPPED_NODES`: Visits only components involved in mappings. * `ONLY_MAIN_NODES`: Visits component groups that do not rely on external mapping inputs. This change updates the API to provide fine-grained control over which nodes are processed during traversal, and includes new tests validating these scoped behaviors.
…ersal Updates `MappingGraph::traverseBottomUp` to accept a `VisitorApplication` scope, ensuring consistent node filtering logic with top-down traversal. This allows targeted processing of nodes (e.g., only mapped or main nodes) when traversing dependencies from the bottom up. Tests are updated to validate scoped bottom-up behavior.
Updates `BaseMappingGraphNode::isMapped()` to use `std::optional<bool>` for managing and lazily computing the node's mapped status, improving efficiency of repeated checks.
Updates `MappingGraph::traverseComponentGroups` to accept a scope parameter, allowing controlled filtering and processing of component groups during graph traversal.
Updates `MappingGraph2_test` to prepend descriptive prefixes (e.g., `[STATE]`, `[MAPPING]`) to node names visited during traversals, ensuring clear identification of the component type for accurate testing results.
Implements overloads for `traverseTopDown_` and `traverseBottomUp_` in `MappingGraph`, allowing users to pass a callable object or lambda directly. This approach simplifies graph traversal by leveraging the new `CallableVisitor` pattern, which automatically handles invoking the provided logic against visited components. Tests are updated to validate lambda usage during complex graph traversals.
Introduces a `clear()` method for `MappingGraph` to reset the entire graph state. This function ensures that all internal members, such as root node pointers, build flags, mapping status tracking, and associated data containers, are properly initialized back to their default empty state.
Introduces `traverseComponentGroups_` in `MappingGraph`, allowing users to pass a callable object or lambda directly for graph component group traversal. This standardizes the usage of callable visitors across all major graph traversal methods, improving API consistency and reducing boilerplate code.
Extracts all core graph traversal methods (Top-Down, Bottom-Up, component group traversals) from `MappingGraph` and moves their implementation to a dedicated `MappingGraphAlgorithms` class. This improves modularity by separating the algorithm details from the main graph structure API. Updates headers and tests to utilize the new `algorithms` member struct for all traversal calls.
Adds an overloaded `traverse` method to `MappingGraphAlgorithms`. This overload allows the graph traversal process to utilize a `TaskScheduler`, executing node visits concurrently for improved performance when processing large graphs on multi-threaded environments. It falls back to synchronous traversal if no scheduler is provided.
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.
Still a draft, not to be reviewed yet. Need to use the CI 🔥
[with-all-tests]
By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).
Reviewers will merge this pull-request only if