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: Initialize the iterator
  
  Parameters
  ----------
  G : nx.DiGraph
      The directed graph which we need to iterate trees over
  
  weight : String, default = "weight"
      The edge attribute used to store the weight of the edge
  
  minimum : bool, default = True
      Return the trees in increasing order while true and decreasing order
      while false.
  
  init_partition : tuple, default = None
      In the case that certain edges have to be included or excluded from
      the arborescences, `init_partition` should be in the form
      `(included_edges, excluded_edges)` where each edges is a
      `(u, v)`-tuple inside an iterable such as a list or set.
code: def __init__(
      self, G, weight="weight", minimum=True, init_partition=None
  ):
      """
      Initialize the iterator
  
      Parameters
      ----------
      G : nx.DiGraph
          The directed graph which we need to iterate trees over
  
      weight : String, default = "weight"
          The edge attribute used to store the weight of the edge
  
      minimum : bool, default = True
          Return the trees in increasing order while true and decreasing order
          while false.
  
      init_partition : tuple, default = None
          In the case that certain edges have to be included or excluded from
          the arborescences, `init_partition` should be in the form
          `(included_edges, excluded_edges)` where each edges is a
          `(u, v)`-tuple inside an iterable such as a list or set.
  
      """
      self.G = G.copy()
      self.weight = weight
      self.minimum = minimum
      self.method = (
          minimum_spanning_arborescence
          if minimum
          else maximum_spanning_arborescence
      )
      # Randomly create a key for an edge attribute to hold the partition data
      self.partition_key = (
          "ArborescenceIterators super secret partition attribute name"
      )
      if init_partition is not None:
          partition_dict = {}
          for e in init_partition[0]:
              partition_dict[e] = nx.EdgePartition.INCLUDED
          for e in init_partition[1]:
              partition_dict[e] = nx.EdgePartition.EXCLUDED
          self.init_partition = ArborescenceIterator.Partition(
              0, partition_dict
          )
      else:
          self.init_partition = None
  
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 1 to create a new ArborescenceIterator object  with example: obj = ArborescenceIterator(G, weight, minimum, init_partition)