# AxelrodState#

class graph_tool.dynamics.AxelrodState(g, f=10, q=2, r=0, s=None)[source]#

Axelrod’s culture dissemination model.

Parameters:
gGraph

Graph to be used for the dynamics

fint (optional, default: 10)

Number of features.

qint (optional, default: 2)

Number of traits for each feature.

rfloat (optional, default: .0)

Spontaneous trait change probability.

sVertexPropertyMap (optional, default: None)

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

Notes

This implements Axelrod’s model for culture dissemination [axelrod-dissemination-1997].

Each node has a vector state $$\boldsymbol s^{(i)} \in \{0,\dots,q-1\}^f$$.

If a node $$i$$ is updated at time $$t$$, the transition to state $$\boldsymbol s^{(i)}(t+1)$$ is done as follows:

1. With probability $$r$$ a feature $$l$$ is chosen uniformly at random from the interval $$\{0,\dots,f-1\}$$, and a trait $$r$$ is chosen uniformly at random from the interval $$\{0,\dots,q-1\}$$, and the new state is set as $$s^{(i)}_l(t+1)=r$$.

2. Otherwise, a neighbour $$j$$ is chosen uniformly at random, and we let $$d$$ be the number of equal traits across features between $$i$$ and $$j$$,

$d = \sum_{l=0}^{f-1} \delta_{s^{(i)}_l(t), s^{(j)}_l(t)}.$

Then with probability $$d/f$$ a trait $$l$$ is chosen uniformly at random from the set of differing features of size $$f-d$$, i.e. $$\{l|s^{(i)}_l(t) \ne s^{(j)}_l(t)\}$$, and the corresponding trait of $$j$$ is copied to $$i$$: $$s^{(i)}_l(t+1) = s^{(j)}_l(t)$$.

3. Otherwise we have $$\boldsymbol s_i(t+1) = \boldsymbol s_i(t)$$.

References

Axelrod, R., “The Dissemination of Culture: A Model with Local Convergence and Global Polarization”, Journal of Conflict Resolution, 41(2), 203–226 (1997). DOI: 10.1177/0022002797041002001 [sci-hub, @tor]

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.AxelrodState(g, f=10, q=30, r=0.005)
>>> ret = state.iterate_async(niter=10000000)
>>> gt.graph_draw(g, g.vp.pos,
...               vertex_fill_color=gt.perfect_prop_hash([state.s])[0],
...               vcmap=cm.magma, output="axelrod.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.