code: def node_rank(self):
          
          nodes = self.postorder()
          node_rank = {}
          for node in nodes:
              max_rank = 0
              for child in self[node].nodes():
                  some_rank = node_rank[child] + 1
                  max_rank = max(max_rank, some_rank)
              node_rank[node] = max_rank
          return node_rank
docs: Returns the maximum rank for each **topological node** in the 
          ``DictGraph``. The rank of a node is defined as the number of edges 
          between the node and a node which has rank 0. A **topological node** 
          has rank 0 if it has no incoming edges.