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: Returns
  -------
  (multi)Graph
      The spanning tree of next greatest weight, which ties broken
      arbitrarily.
docstr_tok: ["Returns","--","--","--","-","(","multi",")","Graph","The","spanning","tree","of","next","greatest","weight",",","which","ties","broken","arbitrarily","."]
code: def __next__(self):
      """
      Returns
      -------
      (multi)Graph
          The spanning tree of next greatest weight, which ties broken
          arbitrarily.
      """
      if self.partition_queue.empty():
          del self.G, self.partition_queue
          raise StopIteration
  
      partition = self.partition_queue.get()
      self._write_partition(partition)
      next_tree = partition_spanning_tree(
          self.G,
          self.minimum,
          self.weight,
          self.partition_key,
          self.ignore_nan,
      )
      self._partition(partition, next_tree)
  
      self._clear_partition(next_tree)
      return next_tree
  
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 3 for calling the SpanningTreeIterator obj's underlying member method code with example usage: obj.__next__() and returns: next_tree