algorithms

algorithms.py

Purpose: Algorithms used to simulate graph structues using Graph Motif Models

Author: Drew Conway Email: drew.conway@nyu.edu

gmm.algorithms.simulate(gmm, tau, poisson=True, new_name='GMM Simulation')

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

motifs for the simulation.

Returns :

gmm_sim : A NetworkX graph object derived from a graph motif model simualtion on a

given gmm object.

gmm.algorithms.draw_structure(motif_mass)

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

by the gmm_simulate function.

Returns :

motif : A randomly drawn graph motif, as a NetworkX graph object

gmm.algorithms.motif_counts(gmm, tau)

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

largest graph in set of graph motifs used in the given model.

Returns :

subgraph_counts : A list of tuples with the following construction (index,motif,count), where

“count” is the number of subgraph isomorphisms for the given motif counted in the base structure of the given GMM object and index is the motif index.

gmm.algorithms.get_motifs(tau, directed_motifs)
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

largest graph in set of graph motifs used in the given model.

directed_motifs : A boolean designating whether the motifs should be directed.

Returns :

motifs : A list of tuples of the following construction (index,motif,0). The final zero is used as

is a placeholder and will set the counts of subgraph isomorphism for each motif in the GMM’s base structure.

gmm.algorithms.all_graphs(num_nodes, directed_motifs)

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

gmm.algorithms.poisson_mass(motif_counts)

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

mass function as values given the lambda estimate from the motif_counts.

Notes

There are two critical assumption inherent to using the Poisson fit method for estimating:

  • Graphs can be ordered by complexity. This is tacitly implied in the model, but when using

the Poisson fit to estimate mass for all motifs it is explicit.

  • Perhaps more importantly, motif counts are distributed Possion

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.

Previous topic

Graph Motif Model (gmm)

This Page