Repository navigation
Tweak Graphs performance, and further improve GraphPropertiesTest in light of the recently detected bug. - #8802
Merged
Merged
Conversation
… in light of the recently detected bug. ### `Graphs` - We have been copying a `Set` to an `ArrayDeque` for no particular reason. We might as well use its `Iterator` to reduce how much we store. ### `GraphPropertiesTest` - `hasCycle_deepPathGraph` was populating `graphsToTest` but then asserting on `directedNetwork` and `undirectedNetwork`, which are empty! (This seems like a sign that the tests should really be restructed more significantly....) This is my fault from 63734b9. - Because of the recently detected bug (fix: cl/1009013320), our tests weren't actually traversing deeply into the graph, so they weren't actually proving that the switch from recursion to iteration was effective. Shame on me for not verifying that the tests failed before my change! - Until cl/1009013320, all tests that checked for `hasCycle(undirectedGraph) == true` triggered [a shortcut](https://github.com/google/guava/blob/ff4f4e8dee0cad772ffa0256a93cae5b4aae695f/guava/src/com/google/common/graph/Graphs.java#L65), so we were not testing the part of the logic that lives in `subgraphHasCycle`. This has probably been broken forever. Amazingly, all the new and fixed tests do pass without prod changes. (noticed during investigation of #8796) RELNOTES=n/a PiperOrigin-RevId: 1009644539
copybara-service
Bot
force-pushed
the
test_1009082052
branch
from
October 29, 2026 13:35
9a61f47 to
c29059a
Compare
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.
Tweak
Graphsperformance, and further improveGraphPropertiesTestin light of the recently detected bug.GraphsSetto anArrayDequefor no particular reason. We might as well use itsIteratorto reduce how much we store.GraphPropertiesTesthasCycle_deepPathGraphwas populatinggraphsToTestbut then asserting ondirectedNetworkandundirectedNetwork, which are empty! (This seems like a sign that the tests should really be restructed more significantly....) This is my fault from 63734b9.hasCycle(undirectedGraph) == truetriggered a shortcut, so we were not testing the part of the logic that lives insubgraphHasCycle. This has probably been broken forever.Amazingly, all the new and fixed tests do pass without prod changes.
(noticed during investigation of #8796)
RELNOTES=n/a