Computes the parents for each vertex as determined through depth-first-search (though not too meaningful in an undirected weightless graph) :return: parents for each vertex :rtype: dict
(self)
| 41 | yield i |
| 42 | |
| 43 | def dfs_recursive(self): |
| 44 | """ |
| 45 | Computes the parents for each vertex as determined through depth-first-search |
| 46 | (though not too meaningful in an undirected weightless graph) |
| 47 | :return: parents for each vertex |
| 48 | :rtype: dict |
| 49 | """ |
| 50 | parents = {} |
| 51 | |
| 52 | self.dfs_util(0, parents) |
| 53 | |
| 54 | return parents |
| 55 | |
| 56 | def dfs_util(self, vertex, parents): |
| 57 | for u in self.get_neighbor(vertex): |