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, 4, 5, 6], dtype=int32) 0 array([0, 1, 5, 6], dtype=int32) 1 array([34, 35, 36], dtype=int32) 1 array([34, 35, 38, 39], dtype=int32) 1 array([34, 35, 37, 38], dtype=int32) 1 array([12, 23, 33, 47], dtype=int32) 0 array([12, 23, 47, 54], dtype=int32) 1 array([12, 36, 41, 47], dtype=int32) 1 array([12, 46, 47], dtype=int32) 0 array([ 9, 12, 41, 47], dtype=int32) 0 array([ 9, 11, 12, 47], dtype=int32) 0 array([ 9, 12, 24, 47], dtype=int32) 0 array([11, 12, 13, 17, 47], dtype=int32) 0 array([12, 13, 40, 47], dtype=int32) 0 array([12, 40, 41, 47, 54], dtype=int32) 0 array([12, 24, 40, 47], dtype=int32) 0 array([24, 26, 40, 47], dtype=int32) 0 array([26, 40, 45, 47], dtype=int32) 1 array([11, 26, 45, 47], dtype=int32) 0 array([13, 40, 42, 47], dtype=int32) 1 array([33, 37, 47], 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.