-
Notifications
You must be signed in to change notification settings - Fork 34
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
Fix/normalized hypergraph laplacian #648
base: main
Are you sure you want to change the base?
Fix/normalized hypergraph laplacian #648
Conversation
Fixes the implementation of `normalized_hypergraph_laplacian` to prevent negative eigenvalues. Rewrites core matrix calculations in full definition.
Adds a proprty test for eigenvalue sign. Adds error tests for new `weights` variable.
Updated 'Raises' portion of function docstring to include type and length error catches on `weights` parameter.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #648 +/- ##
==========================================
- Coverage 93.45% 93.35% -0.11%
==========================================
Files 64 64
Lines 4993 5008 +15
==========================================
+ Hits 4666 4675 +9
- Misses 327 333 +6 ☔ View full report in Codecov by Sentry. |
Thanks for the PR! It looks good, I only left a few comments to check that everything is okay in the sparse case, and to simplify a few lines. About the weights, I'm thinking maybe we want the argument to be boolean instead: That's how we have it for the adjacency matrix now. |
Thanks for the feedback! I agree, I can't think of any use cases where the weights would want to be different than the edge attributes than cannot also be handled with edge attributes. I can make those adjustments soon. I will also implement your suggestions, thank you! I will ping this for a rereview when those changes are made. |
Implement suggestion - Edge weight matrix Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com>
…er-dan/xgi into fix/normalized_hypergraph_laplacian
Okie I believe this is ready for re-review. I have addressed most of your comments @maximelucas by directly implementing the suggestions, however, to clarify on the remaining, here are two observations:
|
Thanks a lot @kaiser-dan! Just added a few more comments for consistency and simplicity:
After these small changes we should be good to go! |
Fix docstring typo Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com>
Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com>
Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com>
Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com>
Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com>
Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com>
Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com>
Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com>
Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com>
Implement suggestion - Edge weight matrix Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com>
Fix docstring typo Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> Update xgi/linalg/laplacian_matrix.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> Update xgi/linalg/laplacian_matrix.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> Update xgi/linalg/laplacian_matrix.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> Update xgi/linalg/laplacian_matrix.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> Update xgi/linalg/laplacian_matrix.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> Update xgi/linalg/laplacian_matrix.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> Update xgi/linalg/laplacian_matrix.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com> Update xgi/linalg/laplacian_matrix.py Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com>
Add the minimum(?) working example of issue xgi-org#647 as new `test_` function. Tidied `test_normalized_hypergraph_laplacian` and added L2 and L3 comparison.
…er-dan/xgi into fix/normalized_hypergraph_laplacian
Great, thanks a lot! Thanks for bearing with me :) |
Co-authored-by: Maxime Lucas <maximelucas@users.noreply.github.com>
Thank you! It's been fun, I hope to contribute as much as I can moving forward as well. |
Summary
Rewrote
normalized_hypergraph_laplacian
implementation to match reference implementation. Fixes #647 .Description
Rewrote the matrix calculations in
normalized_hypergraph_laplacian
to match the implementation referenced here: #647 (comment). Also adds aweighted
Boolean parameter to allow for differentially weighting edges in the Laplacian calculation, drawn from each edge's "weight" attribute if available (default to 1 if unavailable).Concerns
I have only added barebone unit tests for the effect of edge weights (only on their acceptable definition). I am unsure how or what the expected behavior would be for non-uniform edge weights.
Other
Currently only supports strictly positive weights - a weight of zero would cause some issues with rank. That said, an edge weight of 0 could be interpreted as the subgraph with that edge removed and could be a nice way to handle zero weights in the future?Deprecated with latest commit 573eaad.