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.
Objective
As the first step towards more modular schedule graph structures, we first need to generalize the foundational pieces: the
Graph
data structure and related algorithms.One might ask: "what are 'more modular schedule graph structures'?" I've come across quite a few use cases that can almost be fulfilled with a
Schedule
, but have different-enough requirements that renderSchedule
incompatible as-is:bevy_render
'sRenderGraph
is already somewhatSchedule
-like, but requires all nodes to be read-only and currently only allows a single query to be performed.bevy_render
'sExtract
schedule could be statically enforced to be read-only, which would allow its executor to skip access conflict checks.Therefore, by providing modular and generic building blocks for building
Schedule
-shaped things, we can satisfy each of the above and more. And since most of these are likely to make use ofDiGraph
orUnGraph
, generalizing them is a good start.One might ask: "what does this give us over
petgraph
?" A couple things:petgraph
is not currentlyno_std
, which is a prerequisite to pull it in now thatbevy_ecs
isno_std
.no_std
Support petgraph/petgraph#747 has been recently opened to fix this.GraphNodeId
allows us to use memory-efficient forms for edge and neighbor information, which currently saves us 8 bytes for each edge pair and each neighbor+direction.Solution
Replaces the hardcoded usage of
NodeId
with an implementableGraphNodeId
trait inDiGraph
/UnGraph
and associated algorithms. Algorithms implemented as part ofScheduleGraph
will be tackled in a future PR in order to keep this one small.Testing
Current tests are being reused.
Migration Guide
DiGraph
orUnGraph
usage must be changed toDiGraph<NodeId>
orUnGraph<NodeId>
, respectively.