1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
8pub struct Link {
9 pub index: u32,
10 pub source: u32,
11 pub target: u32,
12}
13
14impl Link {
15 pub fn new(index: u32, source: u32, target: u32) -> Self {
17 Self {
18 index,
19 source,
20 target,
21 }
22 }
23
24 pub fn is_null(&self) -> bool {
26 self.index == 0 && self.source == 0 && self.target == 0
27 }
28
29 pub fn is_full_point(&self) -> bool {
31 self.index == self.source && self.source == self.target
32 }
33
34 pub fn is_partial_point(&self) -> bool {
36 self.index == self.source || self.index == self.target
37 }
38
39 pub fn format(&self) -> String {
41 format!("({} {} {})", self.index, self.source, self.target)
42 }
43}
44
45pub type DoubletsLink = doublets::Link<u32>;
47
48impl From<DoubletsLink> for Link {
49 fn from(link: DoubletsLink) -> Self {
50 Self::new(link.index, link.source, link.target)
51 }
52}
53
54impl From<Link> for DoubletsLink {
55 fn from(link: Link) -> Self {
56 Self::new(link.index, link.source, link.target)
57 }
58}