Skip to content

Optimize line graph construction#706

Merged
kaiser-dan merged 1 commit into
xgi-org:devfrom
Ved235:main
Apr 27, 2026
Merged

Optimize line graph construction#706
kaiser-dan merged 1 commit into
xgi-org:devfrom
Ved235:main

Conversation

@Ved235

@Ved235 Ved235 commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

This changes the implementation in xgi.convert.to_line_graph() to avoid scanning every pair of hyperedges. Instead of using combinations(H._edge, 2) and checking every pair, it now only considers pairs that actually overlap.

On synthetic hypergraphs generated using codex, there was a significant performance gain:

  • 2k: 436.47 ms -> 25.54 ms
  • 4k: 1936.89 ms -> 98.47 ms
  • 6k: 4975.49 ms -> 219.49 ms

Validation

pytest -q
392 passed, 6 skipped, 117 warnings in 17.99s

@kaiser-dan kaiser-dan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Ved235 , thanks for this work! It is a welcome change with some impressive speedups.

I've looked through the code and it seems straight-forward enough, I'll approve the PR now but merge it into the dev branch instead later.

@kaiser-dan kaiser-dan changed the base branch from main to dev April 5, 2026 14:57
@nwlandry

Copy link
Copy Markdown
Collaborator

@kaiser-dan --- is there a timeline for this being merged?

@kaiser-dan kaiser-dan merged commit 0c0dfbb into xgi-org:dev Apr 27, 2026
15 checks passed
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.

3 participants