mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-11-05 09:36:19 +00:00
84b6edab82
When we remove a wired node from a network, we need to find connected components in the rest of the graph. Typically, this requires a traversal of the whole graph, taking O(|V| + |E|) time. If we remove a lot of nodes at once (such as when unloading chunks), this ends up being quadratic in the number of nodes. In some test networks, this can take anywhere from a few seconds, to hanging the game indefinitely. This attempts to reduce the cases where this can happen, with a couple of optimisations: - Instead of constructing a new hash set of reachable nodes (requiring multiple allocations and hash lookups), we store reachability as a temporary field on the WiredNode. - We abort our traversal of the graph if we can prove the graph remains connected after removing the node. There's definitely future work to be done here in optimising large wired networks, but this is a good first step. |
||
---|---|---|
.. | ||
common | ||
common-api | ||
core | ||
core-api | ||
fabric | ||
fabric-api | ||
forge | ||
forge-api | ||
lints | ||
standalone | ||
web | ||
ARCHITECTURE.md |