CliqueState#
- class graph_tool.inference.CliqueState(g, init_edges=False, init_max_cliques=True, init_list=None)[source]#
Bases:
objectThe state of a clique decomposition of a given graph.
- Parameters:
- g
Graph Graph to be modelled.
- init_edges
bool(optional, default:False) If
True, the state will be initialized with edges being occupied.- init_max_cliques
bool(optional, default:True) If
True, the state will be initialized with the maximal cliques.- init_list
dict(optional, default:{}) If given, this will give the initialization state. Keys are the clique nodes and values are the counts.
- g
References
[young-hypergraph-2021]Young, JG., Petri, G., Peixoto, T.P. “Hypergraph reconstruction from network data”, Commun Phys 4, 135 (2021), DOI: 10.1038/s42005-021-00637-w [sci-hub, @tor], arXiv: 2008.04948
Examples
>>> g = gt.collection.data["polbooks"] >>> state = gt.CliqueState(g) >>> state.mcmc_sweep(niter=10000) (...) >>> cliques = [] >>> for v in state.f.vertices(): # iterate through factor graph ... if state.is_fac[v]: ... continue # skip over factors ... print(state.c[v], state.x[v]) # clique occupation ... if state.x[v] > 0: ... cliques.append(state.c[v]) ... if len(cliques) > 10: ... break array([0, 2, 4, 5], dtype=int32) 1 array([0, 1, 3, 5], dtype=int32) 1 array([0, 1, 5, 6], dtype=int32) 1 array([0, 4, 5, 6], dtype=int32) 0 array([2, 5, 7], dtype=int32) 1 array([ 4, 28], dtype=int32) 1 array([ 4, 6, 29], dtype=int32) 1 array([ 4, 30, 31], dtype=int32) 0 array([5, 6, 7], dtype=int32) 0 array([ 7, 71], dtype=int32) 1 array([ 7, 14, 58], dtype=int32) 1 array([ 7, 58, 85], dtype=int32) 0 array([ 7, 30, 58], dtype=int32) 1 array([ 6, 10, 12], dtype=int32) 0 array([ 6, 12, 18], dtype=int32) 1 array([ 8, 12, 13, 32], dtype=int32) 1
Methods
copy(**kwargs)Copies the state.
entropy(**kwargs)Get the description length, a.k.a.
get_nEd()Get fraction of edge counts per clique size
mcmc_sweep([niter, beta])Runs
niteriterations of a Metropolis-Hastings MCMC, with inverse temperaturebeta, to sample clique decompositions.reset_Ed()Reset edge counts
Reset factor constraints
- copy(**kwargs)[source]#
Copies the state. The parameters override the state properties, and have the same meaning as in the constructor.