添加边
(&mut self, from: &T, to: &T, wt: u32)
| 116 | |
| 117 | // 添加边 |
| 118 | fn add_edge(&mut self, from: &T, to: &T, wt: u32) { |
| 119 | // 点不存在需要先添加 |
| 120 | if !self.contains(from) { |
| 121 | let _fvert = self.add_vertex(from); |
| 122 | } |
| 123 | if !self.contains(to) { |
| 124 | let _tvert = self.add_vertex(to); |
| 125 | } |
| 126 | |
| 127 | self.edgenums += 1; |
| 128 | self.vertices |
| 129 | .get_mut(from) |
| 130 | .unwrap() |
| 131 | .add_neighbor(to.clone(), wt); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | // 根据单词及模式构建图 |
no test coverage detected