1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! Provides functionality for generating graphs for testing and benchmarking.
//! Allows us to generate graphs using the preferential attachment model and
//! the random attachment model.
use crate::;
use *;
/// 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.
///
/// Arguments:
/// g: The graph you wish to add nodes and edges to
/// nodes_to_add: The amount of nodes you wish to add to the graph (steps)
/// edges_per_step: The amount of edges a joining node should add to the graph
/// seed: The seed used in rng, an array of length 32 containing ints (ints must have a max size of u8)
///
/// Returns:
/// 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.
///
/// Arguments:
/// g: The graph you wish to add nodes and edges to
/// nodes_to_add: The amount of nodes you wish to add to the graph (steps)
/// edges_per_step: The amount of edges a joining node should add to the graph
/// seed: The seed used in rng, an array of length 32 containing ints (ints must have a max size of u8)
///
/// Returns:
///
/// None
]