xgi-org / xgi

CompleX Group Interactions (XGI) is a Python package for higher-order networks.
https://xgi.readthedocs.io
Other
172 stars 27 forks source link

Flagged lattices? #504

Closed thomasrobiglio closed 4 months ago

thomasrobiglio commented 5 months ago

I have noticed that our functions flag_complex and flag_complex_d2 return errors when giving as imput graph a lattice. Example:

>>> import networkx as nx
>>> import xgi
>>> G = nx.triangular_lattice_graph(m=5, n=5)
>>> S = xgi.flag_complex_d2(G=G, p2=0.5)

This is because the nodes in the nx lattice are stored as tuples (the cordinates of the lattice site):

>>> G.nodes
NodeView(((0, 0), (1, 0), (2, 0), (3, 0), (0, 1), (1, 1), (2, 1), (0, 2), (1, 2), (2, 2), (3, 2), (0, 3), (1, 3), (2, 3), (0, 4), (1, 4), (2, 4), (3, 4), (0, 5), (1, 5), (2, 5)))

If we are interested I can work on a feature to flag lattices and/or generate lattices with this flavor (we only have ring lattices for now). Let me know what you think and how you think whis should be positioned (do we want to add options to the already existing functions? or build new ones to make explicit the lattice aspect?).

BONUS: networkX gives us the nodes' positions for free so we can have cool visualizations like this: Screenshot 2024-02-02 alle 12 07 16

maximelucas commented 5 months ago

This is a good idea. I actually already have some code to do this. I'll dig it up when I have time.

thomasrobiglio commented 5 months ago

Thanks @maximelucas actually I also have the code, when I have a bit more time I will do a PR

thomasrobiglio commented 4 months ago

Update: I think it's better to just have a recipe for this (the are just minor twitches from the functions we already have). I will do a PR soon