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
//! This module contains various enums used for network classification.

/// `Model` decides the algorithm used to connect the nodes during `Network`'s
/// initialization.
#[derive(Debug, Clone)]
pub enum Model {
    /// The Erdos–Renyi random network model.
    ER {
        /// The probability of connecting any given pair of nodes.
        p: f64,
        /// Should the network be in one piece
        whole: bool,
    },
    /// The Barabasi–Albert preferential attachment model.
    BA {
        /// The initial number of clustered nodes.
        m0: usize,
        /// The number of nodes added in each step during network creation.
        /// Keep in mind that this should be strictly less or equal m0 and the Barabasi-Albert
        /// initialization fuction **will panic** if this is not the case.
        m: usize,
    },
    /// Placeholder for a network with no connections.
    None,
}

/// `Weight` determines the weight of each link in the network (ie. the probability of the
/// infection spreading through it in each time step).
#[derive(Debug, Clone)]
pub enum Weight {
    /// The probability should be constant end equalt to `c`. Keep in mind that 0 < c <= 1, the
    /// `Network::new()` constructor **will panic** if that is not the case.
    Constant { c: f64 },
    /// A weight sampled uniformly from (0, 1).
    Uniform,
}

/// `Error` is used to signify a recoverable error.
#[derive(Debug, PartialEq)]
pub enum Error {
    NoSuchNode { idx: usize },
    BadWeight { weight: f64 },
}