Core dump when constructing BlockState
Bug reports:
Please follow the general troubleshooting steps first:
-
Are you running the latest graph-tool
version? -
Do you observe the problem with the current git version? -
Are you using Macports or Homebrew? If yes, please submit an issue there instead: https://github.com/Homebrew/brew/issues and https://trac.macports.org/newticket -
Did you compile graph-tool
manually? -
If you answered yes above, did you use the exact same compiler to build graph-tool
,boost-python
andPython
?
I am running the latest version of graph-tool 2.35 (commit eea271a5) that I installed using conda on python 3.8.5. My OS is Ubuntu 16.04 (I know, I really need to update it now).
The following code reproduces the error:
import graph_tool.all as gt
import numpy as np
G = gt.complete_graph(10)
b = np.array([1]*5 + [-1]*5)
state = gt.BlockState(G, b=b)
I think that I found a corner case because there's no real reason to use negative labels for blocks, it was just handy in the particular piece of code that I was using (in order to take the product to check whether nodes are in the same block).
Something even stranger is that while working inside Jupyter I noticed that creating a BlockState like above sometimes killed my kernel and in weird occasions which I'm not exactly able to reproduce it didn't (perhaps when I had instantiated it with other values somehow? Not sure). When it didn't die, I ran state.get_matrix()
at some point and I noticed that it was 3 by 3 with the middle row and middle column empty, which means that BlockState internally takes as possible block labels all consecutive integers between the min and the max in b
, right?
This makes sense because I know that you are accounting for empty communities. Still, I wonder if the code should then throw an error in my use case because I was expecting -1
and 1
to be the only allowed labels.