Although networkx has good support, it is extremely slow, especially for large graphs. I recommend graph-tool (I have used it for learning dynamics of contagion models, and it exponentially outperforms networkx)
Good suggestion @VolodyaCO thanks, I wasn't aware of this library. However it seems dependent on Boost and it's compiled C++. Does it come in a pip package?
When I installed it I had to do it with a non-standard conda channel. Apparently it is now included in conda-forge. I'm not sure it's in a pip package...
Alright then it's a no-go for the moment. We can stick to igraph and networkx that have better support. For our tasks they should be relatively fast, since in most cases the lists of edges etc are computed only once.
Well, if it's for small graphs, then surely this is not a critical performance issue and the best decision is to stay with networkx, as it is the most used one (with the best support).
@gcarleo I could try to help, but I am unfamiliar with the C++ code. If you give me specific tasks I can try to do them. However, maybe a member of the developer team is able to perform this work quicker and better.
@VolodyaCO a specific first task to start with would be to write an AbstractGraph class in python (say, similar to this style ) that defines what the common interface of the graphs in python should be. In practice, it should have the same methods of the graph classes we already have. Essentially the attributes as defined in here
The pull request should be done to the branch v3.0.
@gcarleo can I write the CustomGraph, and the rest of the graphs using networkx? Also, should I create a new pull request when I write most of the code?
Yes that sounds good, basically HyperCube and CustomGraph are just special cases of already existing networkx graphs . The only trickier case is Lattice, but maybe we could use some other existing library, for example https://pypi.org/project/pbcpy/ or others
@gcarleo do you want me to check that the nodes are always labeled by integers? Or should I give freedom to label nodes as strings?, e.g. nk.graph.CustomGraph([("cavity 1", "cavity 2", "color 1")])
I think that at the moment we construct CustomGraph just using a list of (integer) edges... maybe I would leave it this way since it seems easier to handle? I also realized that we actually don't need networkx to implement CustomGraph, it is easier to just work with scipy.sparse.csgraph since it has already all the methods we need!
It was just to avoid introducing the explicit dependence on networkx for the simple cases we are interested in... if it's not too much work I would write CustomGraph with the scipy version, and leave the wrapper you already wrote for networkx as another class/converter to netket.AbstractGraph (maybe call it netket.graph.NetworkX that can be constructed from a networkx graph?)... up to you
Yes sorry! I realize that there is a few methods missing in the scipy interface anyways... (is_bipartite is not there and finding automorphisms is definitely not there) so indeed it makes more sense to proceed with networkx...
I was checking that before as well... but I was a bit unsure of including something of the sort because in the C++ implementation the automorphisms are an input to the CustomGraph. However, it should be something that gets computed always, right @gcarleo ? i.e. it shouldn't be an argument of the init method.
Indeed, the old C++ implementation was quite limited in this. Now we can make it automatically computed when one calls .automorphisms() (I wouldn't compute it by default though, but only if one calls that method and wants the automorphisms)...
Also, it would be a good idea to call the main class you are writing just netket.Graph, it doesn't really make sense to call this CustomGraph anymore! (that was a kind of weird name that was left from version 1.0..)