# cdlib.algorithms.spinglass¶

spinglass(g_original: object, spins: int = 25) → cdlib.classes.node_clustering.NodeClustering

Spinglass relies on an analogy between a very popular statistical mechanic model called Potts spin glass, and the community structure. It applies the simulated annealing optimization technique on this model to optimize the modularity.

Supported Graph Types

Undirected Directed Weighted
Yes No No
Parameters: g_original – a networkx/igraph object spins – the number of spins to use. This is the upper limit for the number of communities. It is not a problem to supply a (reasonably) big number here, in which case some spin states will be unpopulated. NodeClustering object
>>> from cdlib import algorithms
>>> import networkx as nx
>>> G = nx.karate_club_graph()
>>> com = algorithms.spinglass(G)


Reichardt, Jörg, and Stefan Bornholdt. Statistical mechanics of community detection. Physical Review E 74.1 (2006): 016110.