def topological_order(self):
        """Return the topological order of the node IDs from the input node to the output node."""
        q = Queue()
        in_degree = {}
        for i in range(self.n_nodes):
            in_degree[i] = 0
        for u in range(self.n_nodes):
            for v, _ in self.adj_list[u]:
                in_degree[v] += 1
        for i in range(self.n_nodes):
            if in_degree[i] == 0:
                q.put(i)

        order_list = []
        while not q.empty():
            u = q.get()
            order_list.append(u)
            for v, _ in self.adj_list[u]:
                in_degree[v] -= 1
                if in_degree[v] == 0:
                    q.put(v)
        return order_list
def topological_order ( self ) : q = Queue ( ) in_degree = { } for i in range ( self . n_nodes ) : in_degree [ i ] = 0 for u in range ( self . n_nodes ) : for v , _ in self . adj_list [ u ] : in_degree [ v ] += 1 for i in range ( self . n_nodes ) : if in_degree [ i ] == 0 : q . put ( i ) order_list = [ ] while not q . empty ( ) : u = q . get ( ) order_list . append ( u ) for v , _ in self . adj_list [ u ] : in_degree [ v ] -= 1 if in_degree [ v ] == 0 : q . put ( v ) return order_list
Return the topological order of the node IDs from the input node to the output node.