Skip to content

graph_gen #

Generate Raphtory graphs from attachment models

Functions#

random_attachment(g, nodes_to_add, edges_per_step, seed=None) #

Generates a graph using the random attachment model

This function is a graph generation model based upon: Callaway, Duncan S., et al. "Are randomly grown graphs really random?." Physical Review E 64.4 (2001): 041902.

Parameters:

Name Type Description Default
g Any

The graph you wish to add nodes and edges to

required
nodes_to_add Any

The amount of nodes you wish to add to the graph (steps)

required
edges_per_step Any

The amount of edges a joining node should add to the graph

required
seed Any

The seed used in rng, an array of length 32 containing ints (ints must have a max size of u8)

None

Returns:

Type Description

None

ba_preferential_attachment(g, nodes_to_add, edges_per_step, seed=None) #

Generates a graph using the preferential attachment model.

Given a graph this function will add a user defined number of nodes, each with a user defined number of edges. This is an iterative algorithm where at each step a node is added and its neighbours are chosen from the pool of nodes already within the network. For this model the neighbours are chosen proportionally based upon their degree, favouring nodes with higher degree (more connections). This sampling is conducted without replacement.

Note: If the provided graph doesnt have enough nodes/edges for the initial sample, the min number of both will be added before generation begins.

Parameters:

Name Type Description Default
g Any

The graph you wish to add nodes and edges to

required
nodes_to_add Any

The amount of nodes you wish to add to the graph (steps)

required
edges_per_step Any

The amount of edges a joining node should add to the graph

required
seed Any

The seed used in rng, an array of length 32 containing ints (ints must have a max size of u8)

None

Returns:

None