Skip to content

Fix duplication in methpaths when directed=False#143

Merged
yu-ta-sato merged 1 commit intoc2g-dev:mainfrom
yu-ta-sato:fix_duplication_in_metapaths
Mar 21, 2026
Merged

Fix duplication in methpaths when directed=False#143
yu-ta-sato merged 1 commit intoc2g-dev:mainfrom
yu-ta-sato:fix_duplication_in_metapaths

Conversation

@yu-ta-sato
Copy link
Collaborator

Description

Fix duplicated metapaths in undirected mode for both add_metapaths_by_weight() and add_metapaths().

For add_metapaths_by_weight(), undirected endpoint pairs are now canonicalized and deduplicated before new edges are materialized, so mirrored pairs like (u, v) and (v, u) no longer both appear.

For add_metapaths(), undirected path aggregation now canonicalizes mirrored traversals before grouping, removing duplicate reverse-orientation metapaths while preserving distinct paths between the same endpoints.

Added regression tests covering:

  • undirected weighted metapaths from tuple input
  • undirected weighted metapaths in NetworkX MultiGraph output
  • undirected structural metapaths with mirrored traversals

Related Issues

NA

Checklist

  • I have read the Contributing Guide.
  • I have updated the documentation, if necessary.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • Pre-commit checks passed locally.

@codecov
Copy link

codecov bot commented Mar 21, 2026

Codecov Report

❌ Patch coverage is 97.56098% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
city2graph/metapath.py 97.56% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@yu-ta-sato yu-ta-sato merged commit 9693e63 into c2g-dev:main Mar 21, 2026
6 of 7 checks passed
@yu-ta-sato yu-ta-sato deleted the fix_duplication_in_metapaths branch March 21, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant