import collections


def GenerateDependentSetPerTask(scenario):
  """Maps direct dependents per tasks of scenario.

  Args:
    scenario: The scenario containing the Tasks to map.

  Returns:
    {Task: set(Task)}
  """
  task_set = set(scenario)
  task_children = collections.defaultdict(set)
  for task in scenario:
    for parent in task._dependencies:
      if parent in task_set:
        task_children[parent].add(task)
  return task_children