-
Notifications
You must be signed in to change notification settings - Fork 30
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
Method for k-skeleton of a SC #578
Conversation
I originally planned to do something simpler like: if order != max_order:
bunch = _H.edges.filterby('order', order, 'gt')
_H.remove_simplex_ids_from(bunch) but I have noticed that
let me know if this is an expected behavior or not, in case I will open an issue. |
Good catch I think it's a bug. Worth checking, but after a first quick look, the first 5 edges are: {0: frozenset({1, 2, 3, 4}),
1: frozenset({2, 4}),
2: frozenset({1, 2}),
3: frozenset({3, 4}),
4: frozenset({1, 2, 3}),
...} and I think it fails when trying to remove edge 4: frozenset({1, 2, 3}) which does not exist anymore already because it already removed 2: frozenset({1, 2}), and in doing so had to remove 4: frozenset({1, 2, 3}) already to ensure downward closure. If that's really the case, we just have to catch it or remove edges already removed from the list of edges to remove. |
xgi/core/simplicialcomplex.py
Outdated
|
||
def k_skeleton(self, order, in_place=True): | ||
"""Returns the k-skeleton of the simplicial complex. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a new paragraph maybe define in a few words what the k-skeleton is, with a reference?
xgi/core/simplicialcomplex.py
Outdated
_H = self | ||
else: | ||
_H = self.copy() | ||
max_order = max(len(edge) for edge in _H._edge.values()) - 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_order = max(len(edge) for edge in _H._edge.values()) - 1 | |
max_order = xgi.max_edge_order(_H) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that I can do from ..algorithms.properties import max_edge_order
in this module because this would lead to a circular import... this probably hints in the direction of having the function in the convert
module then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah fair, but which part would be circular you think? algorithms.properties doesn't import Simplicialcomplex I think. Worth checking maybe. I think there should be a way of using it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xgi/tests/conftest.py:6: in <module>
import xgi
xgi/xgi/__init__.py:1: in <module>
from . import (
xgi/xgi/core/__init__.py:4: in <module>
from .simplicialcomplex import SimplicialComplex
xgi/xgi/core/simplicialcomplex.py:19: in <module>
from ..algorithms.properties import max_edge_order
xgi/xgi/algorithms/__init__.py:1: in <module>
from . import properties, assortativity, centrality, clustering, connected
xgi/xgi/algorithms/centrality.py:10: in <module>
from ..convert import to_line_graph
xgi/xgi/convert/__init__.py:1: in <module>
from . import (
xgi/xgi/convert/bipartite_graph.py:7: in <module>
from ..generators import empty_hypergraph
xgi/xgi/generators/__init__.py:1: in <module>
from . import (
xgi/xgi/generators/simplicial_complexes.py:15: in <module>
from ..core import SimplicialComplex
xgi/core/simplicialcomplex.py
Outdated
if order != max_order: | ||
bunch = _H.edges.filterby("order", order, "gt") | ||
_H.remove_simplex_ids_from(bunch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if order==max_order
we do nothing, and if order<max_order
then we remove all simplices with d>order
right? I don't remember how the k-skeleton is defined heh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes exactly:
The k-skeleton of a simplicial complex is the subcomplex containing all the simplices of the original complex of dimension at most k.
Ok so your code looks good but I just realised: this is just like this general recipe we had also for hypergraphs right? Should we maybe make that into a general function for hypergraphs? |
Yes, from my understanding the whole skeleton business is from algebraic topology and thus refers only to SCs... still you're right that this is doing the same as the recipe + it could be applied in the same way to hypergraphs. If I remember well up to a while ago the
|
The skeletons in XGI's closet.... I like the idea of This all sounds like a good plan! |
thank you @maximelucas and @nwlandry for the feedback, I will implement everything tomorrow/friday. |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Is this ready for re-review, @thomasrobiglio? |
Yes! Thank you @nwlandry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome, @thomasrobiglio! Ready to merge! Thanks so much!
I noticed that #178 has been around for a while and thought it would be a nice way to get back in the PR game.