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
extern crate uuid;
use uuid::Uuid;
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
pub struct Edge {
pub src: Uuid,
pub dst: Uuid,
pub innov: Uuid,
pub weight: f32,
pub active: bool
}
impl Edge {
pub fn new(src: Uuid, dst: Uuid, innov: Uuid, weight: f32, active: bool) -> Self {
Edge {
src,
dst,
innov,
weight,
active
}
}
#[inline]
pub fn update(&mut self, delta: f32) {
self.weight += delta;
}
#[inline]
pub fn calculate(&mut self, val: f32) -> f32 {
val * self.weight
}
}