Return an adjacency matrix representation of the graph
(self)
| 88 | return [self._V2I[e.to] for e in self._G[v_i]] |
| 89 | |
| 90 | def to_matrix(self): |
| 91 | """Return an adjacency matrix representation of the graph""" |
| 92 | adj_mat = np.zeros((len(self._V), len(self._V))) |
| 93 | for e in self.edges: |
| 94 | fr, to = self._V2I[e.fr], self._V2I[e.to] |
| 95 | adj_mat[fr, to] = 1 if e.weight is None else e.weight |
| 96 | return adj_mat |
| 97 | |
| 98 | def to_adj_dict(self): |
| 99 | """Return an adjacency dictionary representation of the graph""" |
nothing calls this directly
no outgoing calls
no test coverage detected