Skip to content

Add wrapper for vertex_components using adjacency matrix - #285

Merged
alecjacobson merged 2 commits into
libigl:mainfrom
zfergus:main
Aug 11, 2026
Merged

Add wrapper for vertex_components using adjacency matrix#285
alecjacobson merged 2 commits into
libigl:mainfrom
zfergus:main

Conversation

@zfergus

@zfergus zfergus commented Sep 27, 2025

Copy link
Copy Markdown
Contributor

Restore the vertex_components_from_adjacency_matrix previously removed. This is still referenced in the docs. I have a use for this function, so it would be nice to restore.

@alecjacobson

Copy link
Copy Markdown
Contributor

Looks good. Would you mind adding a test call?

Copilot AI lite review requested due to automatic review settings August 10, 2026 21:05
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alecjacobson

Copy link
Copy Markdown
Contributor

Rebased onto current main. This resolved a conflict with the vertex_components docstring fix that landed in #305 — kept that corrected face-based docstring and your new vertex_components_from_adjacency_matrix binding side by side. I also added a test (two disconnected components → checks component ids and per-component counts), since the PR didn't include one. Full suite green locally (92 passed). Thanks!

(Written by Claude Code on behalf of @alecjacobson.)

Copilot AI left a comment

Copy link
Copy Markdown

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 restores the previously removed vertex_components_from_adjacency_matrix Python binding (referenced in the docs) by adding a nanobind wrapper around libigl’s adjacency-matrix overload and adding a regression test to validate the returned component labels and component-size counts.

Changes:

  • Add vertex_components_from_adjacency_matrix(adjacency) binding that returns (c, counts) for a sparse adjacency matrix.
  • Add a new test that builds a sparse adjacency matrix with two disconnected components and validates c and counts.

Reviewed changes

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

File Description
src/vertex_components.cpp Adds the adjacency-matrix wrapper and binds it into the Python module.
tests/test_all.py Adds a regression test for vertex_components_from_adjacency_matrix.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vertex_components.cpp Outdated
Comment on lines +42 to +44

@param[in] F #F by 3 matrix of triangle (face) indices
@return Vector C of per-vertex connected-component ids)");
}
@param[in] F Matrix of triangle indices
@return Vector C of component IDs per vertex)");
@zfergus

zfergus commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Looks good. Would you mind adding a test call?

Oops, forgot about this message. Thanks for adding the test for me.

@alecjacobson
alecjacobson merged commit b2c1055 into libigl:main Aug 11, 2026
39 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