Generating networks

Generating networks in CiGRAM is straightforward.

from cigram import generate_graph
n = 1000
avg_k = 4.95
k = 1
graph, positions, communities = cigram_graph(n, avg_k, k)

Here n is the number of nodes, avg_k is the desired average degree and k is the number of communities. Note that the number of communities here is fixed at 1, so the graph will not generate artificial clusters.

The resulting returned tuple of graph, positions and communities is a networkx graph object, a dictionary of points upon a unit circle for each node, and a dictionary for the community membership of each vertex.

More complex parameters allow you to generate different heterogenous degree distributions. This is controlled by the parameters sigma_f and sigma_r which have an effect on the underlying probability space for the connections between nodes.

sigma_r = 0.8
sigma_f = 0.8
graph, positions, communities = cigram_graph(n, avg_k, k)

To generate networks with assortativity this can be specified with the parameter a (by default this is 0).

LFR Benchmarks

CiGRAM also includes the generation of Lancichinetti–Fortunato–Radicchi (LFR) benchamrks. This was implemented due to issues found with the python implementation in NetworkX. This version is mostly a tidied up version of the original C++ code. To use:

from cigram import lfr_benchmark_graph

params = {
    'n': 10000,
    'average_degree': 10,
    'max_degree': 1000,
    'mu': 0.5,
    'tau': 2.0,
    'tau2': 2.0,
    'minc_size': 3,
    'maxc_size': 1000,
    'overlapping_nodes': 0,
    'overlapping_memberships': 1,
    'seed': 1337
}

graph, comms = lfr_benchmark_graph(**params)