SLCD Simulator: Social Learning Community Detection
Interactive companion simulator for decentralized community detection with nonlinear opinion dynamics: SER, RNP and RNP-DC running live in the browser.
Official Companion Tool: This simulator accompanies the paper “Social learning community detection with nonlinear interaction” by A. Couthures, A. V. Jayakumar, V. S. Varma, I.-C. Morărescu, S. Lasaulce and A. Girard (preprint, 2026).
Can a network find its own communities, without anyone seeing the whole graph? In this model every node is an agent with a private opinion, and it only observes the saturated public actions of its neighbors. When the agents react strongly enough to each other, the network polarizes along its sparsest cuts, and the communities can be read from where the opinions settle. No agent needs a global view of the graph or has to reveal its private opinion.
1. How It Works
Agent \(i\) holds an opinion \(x_i \in [-1, 1]\) and broadcasts the action \(s(x_i) = \min(1, \max(-1, Kx_i))\), a saturated version of its opinion with gain \(K\). At each step, every agent moves towards the average action of its neighbors:
\[x(t+1) = x(t) + h\big(P\, s(x(t)) - x(t)\big), \qquad P = D^{-1}A.\]
- Weak gain: consensus. If \(K\) is below the threshold \(K^\star = 1/\lambda_{N-1}(P)\), set by the second-largest eigenvalue of \(P\), all agents end up agreeing and nothing is learned about the graph.
- Strong gain: polarization. Above \(K^\star\), agreement becomes unstable. Densely connected groups lock together on one side, so the network splits along its weakest links.
- Reading the communities. An edge inside a community almost always connects agents that agree at the end. An edge between communities is often in tension. The three algorithms below turn this observation into a partition.
SER recommended
Score-based Edge Reliability
Run the dynamics \(M\) times from random opinions. In a run, the two ends of an edge agree if
\[|s(x_i) - s(x_j)| < \varepsilon.\]
The reliability \(P_{ij}\) of the edge is the share of runs in which they agree. Keep the edges with \(P_{ij} \geq \tau\): the communities are the connected groups that remain.
RNP
Recursive Neighbor Pruning
Let the network polarize, then cut every edge whose two ends took opposite sides in one of the runs:
\[s(x_i)\, s(x_j) < 0\]
Repeat on what is left until nothing more is cut.
RNP-DC
RNP with Decaying Confidence
Cut edges during the dynamics, as soon as their tension exceeds a confidence radius that shrinks over time:
\[|s(x_i(t)) - s(x_j(t))| > R\rho^{\,t}\]
Works with multi-plateau signals such as a staircase.
All three are fully decentralized: an agent only needs the actions of its own neighbors.
2. Interactive Demo
Pick a network and an algorithm. The detection runs live in your browser, using a JavaScript port of the slcd package that gives the same results as the paper’s code. Each network starts with the parameters used in the paper.
Network
Dynamics
Algorithm
Things to try
- Cross the threshold. Lower \(K\) below \(K^\star\): agents reach consensus, no edge is ever in tension, and every algorithm returns a single community.
- Blur the communities. On the block model, raise p between. Once the blocks are too mixed, the match with the true groups drops.
- Karate club. SER finds the two famous factions, plus a few smaller groups. Hover the dashed edges: they are the fracture lines of the club.
- Football. The 12 conferences are recovered almost exactly. The Independents teams have no conference, so they end up isolated or merged with others.
- Watch it happen. Press ▶ Watch one run to see one realization of the dynamics polarize the network.
3. Use the Code
The Python package slcd has a NetworkX-style API and depends only on NumPy, SciPy and NetworkX. The repository also contains the scripts that reproduce every figure of the paper.
git clone https://github.com/AnthonyCouthures/Social-Learning-Community-Detection.git
cd Social-Learning-Community-Detection
pip install -e .import networkx as nx
import slcd
G = nx.karate_club_graph()
print("K* =", slcd.spectral_threshold(G))
communities = slcd.ser_communities(G, K=5, epsilon=0.2, h=0.1, seed=0) # list of sets of nodes
print(nx.community.modularity(G, communities))rnp_communities and rnp_dc_communities work the same way, and ser_edge_reliability returns the score \(P_{ij}\) of every edge.
4. How to Cite
If you use this code, please cite the paper:
@article{couthures2026social,
title = {Social learning community detection with nonlinear interaction},
author = {Couthures, Anthony and Jayakumar, Athira Varma and Varma, Vineeth Satheeskumar and
Mor{\u{a}}rescu, Irinel-Constantin and Lasaulce, Samson and Girard, Antoine},
year = {2026},
eprint = {2606.00268},
archivePrefix = {arXiv},
primaryClass = {cs.SI},
doi = {10.48550/arXiv.2606.00268}
}The nonlinear consensus model behind it is the one of the COSA Simulator, studied in Couthures et al., IEEE Control Systems Letters, 2025.
Data. Zachary’s karate club: W. W. Zachary, J. Anthropol. Res. 33, 452–473 (1977). US college football 2000: M. Girvan and M. E. J. Newman, PNAS 99, 7821–7826 (2002), data distributed by M. Newman. The code is released under the MIT License.
