class_docstr: Iterate over all spanning trees 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) as well as a modified Kruskal's Algorithm
  to generate minimum spanning trees which respect the partition of edges.
  For spanning trees 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
class_docstr_tok: ["Iterate","over","all","spanning","trees","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",")","as","well","as","a","modified","Kruskal","'s","Algorithm","to","generate","minimum","spanning","trees","which","respect","the","partition","of","edges",".","For","spanning","trees","with","the","same","weight",",","ties","are","broken","arbitrarily",".","References","--","--","--","--","--","..","[","1","]","G.K.","Janssens",",","K.","S\u00f6rensen",",","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.Graph
      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.
  
  ignore_nan : bool, default = False
      If a NaN is found as an edge weight normally an exception is raised.
      If `ignore_nan is True` then that edge is ignored instead.
docstr_tok: ["Initialize","the","iterator","Parameters","--","--","--","--","--","G",":","nx.Graph","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",".","ignore_nan",":","bool",",","default","=","False","If","a","NaN","is","found","as","an","edge","weight","normally","an","exception","is","raised",".","If","`","ignore_nan","is","True","`","then","that","edge","is","ignored","instead","."]
code: def __init__(
      self, G, weight="weight", minimum=True, ignore_nan=False
  ):
      """
      Initialize the iterator
  
      Parameters
      ----------
      G : nx.Graph
          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.
  
      ignore_nan : bool, default = False
          If a NaN is found as an edge weight normally an exception is raised.
          If `ignore_nan is True` then that edge is ignored instead.
      """
      self.G = G.copy()
      self.weight = weight
      self.minimum = minimum
      self.ignore_nan = ignore_nan
      # Randomly create a key for an edge attribute to hold the partition data
      self.partition_key = (
          "SpanningTreeIterators super secret partition attribute name"
      )
  
imports: from dataclasses import dataclass, field
  from enum import Enum
  from heapq import heappop, heappush
  from itertools import count
  from math import isnan
  from operator import itemgetter
  from queue import PriorityQueue
  import networkx
  from networkx.utils import UnionFind, not_implemented_for, py_random_state
label_desc: Use image node_id 1 to create a new SpanningTreeIterator object  with example: obj = SpanningTreeIterator(G, weight, minimum, ignore_nan)