Skip to content

feat: expose voronoi to python #833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jul 4, 2025

Conversation

BeaMarton13
Copy link
Contributor

I used Cody for the functions.

  • By submitting this pull request, I assign the copyright of my contribution to The igraph development team.

@BeaMarton13 BeaMarton13 changed the title feat: expose voronoi python feat: expose voronoi to python Jun 16, 2025
@ntamas
Copy link
Member

ntamas commented Jun 16, 2025

Try to avoid re-formatting the .py files even if your IDE insists on reformatting. It makes it much harder to go through the PR and separate pure formatting-only modifications from the "real" part of the PR.

Copy link
Member

@szhorvat szhorvat left a comment

Choose a reason for hiding this comment

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

Only a few comments, not an exhaustive review.

Copy link
Member

@ntamas ntamas left a comment

Choose a reason for hiding this comment

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

Not a full review yet, I haven't checked the unit test and the Python side in detail. From a bird's eye view the Python side looks good.

@szhorvat szhorvat requested a review from Copilot June 22, 2025 13:05
Copilot

This comment was marked as outdated.

@szhorvat
Copy link
Member

I think modularity should not be a parameter. Instead, let modularity be computed unconditionally. This takes little time compared to the rest of the algorithm.

@BeaMarton13 BeaMarton13 marked this pull request as ready for review June 26, 2025 13:31
@szhorvat szhorvat requested a review from Copilot June 26, 2025 13:31
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces the Voronoi‐based community detection algorithm to the Python igraph API, providing both C and Python bindings and adding basic tests to validate its behavior.

  • Expose community_voronoi in the C library and register it in Graph
  • Add a Python wrapper _community_voronoi in community.py
  • Add testVoronoi unit tests for simple graph scenarios

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/test_decomposition.py New testVoronoi method with three basic cases
src/igraph/community.py Added _community_voronoi Python wrapper
src/igraph/init.py Registered community_voronoi in Graph
src/_igraph/graphobject.c Implemented igraphmodule_Graph_community_voronoi
Comments suppressed due to low confidence (2)

src/igraph/community.py:372

  • The docstring for mode does not mention the total alias that is supported in mode_map. Update the parameter description to include "total" as an alias for "all".
        mode_map = {"out": "out", "in": "in", "all": "all", "total": "all"}  # alias

tests/test_decomposition.py:538

  • [nitpick] The tests only cover the default parameters. Consider adding cases for non‐unit lengths, non‐unit weights, non‐default mode, and a custom radius to fully exercise the new API.
    def testVoronoi(self):

Copy link
Member

@szhorvat szhorvat left a comment

Choose a reason for hiding this comment

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

Thanks for all your work on this so far @BeaMarton13 !

There are some warnings when building docs. Can you help me by investigating the cause?

WARNING: /Users/szhorvat/Repos/python-igraph/.venv/lib/python3.13/site-packages/igraph/_igraph.abi3.so:???: Cannot parse signature of igraph._igraph.GraphBase.community_voronoi
WARNING: /Users/szhorvat/Repos/python-igraph/.venv/lib/python3.13/site-packages/igraph/community.py:333: Cannot find link target for "igraph.Graph.ecc"
WARNING: /Users/szhorvat/Repos/python-igraph/.venv/lib/python3.13/site-packages/igraph/_igraph.abi3.so:???: Documented parameter "lengths" does not exist
WARNING: /Users/szhorvat/Repos/python-igraph/.venv/lib/python3.13/site-packages/igraph/_igraph.abi3.so:???: Documented parameter "weights" does not exist
WARNING: /Users/szhorvat/Repos/python-igraph/.venv/lib/python3.13/site-packages/igraph/_igraph.abi3.so:???: Documented parameter "mode" does not exist
WARNING: /Users/szhorvat/Repos/python-igraph/.venv/lib/python3.13/site-packages/igraph/_igraph.abi3.so:???: Documented parameter "radius" does not exist
WARNING: /Users/szhorvat/Repos/python-igraph/.venv/lib/python3.13/site-packages/igraph/__init__.py:3993: Cannot find link target for "igraph.Graph.ecc"

@szhorvat
Copy link
Member

There are some warnings when building docs. Can you help me by investigating the cause?

WARNING: /Users/szhorvat/Repos/python-igraph/.venv/lib/python3.13/site-packages/igraph/_igraph.abi3.so:???: Cannot parse signature of igraph._igraph.GraphBase.community_voronoi
WARNING: /Users/szhorvat/Repos/python-igraph/.venv/lib/python3.13/site-packages/igraph/community.py:333: Cannot find link target for "igraph.Graph.ecc"
WARNING: /Users/szhorvat/Repos/python-igraph/.venv/lib/python3.13/site-packages/igraph/_igraph.abi3.so:???: Documented parameter "lengths" does not exist
WARNING: /Users/szhorvat/Repos/python-igraph/.venv/lib/python3.13/site-packages/igraph/_igraph.abi3.so:???: Documented parameter "weights" does not exist
WARNING: /Users/szhorvat/Repos/python-igraph/.venv/lib/python3.13/site-packages/igraph/_igraph.abi3.so:???: Documented parameter "mode" does not exist
WARNING: /Users/szhorvat/Repos/python-igraph/.venv/lib/python3.13/site-packages/igraph/_igraph.abi3.so:???: Documented parameter "radius" does not exist
WARNING: /Users/szhorvat/Repos/python-igraph/.venv/lib/python3.13/site-packages/igraph/__init__.py:3993: Cannot find link target for "igraph.Graph.ecc"

@BeaMarton13, I just fixed this, please see the last commit (7c30c6c). It's something very easy to miss.

@szhorvat szhorvat requested a review from ntamas June 28, 2025 11:01
@szhorvat
Copy link
Member

@ntamas I believe this is ready. Please have a look and merge. Please use only squash-and-merge as the commit history is a mess!

@ntamas ntamas merged commit 4119c94 into igraph:develop Jul 4, 2025
11 of 12 checks passed
@ntamas
Copy link
Member

ntamas commented Jul 4, 2025

Thanks!

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.

4 participants