mossspider.dgm.clustered_power_law_network

clustered_power_law_network(n_cluster, edges=3, pr_cluster=0.75, pr_between=0.0007, pr_w=0.35, seed=None)

Generate a graph with the following features: follows a power-law degree distribution, high(er) clustering coefficient, and an underlying community structure. This graph is created by generating a number of subgraphs with power-law distributions and clustering. The subgraphs are generated using networkx.powerlaw_cluster_graph(n=n_cluster[...], m=edges, p=p_cluster). This process is repeated for each element in the n_cluster argument. Then the subgraphs are then randomly connected by creating random edges between nodes of the subgraphs.

Parameters
  • n_cluster (list, set, array, ndarray) – Specify the N for each subgraph in the clustered power-law network via a list. List should be positive integers that correspond to the N for each subgraph.

  • edges (int, optional) – Number of edges to generate within each cluster. Equivalent to the m argument in networkx.powerlaw_cluster_graph.

  • pr_cluster (float, optional) – Probability of a new node forming a triad with neighbors of connected nodes

  • pr_between (float, optional) – Probability of an edge between nodes of each cluster. Evaluated for all node pairs, so should be relatively low to keep a high community structure. Default is 0.0007.

  • pr_w (float, optional) – Probability of the binary baseline covariate W for the network. Default is 0.35.

  • seed (int, None, optional) – Random seed. Default is None.

Returns

Return type

networkx.Graph

Examples

Loading the necessary functions

>>> from mossspider.dgm import clustered_power_law_network

Generating the clustered power-law network

>>> G = clustered_power_law_network(n_cluster=[50, 50, 50, 50])