Return an adjacency dictionary representation of the graph
(self)
| 96 | return adj_mat |
| 97 | |
| 98 | def to_adj_dict(self): |
| 99 | """Return an adjacency dictionary representation of the graph""" |
| 100 | adj_dict = defaultdict(lambda: list()) |
| 101 | for e in self.edges: |
| 102 | adj_dict[e.fr].append(e) |
| 103 | return adj_dict |
| 104 | |
| 105 | def path_exists(self, s_i, e_i): |
| 106 | """ |