Hi,
Thanks for making graph-tool.
I’m having trouble understanding whether an assumption is relevant to my network/analysis.
The assumption in question is “that the edge existence is decoupled from its weight; i.e., the nonexistence of an edge is different from an edge with zero weight” in your paper " Nonparametric weighted stochastic block models".
My network at first had a single edge between every pair of vertices, weighted based on an ensemble of correlation coefficients and analogous metrics. Most of the edges are insignificantly small or due to noise so I pruned them using noise-corrected backboning: Network Backboning with Noisy Data | IEEE Conference Publication | IEEE Xplore
This reduced the number of edges from ~150 million to ~0.64 million.
My edges are bounded between 0 and 1 so I applied a transformation of x’ = log(1 - x) and use the “real-exponential” distribution option.
Does the pruning step break the above assumption? Is this detrimental to the application of the model? I could try including all edges but I assume computation times would be much longer/impractical.
I’m wondering if I could perhaps alleviate this using the rec_params option. The idea being that if I set theta to the average transformed edge weight before edge pruning, then the model would be weighing the kept edges based on their original distribution. Does this idea have any merit or would sticking to the “microcanonical” default generally be better even when the inputted edge distribution doesn’t resemble the original distribution?
It’s possible that I’m doing something wrong, but I may have found a bug that has made me unable to set r and theta as described here: BlockState — graph-tool 2.97 documentation
I’m using the latest apptainer as of July 22nd.
OS: Linux - CentOS 7
Here is my code:
from graph_tool.all import *
g = load_graph("seidr.F1.28.trans-log1-x.graphml")
rec_config = {
"r": 1.0,
"theta": 0.0620203,
}
state = minimize_nested_blockmodel_dl(g, state_args=dict(recs=[g.ep.weight],
rec_types=["real-exponential"],
rec_params=[rec_config]))
This resulted in the following error:
Traceback (most recent call last):
File "/scratch/trans-graph-tool/./run_minimize_nested_blockmodel_nonmicrocannon.py", line 14, in <module>
state = minimize_nested_blockmodel_dl(g, state_args=dict(recs=[g.ep.weight],
rec_types=["real-exponential"],
rec_params=[rec_config]))
File "/usr/lib/python3.13/site-packages/graph_tool/inference/minimize.py", line 227, in minimize_nested_blockmodel_dl
state = state(g, bs=init_bs, **state_args)
File "/usr/lib/python3.13/site-packages/graph_tool/inference/nested_blockmodel.py", line 96, in __init__
self.levels = [base_type(g_, b=bs[0] if bs is not None else None,
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**self.state_args)]
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/graph_tool/inference/blockmodel.py", line 337, in __init__
self._init_recs(self.rec, rec_types, rec_params)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/graph_tool/inference/blockmodel.py", line 454, in _init_recs
raise ValueError("unknown parameters for weight type: " +
str(list(defaults.keys())))
ValueError: unknown parameters for weight type: ['r', 'theta']
I looked through the code and found that these may instead need to be referred to ‘alpha’ and ‘beta’ instead. I replaced ‘r’ with ‘alpha’ and ‘theta’ with ‘beta’ and obtained the following error instead:
Traceback (most recent call last):
File "/scratch/trans-graph-tool/./run_minimize_nested_blockmodel_nonmicrocannon.py", line 14, in <module>
state = minimize_nested_blockmodel_dl(g, state_args=dict(recs=[g.ep.weight],
rec_types=["real-exponential"],
rec_params=[rec_config]))
File "/usr/lib/python3.13/site-packages/graph_tool/inference/minimize.py", line 227, in minimize_nested_blockmodel_dl
state = state(g, bs=init_bs, **state_args)
File "/usr/lib/python3.13/site-packages/graph_tool/inference/nested_blockmodel.py", line 115, in __init__
self._regen_Lrecdx()
~~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.13/site-packages/graph_tool/inference/nested_blockmodel.py", line 149, in _regen_Lrecdx
Lrecdx.a[1:] += s.recdx.a * s._state.get_B_E_D()
ValueError: non-broadcastable output operand with shape (1,) doesn't match the broadcast shape (2,)
My graphml file is too large to upload here directly but I can try to find another place to upload it if necessary.
Thank you for your time.