Skip to content
This repository was archived by the owner on Jun 18, 2026. It is now read-only.

perf: eliminate O(|E|) HashSet from CommunityDetector.detect() - #127

Merged
sauravbhattacharya001 merged 1 commit into
masterfrom
perf/community-detector-eliminate-counted-edges
Mar 28, 2026
Merged

sauravbhattacharya001 merged 1 commit into
masterfrom
perf/community-detector-eliminate-counted-edges

Conversation

@sauravbhattacharya001

@sauravbhattacharya001 sauravbhattacharya001 commented Mar 27, 2026

Copy link
Copy Markdown
Owner

Replace global countedEdges HashSet with single post-BFS pass. Eliminates O(|E|) memory and per-edge hash lookups.

Replace the global countedEdges HashSet (which stored every edge during
BFS to avoid double-counting) with a single post-BFS pass over
graph.getEdges(). Since each edge belongs to exactly one connected
component, we look up the community of one endpoint via the
nodeToCommunity map and attribute the edge directly.

Benefits:
- Eliminates O(|E|) memory for the countedEdges HashSet
- Removes per-edge HashSet.contains + HashSet.add during BFS inner loop
- Separates BFS traversal from edge metric computation for clarity
- Same algorithmic complexity (still O(V+E) overall)
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions github-actions Bot added visualization Graph visualization and UI size/s labels Mar 27, 2026
@sauravbhattacharya001
sauravbhattacharya001 merged commit fdd81c2 into master Mar 28, 2026
4 of 8 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size/s visualization Graph visualization and UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant