| Conditions | 5 |
| Total Lines | 11 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | from collections.abc import Iterable, Mapping |
||
| 18 | def edges_iter(adjacency_source: Union[str, Mapping[int, list[int]]]) -> Iterable[tuple[int, int]]: |
||
| 19 | if isinstance(adjacency_source, str): |
||
| 20 | adjacency_list = parse(adjacency_source) |
||
| 21 | elif isinstance(adjacency_source, Mapping): |
||
| 22 | adjacency_list = adjacency_source.items() |
||
| 23 | else: |
||
| 24 | raise TypeError("'adjacency_source' should be a 'str' or a Mapping[int, list[int]]") |
||
| 25 | |||
| 26 | for s, tl in adjacency_list: |
||
| 27 | for t in tl: |
||
| 28 | yield int(s), int(t) |
||
| 29 | |||
| 59 |