Skip to content

Change flattened dependency graph from DiGraph<NodeId> to DiGraph<SystemKey> #20172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ItsDoot
Copy link
Contributor

@ItsDoot ItsDoot commented Jul 17, 2025

Objective

Semantically, the fully flattened dependency graph never contains SystemSetKeys, so lets encode that into its type.

Solution

  • Added GraphNodeId trait and its related traits GraphNodeIdPair and DirectedGraphNodeId.
    • The latter two traits are used to let us keep the space savings of CompactNodeIdAndDirection and CompactNodeIdPair.
  • Generalized DiGraph and UnGraph with a new GraphNodeId N type parameter.
  • Generalized most functions involving DiGraph/UnGraph to take a GraphNodeId type parameter.
  • Added Graph::try_into function to help us convert from DiGraph<NodeId> to DiGraph<SystemKey>. Does it look a bit gnarly? Yea.

Testing

Re-using current tests.

@ItsDoot ItsDoot added A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 17, 2025
@ItsDoot ItsDoot requested review from chescock and hymm and removed request for chescock July 17, 2025 06:59
@ItsDoot
Copy link
Contributor Author

ItsDoot commented Jul 18, 2025

Thoughts on GraphNodeId now? I removed the two extra related traits as suggested by @chescock and also renamed the associated types to match their semantics.

EDIT: Since it's only a 16 line file now, I could also co-locate it in the same file as Graph.

@alice-i-cecile @chescock

@alice-i-cecile alice-i-cecile requested a review from chescock July 18, 2025 04:10
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

I appreciate the explictness about systems vs system sets. I think this is a net improvement as a result.


impl From<CompactNodeIdPair> for (NodeId, NodeId) {
fn from(value: CompactNodeIdPair) -> Self {
let a = match value.is_system_a {
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I didn't notice the match bool before. It was like that before, and it does seem reasonable here for symmetry with the reverse impl, but ... but ... if!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

match on bool good! if bad!

@ItsDoot ItsDoot added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants