Skip to main content

Crate sangha

Crate sangha 

Source
Expand description

§Sangha — Sociology Engine

सङ्घ (Sanskrit: community, assembly)

A Rust library for computational sociology: social networks, game theory, group dynamics, population models, opinion dynamics, inequality, coalition formation, collective decision-making, trust, and contagion.

§Modules

  • network — Social network graphs, Watts-Strogatz, Barabasi-Albert, BFS, centrality
  • game_theory — Nash equilibria, prisoner’s dilemma, iterated games
  • coordination — N-player public goods, auctions, tragedy of the commons, folk theorem
  • coalition — Shapley value, core stability, faction merge/split
  • collective — Voting (plurality, Borda, Condorcet), jury theorem, wisdom of crowds
  • trust — Trust propagation, reputation aggregation, decay, betrayal
  • contagion — Hatfield emotional contagion, SIS dynamics, mood propagation
  • opinion — Bounded confidence, echo chambers, consensus
  • group — Tuckman stages, social loafing, groupthink
  • population — Logistic growth, SIR model, herd immunity
  • influence — Conformity, social proof, Bass diffusion
  • inequality — Gini coefficient, Lorenz curve

§Example

use sangha::population;

// Herd immunity threshold for R0 = 3
let h = population::herd_immunity_threshold(3.0).unwrap();
assert!((h - 2.0 / 3.0).abs() < 1e-10); // ~66.7%

// Gini coefficient of equal distribution
let g = sangha::inequality::gini_coefficient(&[100.0, 100.0, 100.0]).unwrap();
assert!(g.abs() < 1e-10); // perfect equality

Re-exports§

pub use error::SanghaError;

Modules§

coalition
Coalition game theory — Shapley value, core stability, faction dynamics.
collective
Group decision-making — voting methods, wisdom of crowds, jury theorem.
contagion
Emotional and behavioral contagion — Hatfield model, SIS dynamics, mood propagation.
coordination
Multi-agent coordination — public goods games, auctions, mechanism design.
error
Error types for the sangha sociology engine.
game_theory
Game theory — Nash equilibria, prisoner’s dilemma, evolutionary strategies.
group
Group dynamics — cohesion, social loafing, groupthink, Tuckman stages.
inequality
Inequality — Gini coefficient, Lorenz curve, distribution metrics.
influence
Social influence — conformity, diffusion, social proof.
network
Social networks — graph models, metrics, small-world properties.
opinion
Opinion dynamics — voter model, bounded confidence, polarization.
population
Population dynamics — growth models, epidemiology (SIR).
trust
Trust and reputation — trust propagation, reputation aggregation, decay, betrayal.