Skip to content

Module: ContactNetworkGenerator

Niema Moshiri edited this page Dec 21, 2021 · 45 revisions

The ContactNetworkGenerator module creates an edge list representing the input contact network (either by reading it from file or generating it). See the source code to see what is defined by the abstract class.

List of Implementations

  • Implements the ContactNetworkGenerator using the Barabási-Albert (BA) model
    • Under the BA model, a graph of n nodes is grown by attaching new nodes each with m edges that are preferentially attached to existing nodes with high degree
    • The resulting graphs are undirected
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • num_cn_nodes: Desired number of nodes in the contact network (n)
    • num_edges_from_new: The number of edges that are attached from new nodes to existing nodes (m)
      • This number is roughly half the average node degree
  • Implements the ContactNetworkGenerator using the Extended Barabási-Albert (BA) model
    • With p probability, m new edges are added to the graph, starting from randomly chosen existing nodes and attached preferentially at the other end
    • With q probability, m existing edges are rewired by randomly choosing an edge and rewiring one end to a preferentially chosen node
    • With (1−pq) probability, m new nodes are added to the graph with edges attached preferentially
    • When p = q = 0, the model behaves just like the Barabási–Albert model
    • The resulting graphs are undirected
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • num_cn_nodes: Desired number of nodes in the contact network (n)
    • num_edges_from_new: The number of edges that are attached from new nodes to existing nodes (m)
    • bae_p: The probability value for adding an edge between existing nodes (p)
    • bae_q: The probability value of rewiring of existing edges (q)
      • bae_p + bae_q < 1
  • Implements the ContactNetworkGenerator using the Barbell Graph
    • Two identical complete graphs K{m1} form the left and right bells and are connected by a path P{m2}.
    • The resulting graphs are undirected
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • barbell_m1: The m1 parameter of the Barbell Graph
    • barbell_m2: The m2 parameter of the Barbell Graph
  • Implements the ContactNetworkGenerator using the Caveman Graph
    • The resulting graphs are undirected
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • cave_num_cliques: Number of cliques
    • cave_clique_size: Number of nodes in each clique
  • Implements the ContactNetworkGenerator using the Connected Caveman Graph
    • The resulting graphs are undirected
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • cave_num_cliques: Number of cliques
    • cave_clique_size: Number of nodes in each clique
  • Implements the ContactNetworkGenerator using the Relaxed Caveman Graph
    • The resulting graphs are undirected
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • cave_num_cliques: Number of cliques
    • cave_clique_size: Number of nodes in each clique
    • cave_prob: Probability of rewiring each edge
  • Implements the ContactNetworkGenerator using CCMnet_py (Goyal et al., 2014)
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • num_cn_nodes: Desired number of nodes in the contact network (n)
    • network_stats: List of network properties to include in the model. Options:
      • "Degree": Degree distribution
      • "Mixing": Mixing distribution
      • "Density": Network density (NOT IMPLEMENTED YET)
      • "DegMixing": Degree mixing matrix (NOT IMPLEMENTED YET)
      • "Triangles": Number of 3-cycles (NOT IMPLEMENTED YET)
    • prob_dists: List of distributions associated with each network property listed in network_stats. Options:
      • "MultinomialPoisson": Multinomial Poisson distribution
      • "Normal": Normal distribution (NOT IMPLEMENTED YET)
    • prob_dist_params: TODO CONTINUE HERE
  • Implements the ContactNetworkGenerator such that each community in the graph is generated from a user-specified existing ContactNetworkGenerator implementation, and random edges are placed between the communities with some probability
    • The edges that connect individuals across communities are undirected
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
    • NumPy
    • Any requirements for any of the chosen ContactNetworkGenerator module implementations
  • Config Parameters:
    • cn_generators: A list of dictionaries such that each i-th dictionary corresponds to the i-th community
      • One key in the i-th dictionary must be "ContactNetworkGenerator", and its value must be one of the existing ContactNetworkGenerator implementations (including this one)
      • The remaining keys must be the config parameters and values for the chosen ContactNetworkGenerator implementation for the i-th community
      • For example, [{"ContactNetworkGenerator":"Complete","num_cn_nodes":10},{"ContactNetworkGenerator":"Complete","num_cn_nodes":20}] will create two communities (one with 10 individuals and the other with 20), each using ContactNetworkGenerator_Complete
    • cn_p_across: The probability that a given possible inter-community edge will be created
  • Implements the ContactNetworkGenerator using the Complete Graph
    • The resulting graphs are undirected
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • num_cn_nodes: Desired number of nodes in the contact network
  • Implements the ContactNetworkGenerator by generating a random graph with a user-given degree distribution
    • The resulting graphs are undirected
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • cn_degree_distribution: Desired degree distribution as a dictionary in which keys are degrees (positive integers) and values are counts (positive integers) denoting the number of individuals with a given degree
    • cn_tries: The number of tries to generate the graph
  • Implements the ContactNetworkGenerator using the Erdős–Rényi (ER) model
    • Under the ER model, each of the possible n(n-1)/2 undirected or n(n-1) directed edges is chosen with a probability p
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • num_cn_nodes: Desired number of nodes in the contact network
    • er_prob: The ER model probability p
    • d_or_u: "d" if you want directed edges, or "u" if you want undirected edges
  • Implements the ContactNetworkGenerator module such that the contact network edge list is read from file
  • Requirements:
    • None
  • Config Parameters:
  • Implements the ContactNetworkGenerator using the Newman-Watts-Strogatz model
    • The algorithm behind the WS model is as follows:
      1. Create a ring over n nodes
      2. Each node in the ring is connected with its k nearest neighbors (k-1 neighbors if k is odd)
      3. Shortcuts are created by replacing some edges as follows:
        • For each edge (u,v) in the underlying "n-ring with k nearest neighbors":
          • With probability p, add a new edge (u,w) with a uniformly random choice of existing node w
    • The resulting graphs are undirected
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • num_cn_nodes: Desired number of nodes in the contact network (n)
    • nws_k: Each node is connected to k nearest neighbors in ring topology
    • nws_prob: The probability of rewiring each edge (p)
  • Implements the ContactNetworkGenerator using the Powerlaw Cluster Graph model
    • The resulting graphs are undirected
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • num_cn_nodes: Desired number of nodes in the contact network (n)
    • pcg_m: The number of random edges to add for each new node (m)
    • pcg_p: The probability of adding a triangle after adding a random edge (p)
  • Implements the ContactNetworkGenerator using the Random Partition Graph
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • rpg_sizes: Sizes of groups (list of int)
    • rpg_p_in: Probability of edges within groups
    • rpg_p_out: Probability of edges between groups
    • d_or_u: "d" if you want directed edges, or "u" if you want undirected edges
  • Implements the ContactNetworkGenerator using the k-Regular Graph model
    • The resulting graphs are undirected
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • num_cn_nodes: Desired number of nodes in the contact network (n)
    • cn_degree: The desired degree of each node in the contact network (k)
  • Implements the ContactNetworkGenerator using the Watts-Strogatz (WS) model
    • The algorithm behind the WS model is as follows: a. Create a ring over n nodes b. Each node in the ring is connected with its k nearest neighbors (k-1 neighbors if k is odd) c. Shortcuts are created by replacing some edges as follows: * For each edge (u,v) in the underlying "n-ring with k nearest neighbors": * With probability p, replace it with a new edge (u,w) with a uniformly random choice of existing node w
    • The resulting graphs are undirected
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • num_cn_nodes: Desired number of nodes in the contact network (n)
    • ws_k: Each node is connected to k nearest neighbors in ring topology
    • ws_prob: The probability of rewiring each edge (p)
  • Implements the ContactNetworkGenerator using the Watts-Strogatz model, but guaranteed that the resulting graph is connected
    • The algorithm behind the WS model is as follows:
      1. Create a ring over n nodes
      2. Each node in the ring is connected with its k nearest neighbors (k-1 neighbors if k is odd)
      3. Shortcuts are created by replacing some edges as follows:
        • For each edge (u,v) in the underlying "n-ring with k nearest neighbors":
          • With probability p, add a new edge (u,w) with a uniformly random choice of existing node w
      4. The entire process is repeated until a connected graph results
    • The resulting graphs are undirected
  • The contact network that was generated is written to a file named contact_network.txt.gz in the user-specified output directory
  • Requirements:
  • Config Parameters:
    • num_cn_nodes: Desired number of nodes in the contact network (n)
    • wsc_k: Each node is connected to k nearest neighbors in ring topology
    • wsc_prob: The probability of rewiring each edge (p)
    • wsc_tries: The number of tries to generate the graph
Clone this wiki locally