algorithms.py
Purpose: Algorithms used to simulate graph structues using Graph Motif Models
Author: Drew Conway Email: drew.conway@nyu.edu
The primary function for generating networks using the graph motif modeling technique. The function takes two arguments, a gmm object and a tau value, and returns a NetworkX graph object based on the construct of the gmm passed.
Parameters : | gmm : A graph motif model object. tau : An number greater than or equal to two, which is used to generate a set of graph
poisson : A boolean value to declarse whether to use a Poisson probability mass when
seed : int or array_like value to set the random seed for NumPy RandomState new_name : A string, the name the new graph generated by the simulation |
---|---|
Returns : | gmm_sim : A NetworkX graph object derived from a graph motif model simualtion on a
|
Take a list of tuples of the construct (index,motif,probability mass) and takes a random draw of a motif based on the probability masses.
Parameters : | motf_mass : A list of tuples of the constructure (index,motif,probability mass), likely constructred
|
---|---|
Returns : | motif : A randomly drawn graph motif, as a NetworkX graph object |
Returns dictionary keyed by graph motifs and values as the number of subgraph isomorphisms for the given motif counted in the base structure of the given GMM object.
Parameters : | gmm : A graph motif model object. tau : An integer greater than or equal to 2, which designates the number of nodes in the
|
---|---|
Returns : | subgraph_counts : A list of tuples with the following construction (index,motif,count), where
|
Returns a list of tupples of all possible single component non-singleton subgraphs from a dyad to $G={V=tau,E=
rac{tau(tau-1)}{2}}$, i.e. the K_{tau} complete graph.
The list represents the set of graph moitifs used in a given model. This function is primarily meant as a helper to motif_counts, but can be used for other user purposes.
Parameters : | tau : An integer greater than or equal to 2, which designates the number of nodes in the
|
---|---|
Returns : | motifs : A list of tuples of the following construction (index,motif,0). The final zero is used as
|
Retuns a list of all possible single component graphs given some number of nodes. This function is meant primarily as a helper function to get_subgraphs, but can be used for other user purposes.
Parameters : | num_nodes : The number of nodes in the complete graph directed_motifs : A boolean designating whether the motifs should be directed. |
---|---|
Returns : | graphs : A list of all possible single component graphs given some number of nodes |
Will calculate a shape parameter (lambda) for a Possion distribution given some motif counts.
Parameters : | motif_counts : A dictionary of motif counts keyed by (order, motif) tuples with count values. |
---|---|
Returns : | motif_pmf : A dictionary of motif counts keyed by (order, motif) tuples with Poisson probability
|
Notes
There are two critical assumption inherent to using the Poisson fit method for estimating:
the Poisson fit to estimate mass for all motifs it is explicit.
In this case the most basic motif, the dyad, maps to k=0, and the assumed k value increases as both node and edge complexity increase in motifs.
The primary advantage of this method is to assure that there is some positive probability mass for every motif in the model. In some cases a motif may have a zero probability given some base structure. This method will prevent that outcome.