class_docstr: Iterate over all spanning arborescences of a graph in either increasing or
  decreasing cost.
  
  Notes
  -----
  This iterator uses the partition scheme from [1]_ (included edges,
  excluded edges and open edges). It generates minimum spanning
  arborescences using a modified Edmonds' Algorithm which respects the
  partition of edges. For arborescences with the same weight, ties are
  broken arbitrarily.
  
  References
  ----------
  .. [1] G.K. Janssens, K. Sörensen, An algorithm to generate all spanning
         trees in order of increasing cost, Pesquisa Operacional, 2005-08,
         Vol. 25 (2), p. 219-229,
         https://www.scielo.br/j/pope/a/XHswBwRwJyrfL88dmMwYNWp/?lang=en
docstr: Writes the desired partition into the graph to calculate the minimum
  spanning tree. Also, if one incoming edge is included, mark all others
  as excluded so that if that vertex is merged during Edmonds' algorithm
  we cannot still pick another of that vertex's included edges.
  
  Parameters
  ----------
  partition : Partition
      A Partition dataclass describing a partition on the edges of the
      graph.
code: def _write_partition(self, partition):
      """
      Writes the desired partition into the graph to calculate the minimum
      spanning tree. Also, if one incoming edge is included, mark all others
      as excluded so that if that vertex is merged during Edmonds' algorithm
      we cannot still pick another of that vertex's included edges.
  
      Parameters
      ----------
      partition : Partition
          A Partition dataclass describing a partition on the edges of the
          graph.
      """
      for u, v, d in self.G.edges(data=True):
          if (u, v) in partition.partition_dict:
              d[self.partition_key] = partition.partition_dict[(u, v)]
          else:
              d[self.partition_key] = nx.EdgePartition.OPEN
  
      for n in self.G:
          included_count = 0
          excluded_count = 0
          for u, v, d in self.G.in_edges(nbunch=n, data=True):
              if d.get(self.partition_key) == nx.EdgePartition.INCLUDED:
                  included_count += 1
              elif (
                  d.get(self.partition_key) == nx.EdgePartition.EXCLUDED
              ):
                  excluded_count += 1
          # Check that if there is an included edges, all other incoming ones
          # are excluded. If not fix it!
          if (
              included_count == 1
              and excluded_count != self.G.in_degree(n) - 1
          ):
              for u, v, d in self.G.in_edges(nbunch=n, data=True):
                  if (
                      d.get(self.partition_key)
                      != nx.EdgePartition.INCLUDED
                  ):
                      d[self.partition_key] = nx.EdgePartition.EXCLUDED
  
imports: import string
  from dataclasses import dataclass, field
  from enum import Enum
  from operator import itemgetter
  from queue import PriorityQueue
  import networkx
  from networkx.utils import py_random_state
  from .recognition import is_arborescence, is_branching
label_desc: Use image node_id 5 for calling the ArborescenceIterator obj's underlying member method code with example usage: obj._write_partition(partition) without return types