Returns a topological ordering of the DAG.

        Returns:
            list: A list of topologically sorted nodes in the graph.

        Raises:
            ValueError: Raised if the graph is not acyclic.

def topological_sort(self):
        """ Returns a topological ordering of the DAG.

        Returns:
            list: A list of topologically sorted nodes in the graph.

        Raises:
            ValueError: Raised if the graph is not acyclic.
        """
        graph = self.graph

        in_degree = {}
        for u in graph:
            in_degree[u] = 0

        for u in graph:
            for v in graph[u]:
                in_degree[v] += 1

        queue = deque()
        for u in in_degree:
            if in_degree[u] == 0:
                queue.appendleft(u)

        sorted_graph = []
        while queue:
            u = queue.pop()
            sorted_graph.append(u)
            for v in sorted(graph[u]):
                in_degree[v] -= 1
                if in_degree[v] == 0:
                    queue.appendleft(v)

        if len(sorted_graph) == len(graph):
            return sorted_graph
        else:
            raise ValueError('graph is not acyclic')