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

refactor: add equals/hashCode/toString to Edge class - #116

Merged
sauravbhattacharya001 merged 1 commit into
masterfrom
refactor/edge-equals-hashcode-tostring
Mar 28, 2026
Merged

sauravbhattacharya001 merged 1 commit into
masterfrom
refactor/edge-equals-hashcode-tostring

Conversation

@sauravbhattacharya001

Copy link
Copy Markdown
Owner

The \Edge\ class is used in Sets and Maps throughout the codebase but was relying on \Object's identity-based \�quals/\hashCode. This meant two Edge objects connecting the same vertices with the same type and weight were not considered equal in collections.

Changes

  • equals: order-independent vertex comparison (treats undirected edges correctly — \A--B == B--A)
  • hashCode: consistent with equals, uses commutative addition for vertex hashes
  • toString: readable debug format: \Edge[v1--v2, type=f, weight=1.0]\

Why

Multiple analyzers (ShortestPathFinder, CommunityDetector, GraphDiffAnalyzer, etc.) store Edge objects in Sets and Maps. Without proper equals/hashCode, duplicate detection and lookups behave incorrectly in subtle ways.

The Edge class is used extensively in Sets and Maps throughout the
codebase (e.g., ShortestPathFinder, CommunityDetector, GraphStats)
but was relying on Object's identity-based equals/hashCode. This
meant two Edge objects connecting the same vertices with the same
type and weight were not considered equal in collections.

- equals: order-independent vertex comparison (undirected edges)
- hashCode: consistent with equals, order-independent
- toString: readable format for debugging: Edge[v1--v2, type=f, weight=1.0]
@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 24, 2026
@sauravbhattacharya001
sauravbhattacharya001 merged commit a5c5c9e 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