# IsingGlauberState#

class graph_tool.dynamics.IsingGlauberState(g, beta=1.0, w=1.0, h=0.0, s=None)[source]#

Glauber dynamics of the Ising model.

Parameters:
gGraph

Graph to be used for the dynamics

betafloat (optional, default: 1.)

Inverse temperature.

wEdgePropertyMap or float (optional, default: 1.)

Edge interaction strength. If a scalar is provided, it’s used for all edges.

hVertexPropertyMap or float (optional, default: 0.)

Vertex local field. If a scalar is provided, it’s used for all vertices.

sVertexPropertyMap (optional, default: None)

Initial global state. If not provided, a random state will be chosen.

Notes

This implements the Glauber dynamics of the Ising model [ising-model] on a network.

If a node $$i$$ is updated at time $$t$$, the transition to state $$s_i(t+1) \in \{-1,+1\}$$ is done with probability

$P(s_i(t+1)|\boldsymbol s(t)) = \frac{\exp(\beta s_i(t+1)\sum_jA_{ij}w_{ij}s_j(t) + h_is_i(t+1))} {2\cosh(\beta\sum_jA_{ij}w_{ij}s_j(t) + h_i)}.$

References

Examples

>>> g = gt.GraphView(gt.collection.data["polblogs"].copy(), directed=False)
>>> gt.remove_parallel_edges(g)
>>> g = gt.extract_largest_component(g, prune=True)
>>> state = gt.IsingGlauberState(g, beta=.05)
>>> ret = state.iterate_async(niter=1000 * g.num_vertices())
>>> gt.graph_draw(g, g.vp.pos, vertex_fill_color=state.s,
...               output="glauber-ising.svg")
<...>


Methods

 Return a copy of the state. Returns list of "active" nodes, for states where this concept is used. Returns the internal VertexPropertyMap with the current state. iterate_async([niter]) Updates nodes asynchronously (i.e. single vertex chosen randomly), niter number of times. iterate_sync([niter]) Updates nodes synchronously (i.e. a full "sweep" of all nodes in parallel), niter number of times. Resets list of "active" nodes, for states where this concept is used. set_active(active) Sets the list of "active" nodes, for states where this concept is used.
copy()#

Return a copy of the state.

get_active()#

Returns list of “active” nodes, for states where this concept is used.

get_state()#

Returns the internal VertexPropertyMap with the current state.

iterate_async(niter=1)#

Updates nodes asynchronously (i.e. single vertex chosen randomly), niter number of times. This function returns the number of nodes that changed state.

iterate_sync(niter=1)#

Updates nodes synchronously (i.e. a full “sweep” of all nodes in parallel), niter number of times. This function returns the number of nodes that changed state.

Parallel implementation.

If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.

reset_active()#

Resets list of “active” nodes, for states where this concept is used.

set_active(active)#

Sets the list of “active” nodes, for states where this concept is used.