The block_models module¶
This module contains a series of function that can generate random graphs with a signed community structure.
-
block_models.
SBAM
(n, k, p, eta)¶ A signed Barabási–Albert model graph generator.
Parameters: - n – (int) Number of nodes.
- k – (int) Number of communities.
- p – (float) Sparsity value.
- eta – (float) Noise value.
Returns: (a,b),c where a is a sparse n by n matrix of positive edges, b is a sparse n by n matrix of negative edges c is an array of cluster membership.
-
block_models.
SRBM
(n, k, p, eta)¶ A signed regular graph model generator.
Parameters: - n – (int) Number of nodes.
- k – (int) Number of communities.
- p – (float) Sparsity value.
- eta – (float) Noise value.
Returns: (a,b),c where a is a sparse n by n matrix of positive edges, b is a sparse n by n matrix of negative edges c is an array of cluster membership.
-
block_models.
SSBM
(n, k, pin, etain, pout=None, etaout=None, values='ones', sizes='uniform')¶ A signed stochastic block model graph generator.
Parameters: - n – (int) Number of nodes.
- k – (int) Number of communities.
- pin – (float) Sparsity value within communities.
- etain – (float) Noise value within communities.
- pout – (float) Sparsity value between communities.
- etaout – (float) Noise value between communities.
- values – (string) Edge weight distribution (within community and without sign flip; otherwise weight is negated): ‘ones’: Weights are 1. ‘gaussian’: Weights are Gaussian, with variance 1 and expectation of 1.# ‘exp’: Weights are exponentially distributed, with parameter 1. ‘uniform: Weights are uniformly distributed between 0 and 1.
- sizes – (string) How to generate community sizes: ‘uniform’: All communities are the same size (up to rounding). ‘random’: Nodes are assigned to communities at random. ‘uneven’: Communities are given affinities uniformly at random, and nodes are randomly assigned to communities weighted by their affinity.
Returns: (a,b),c where a is a sparse n by n matrix of positive edges, b is a sparse n by n matrix of negative edges c is an array of cluster membership.