ExhaustiveSweepState#
- class graph_tool.inference.ExhaustiveSweepState(entropy_args={})[source]#
Bases:
EntropyState
Base state that implements exhaustive enumerative sweeps.
Methods
exhaustive_sweep
([entropy_args, callback, ...])Perform an exhaustive loop over all possible network partitions.
Return the current default values for the parameters of the function
entropy()
, together with other operations that depend on them.Reset the current default values for the parameters of the function
entropy()
, together with other operations that depend on them.update_entropy_args
(**kwargs)Update the default values for the parameters of the function
entropy()
from the keyword arguments, in a stateful way, together with other operations that depend on them.- exhaustive_sweep(entropy_args={}, callback=None, density=None, vertices=None, initial_partition=None, max_iter=None)[source]#
Perform an exhaustive loop over all possible network partitions.
- Parameters:
- entropy_args
dict
(optional, default:{}
) Entropy arguments, with the same meaning and defaults as in
graph_tool.inference.BlockState.entropy()
.- callbackcallable object (optional, default:
None
) Function to be called for each partition, with three arguments
(S, S_min, b_min)
corresponding to the the current entropy value, the minimum entropy value so far, and the corresponding partition, respectively. If not provided, andhist is None
an iterator over the same values will be returned instead.- density
tuple
(optional, default:None
) If provided, it should contain a tuple with values
(S_min, S_max, n_bins)
, which will be used to obtain the density of states via a histogram of sizen_bins
. This parameter is ignored unlesscallback is None
.- verticesiterable of ints (optional, default:
None
) If provided, this should be a list of vertices which will be moved. Otherwise, all vertices will.
- initial_partitioniterable of ints (optional, default:
None
) If provided, this will provide the initial partition for the iteration.
- max_iter
int
(optional, default:None
) If provided, this will limit the total number of iterations.
- entropy_args
- Returns:
- statesiterator over (S, S_min, b_min)
If
callback
isNone
andhist
isNone
, the function will return an iterator over(S, S_min, b_min)
corresponding to the the current entropy value, the minimum entropy value so far, and the corresponding partition, respectively.- Ss, countspair of
numpy.ndarray
If
callback is None
andhist is not None
, the function will return the values of each bin (Ss
) and the state count of each bin (counts
).- b_min
VertexPropertyMap
If
callback is not None
orhist is not None
, the function will also return partition with smallest entropy.
Notes
This algorithm has an \(O(B^N)\) complexity, where \(B\) is the number of groups, and \(N\) is the number of vertices.
- get_entropy_args()#
Return the current default values for the parameters of the function
entropy()
, together with other operations that depend on them.