network_flow/graph/edge/
mod.rs1#[derive(Debug)]
7pub struct Edge<T, E> {
8 pub(crate) from : usize,
9 pub(crate) to : usize,
10 pub(crate) next_edge : usize,
11 pub(crate) opp_edge : usize,
12 pub(crate) weight : T,
13 pub(crate) cost : E,
14 pub(crate) reversed : bool
15}
16
17impl<T, E> Edge<T, E>
18 where
19 T : Default,
20 E : Default{
21 pub(crate) fn empty_edge(i : usize) -> Edge<T, E> {
22 Edge::<T, E> {
23 from : i,
24 to : i,
25 next_edge : usize::MAX,
26 opp_edge : usize::MAX,
27 weight : T::default(),
28 cost : E::default(),
29 reversed : false
30 }
31 }
32
33 pub(crate) fn create_edge(from : usize, to : usize, next_edge : usize, opp_edge : usize,
34 weight : T, cost : E) -> Edge<T, E> {
35 Edge::<T, E> {
36 from, to, next_edge, opp_edge, weight, cost, reversed : false
37 }
38 }
39
40 pub fn is_reversed(&self) -> bool {
41 self.reversed
42 }
43
44 pub fn get_to(&self) -> usize {
45 self.to
46 }
47}
48impl <T : Default + PartialEq, E> Edge<T, E> {
49 pub fn is_full(&self) -> bool {
50 self.weight == T::default()
51 }
52}