(self, u, v, w=1)
| 269 | # adding the weight is optional |
| 270 | # handles repetition |
| 271 | def add_pair(self, u, v, w=1): |
| 272 | # check if the u exists |
| 273 | if self.graph.get(u): |
| 274 | # if there already is a edge |
| 275 | if self.graph[u].count([w, v]) == 0: |
| 276 | self.graph[u].append([w, v]) |
| 277 | else: |
| 278 | # if u does not exist |
| 279 | self.graph[u] = [[w, v]] |
| 280 | # add the other way |
| 281 | if self.graph.get(v): |
| 282 | # if there already is a edge |
| 283 | if self.graph[v].count([w, u]) == 0: |
| 284 | self.graph[v].append([w, u]) |
| 285 | else: |
| 286 | # if u does not exist |
| 287 | self.graph[v] = [[w, u]] |
| 288 | |
| 289 | # handles if the input does not exist |
| 290 | def remove_pair(self, u, v): |
no test coverage detected