probinet.synthetic.reciprocity#

Class definition of the reciprocity generative models with the member functions required. It builds a directed, possibly weighted, network.

Classes

GM_reciprocity(N, K[, eta, avg_degree, ...])

A class to generate a directed, possibly weighted, network with reciprocity.

ReciprocityMMSBM_joints(**kwargs)

Proposed benchmark.

class probinet.synthetic.reciprocity.GM_reciprocity(N: int, K: int, eta: float = 0.5, avg_degree: float = 3, over: float = 0.0, corr: float = 0.0, seed: int = 0, alpha: float = 0.1, ag: float = 0.1, beta: float = 0.1, Normalization: int = 0, structure: str = 'assortative', end_file: str | None = None, out_folder: Path = PosixPath('outputs'), output_parameters: bool = False, output_adj: bool = False, outfile_adj: str | None = None, ExpM: float | None = None)[source]#

A class to generate a directed, possibly weighted, network with reciprocity.

planted_network_cond_independent(parameters: Tuple[ndarray, ndarray, ndarray] | None = None) Tuple[MultiDiGraph, ndarray][source]#

Generate a directed, possibly weighted network without using reciprocity. It uses conditionally independent A_ij from a Poisson | (u,v,w).

Parameters:

parameters (Tuple[np.ndarray, np.ndarray, np.ndarray], optional) – Latent variables u, v, and w.

Returns:

  • G (MultiDigraph) – MultiDiGraph NetworkX object.

  • A (np.ndarray) – The adjacency matrix of the generated network.

planted_network_reciprocity_only(p: float | None = None) Tuple[MultiDiGraph, ndarray][source]#

Generate a directed, possibly weighted network using only reciprocity. One of the directed-edges is generated with probability p, the other with eta*A_ji, i.e. as in Erdos-Renyi reciprocity.

Parameters:

p (float, optional) – Probability to generate one of the directed-edge.

Returns:

  • G (MultiDigraph) – MultiDiGraph NetworkX object.

  • A (np.ndarray) – The adjacency matrix of the generated network.

reciprocity_planted_network(parameters: Tuple[ndarray, ndarray, ndarray, float] | None = None) Tuple[MultiDiGraph, ndarray][source]#

Generate a directed, possibly weighted network by using the reciprocity generative model. Can be used to generate benchmarks for networks with reciprocity.

Steps:
  1. Generate the latent variables.

  2. Extract A_ij entries (network edges) from a Poisson distribution; its mean depends on the latent variables.

Parameters:

parameters (Tuple[np.ndarray, np.ndarray, np.ndarray, float], optional) – Latent variables u, v, w, and eta.

Returns:

  • G (MultiDiGraph) – MultiDiGraph NetworkX object.

  • A (np.ndarray) – The adjacency matrix of the generated network.

class probinet.synthetic.reciprocity.ReciprocityMMSBM_joints(**kwargs)[source]#

Proposed benchmark. Create a synthetic, directed, and binary network (possibly multilayer) by a mixed-membership stochastic block-model with a reciprocity structure - It models pairwise joint distributions with Bivariate Bernoulli distributions

build_Y(parameters: Tuple[ndarray, ndarray, ndarray] | None = None) None[source]#

Generate network layers G using the latent variables, with the generative model (A_ij,A_ji) ~ P(A_ij, A_ji|u,v,w,eta)

Parameters:

parameters (Tuple[np.ndarray, np.ndarray, np.ndarray], optional) – Latent variables u, v, and w.