1use std::fmt;
2use std::fmt::{Formatter};
3
4pub struct Edge {
5 from: String,
6 to: String,
7 style: Vec<String>,
8}
9
10impl Edge {
11 pub fn new(from: String, to: String) -> Self {
12 Edge { from, to, style: vec![] }
13 }
14 pub fn styled(from: String, to: String, style: Vec<String>) -> Self {
15 Edge { from, to, style }
16 }
17}
18
19impl fmt::Display for Edge {
20 fn fmt(&self, out: &mut Formatter<'_>) -> fmt::Result {
21 if self.style.len() > 0 {
22 out.write_str(&format!("{} -> {} [{}];", self.from, self.to, self.style.join(",")))
23 } else {
24 out.write_str(&format!("{} -> {};", self.from, self.to))
25 }
26 }
27}