old_contents: import itertools
  
  import networkx as nx
  
  from .simple import primitive_run
  
  
  class MixInParallelRunner(object):
  
      def run_parent(self, task):
          self.create_graph(task)
          self.submit_tasks()
          self.wait_tasks()
  
      def create_graph(self, task):
          self.graph = graph = nx.DiGraph()
          self.nodetaskmap = nodetaskmap = {}
          counter = itertools.count().next
          self.root = root = counter()
  
          def creator(i, t):
              nodetaskmap[i] = t
              for p in t.get_parents():
                  k = counter()
                  graph.add_node(k)
                  graph.add_edge(i, k)
                  creator(k, p)
  
          creator(root, task)
  
      def sorted_nodes(self):
          return nx.topological_sort(self.graph)
  
      def submit_tasks(self):
          """
          Submit tasks using the :attr:`graph` generated by :meth:`create_graph`.
          """
          self.results = results = {}
          for node in self.sorted_nodes():
              deps = [results[n] for n in self.graph.predecessors(node)]
              results[node] = self.apply_async(self.nodetaskmap[node], deps)
  
      def apply_async(self, task, deps):
          raise NotImplementedError
  
      def wait_tasks(self):
          raise NotImplementedError
  
      @property
      def run_func(self):
          return run_task_load_parents
  
  
  def run_task_load_parents(task):
      primitive_run(task, load_parents)
  
  
  def load_parents(task):
      for parent in task.get_parents():
          parent.load()
  
new_contents: import itertools
  
  import networkx as nx
  
  from .simple import primitive_run
  
  
  class MixInParallelRunner(object):
  
      def run_parent(self, task):
          self.create_graph(task)
          self.submit_tasks()
          self.wait_tasks()
  
      def create_graph(self, task):
          self.graph = graph = nx.DiGraph()
          self.nodetaskmap = nodetaskmap = {}
          counter = itertools.count().next
          self.root = root = counter()
  
          def creator(i, t):
              nodetaskmap[i] = t
              for p in t.get_parents():
                  k = counter()
                  graph.add_node(k)
                  graph.add_edge(k, i)
                  creator(k, p)
  
          creator(root, task)
  
      def sorted_nodes(self):
          return nx.topological_sort(self.graph)
  
      def submit_tasks(self):
          """
          Submit tasks using the :attr:`graph` generated by :meth:`create_graph`.
          """
          self.results = results = {}
          for node in self.sorted_nodes():
              deps = [results[n] for n in self.graph.predecessors(node)]
              results[node] = self.apply_async(self.nodetaskmap[node], deps)
  
      def apply_async(self, task, deps):
          raise NotImplementedError
  
      def wait_tasks(self):
          raise NotImplementedError
  
      @property
      def run_func(self):
          return run_task_load_parents
  
  
  def run_task_load_parents(task):
      primitive_run(task, load_parents)
  
  
  def load_parents(task):
      for parent in task.get_parents():
          parent.load()
  
subject: Fix add_edge in MixInParallelRunner.create_graph