code: def transitively_reduce(self):
          
          removals = set()
  
          for from_node, neighbors in self._edges.items():
              childpairs = \
                  [(c1, c2) for c1 in neighbors for c2 in neighbors if c1 != c2]
  
              for child1, child2 in childpairs:
                  if self.has_path(child1, child2) \
                     and not self.has_path(child1, from_node):
                      removals.add((from_node, child2))
  
          for edge in removals:
              self.remove_edge(edge[0], edge[1])
docs: Performs a transitive reduction on the graph.