def get_topological_sorted_tasks(self):
""" Create the tasks Graph and perform topological sorting
A topological sort is a nonunique permutation of the nodes
such that an edge from u to v implies that u appears before
v in the topological sort order.
:return: Return a list of nodes in topological sort order.
"""
# First, map the tasks IDs to their original position
tasks_position = {}
for count_position, task in enumerate(self.workflow['tasks']):
tasks_position[task['id']] = count_position
sorted_tasks_id = nx.topological_sort(self.graph, reverse=False)
return sorted_tasks_id
评论列表
文章目录