cdlib.benchmark.LFR

LFR(n: int, tau1: float, tau2: float, mu: float, average_degree: float = None, min_degree: int = None, max_degree: int = None, min_community: int = None, max_community: int = None, tol: float = 1e-07, max_iters: int = 500, seed: int = 42) → [<class 'object'>, <class 'object'>]

Returns the LFR benchmark graph and planted communities.

Parameters:
  • n – Number of nodes in the created graph.
  • tau1 – Power law exponent for the degree distribution of the created graph. This value must be strictly greater than one.
  • tau2 – Power law exponent for the community size distribution in the created graph. This value must be strictly greater than one.
  • mu – Fraction of intra-community edges incident to each node. This value must be in the interval [0, 1].
  • average_degree – Desired average degree of nodes in the created graph. This value must be in the interval [0, n]. Exactly one of this and min_degree must be specified, otherwise a NetworkXError is raised.
  • min_degree – Minimum degree of nodes in the created graph. This value must be in the interval [0, n]. Exactly one of this and average_degree must be specified, otherwise a NetworkXError is raised.
  • max_degree – Maximum degree of nodes in the created graph. If not specified, this is set to n, the total number of nodes in the graph.
  • min_community – Minimum size of communities in the graph. If not specified, this is set to min_degree.
  • max_community – Maximum size of communities in the graph. If not specified, this is set to n, the total number of nodes in the graph.
  • tol – Tolerance when comparing floats, specifically when comparing average degree values.
  • max_iters – Maximum number of iterations to try to create the community sizes, degree distribution, and community affiliations.
  • seed – (integer, random_state, or None (default)) – Indicator of random number generation state. See Randomness.
Returns:

A networkx synthetic graph, the set of communities (NodeClustering object)

Example:
>>> from cdlib.benchmark import LFR
>>> n = 250
>>> tau1 = 3
>>> tau2 = 1.5
>>> mu = 0.1
>>> G, coms = LFR(n, tau1, tau2, mu, average_degree=5, min_community=20)
References:

Andrea Lancichinetti, Santo Fortunato, and Filippo Radicchi. “Benchmark graphs for testing community detection algorithms”, Phys. Rev. E 78, 046110 2008