This repository was archived by the owner on Jun 18, 2026. It is now read-only.
perf: replace O(V*d) edge counting with O(E) single-pass - #110
Closed
sauravbhattacharya001 wants to merge 2 commits into
Closed
sauravbhattacharya001 wants to merge 2 commits into
sauravbhattacharya001 wants to merge 2 commits into
Conversation
… in Network.java The generateFile method had 5 nearly identical query execution blocks (friends, study-groups, classmates, strangers, familiar-strangers) that differed only in SQL template, edge label, and threshold values. Changes: - Extract LOCATION_MATCH_TEMPLATE and LOCATION_EXCLUDE_TEMPLATE as shared SQL templates with operator placeholders - Add executeLocationMatchQuery() for parameterized location queries - Add executeEdgeQuery() for location-exclusion queries - Parameterize the location value (was previously hardcoded in SQL strings) - Improve Javadoc and parameter naming conventions
countEdgesInSubgraph previously iterated each vertex's incident edges and used a HashSet<edge> to deduplicate, resulting in O(Σdeg) time plus O(E_sub) memory for the seen set and getEndpoints() overhead. New implementation iterates graph.getEdges() once and checks endpoint membership in the vertex set (O(1) HashSet lookups), eliminating the deduplication set entirely. This is both faster and allocates less.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Owner
Author
|
Closing: superseded or conflicting with newer changes already on main/master. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Performance
\GraphUtils.countEdgesInSubgraph()\ previously iterated each vertex's incident edges and used a \HashSet\ to deduplicate — O(Σdeg) time + O(E_sub) memory for the seen set.
Change
Single pass over \graph.getEdges()\ checking endpoint membership in the vertex set (O(1) HashSet lookups). Eliminates the deduplication set and \getEndpoints()\ overhead entirely.
This method is called by \cycleRankOfSubgraph()\ and various analyzers, so the improvement cascades.