# spinglass.community

0th

Percentile

##### Finding communities in graphs based on statistical meachanics

This function tries to find communities in graphs via a spin-glass model and simulated annealing.

Keywords
graphs
##### Usage
spinglass.community(graph, weights=NULL, vertex=NULL, spins=25,
parupdate=FALSE, start.temp=1, stop.temp=0.01,
cool.fact=0.99, update.rule=c("config", "random",
"simple"), gamma=1, implementation=c("orig", "neg"),
gamma.minus=1)
##### Arguments
graph
The input graph, can be directed but the direction of the edges is neglected.
weights
The weights of the edges. Either a numeric vector or NULL. If it is null and the input graph has a weight edge attribute then that will be used. If NULL and no such attribute is present then the edges
vertex
This parameter can be used to calculate the community of a given vertex without calculating all communities. Note that if this argument is present then some other arguments are ignored.
spins
Integer constant, 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.
parupdate
Logical constant, whether to update the spins of the vertices in parallel (synchronously) or not. This argument is ignored if the second form of the function is used (ie. the vertex argument is present).
start.temp
Real constant, the start temperature. This argument is ignored if the second form of the function is used (ie. the vertex argument is present).
stop.temp
Real constant, the stop temperature. The simulation terminates if the temperature lowers below this level. This argument is ignored if the second form of the function is used (ie. the vertex argument is presen
cool.fact
Cooling factor for the simulated annealing. This argument is ignored if the second form of the function is used (ie. the vertex argument is present).
update.rule
Character constant giving the null-model of the simulation. Possible values: simple and config. simple uses a random graph with the same number of edges as the baseline probab
gamma
Real constant, the gamma argument of the algorithm. This specifies the balance between the importance of present and non-present edges in a community. Roughly, a comunity is a set of vertices having many edges inside the community and few edge
implementation
Character scalar. Currently igraph contains two implementations for the Spin-glass community finding algorithm. The faster original implementation is the default. The other implementation, that takes into account negative weights, can be c
gamma.minus
Real constant, the gamma.minus parameter of the algorithm. This specifies the balance between the importance of present and non-present negative weighted edges in a community. Smaller values of gamma.minus, leads to communities with lesser
##### Details

This function tries to find communities in a graph. A community is a set of nodes with many edges inside the community and few edges between outside it (i.e. between the community itself and the rest of the graph.)

This idea is reversed for edges having a negative weight, ie. few negative edges inside a community and many negative edges between communities. Note that only the neg implementation supports negative edge weights.

The spinglass.cummunity function can solve two problems related to community detection. If the vertex argument is not given (or it is NULL), then the regular community detection problem is solved (approximately), i.e. partitioning the vertices into communities, by optimizing the an energy function.

If the vertex argument is given and it is not NULL, then it must be a vertex id, and the same energy function is used to find the community of the the given vertex. See also the examples below.

##### Value

• If the vertex argument is not given, ie. the first form is used then a spinglass.community returns a communities object.

If the vertex argument is present, ie. the second form is used then a named list is returned with the following components:

• communityNumeric vector giving the ids of the vertices in the same community as vertex.
• cohesionThe cohesion score of the result, see references.
• inner.linksThe number of edges within the community of vertex.
• outer.linksThe number of edges between the community of vertex and the rest of the graph.

##### concept

• Statistical mechanics
• Spin-glass
• Community structure

##### References

J. Reichardt and S. Bornholdt: Statistical Mechanics of Community Detection, Phys. Rev. E, 74, 016110 (2006), http://arxiv.org/abs/cond-mat/0603718

M. E. J. Newman and M. Girvan: Finding and evaluating community structure in networks, Phys. Rev. E 69, 026113 (2004)

V.A. Traag and Jeroen Bruggeman: Community detection in networks with positive and negative links, http://arxiv.org/abs/0811.2329 (2008).

communities, clusters

##### Aliases
• spinglass.community
##### Examples
g <- erdos.renyi.game(10, 5/10) %du% erdos.renyi.game(9, 5/9)
spinglass.community(g, vertex=1)