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: Create new partitions based of the minimum spanning tree of the
  current minimum partition.
  
  Parameters
  ----------
  partition : Partition
      The Partition instance used to generate the current minimum spanning
      tree.
  partition_tree : nx.Graph
      The minimum spanning tree of the input partition.
docstr_tok: ["Create","new","partitions","based","of","the","minimum","spanning","tree","of","the","current","minimum","partition",".","Parameters","--","--","--","--","--","partition",":","Partition","The","Partition","instance","used","to","generate","the","current","minimum","spanning","tree",".","partition_tree",":","nx.Graph","The","minimum","spanning","tree","of","the","input","partition","."]
code: def _partition(self, partition, partition_tree):
      """
      Create new partitions based of the minimum spanning tree of the
      current minimum partition.
  
      Parameters
      ----------
      partition : Partition
          The Partition instance used to generate the current minimum spanning
          tree.
      partition_tree : nx.Graph
          The minimum spanning tree of the input partition.
      """
      # create two new partitions with the data from the input partition dict
      p1 = self.Partition(0, partition.partition_dict.copy())
      p2 = self.Partition(0, partition.partition_dict.copy())
      for e in partition_tree.edges:
          # determine if the edge was open or included
          if e not in partition.partition_dict:
              # This is an open edge
              p1.partition_dict[e] = EdgePartition.EXCLUDED
              p2.partition_dict[e] = EdgePartition.INCLUDED
  
              self._write_partition(p1)
              p1_mst = partition_spanning_tree(
                  self.G,
                  self.minimum,
                  self.weight,
                  self.partition_key,
                  self.ignore_nan,
              )
              p1_mst_weight = p1_mst.size(weight=self.weight)
              if nx.is_connected(p1_mst):
                  p1.mst_weight = (
                      p1_mst_weight if self.minimum else -p1_mst_weight
                  )
                  self.partition_queue.put(p1.__copy__())
              p1.partition_dict = p2.partition_dict.copy()
  
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 4 for calling the SpanningTreeIterator obj's underlying member method code with example usage: obj._partition(partition, partition_tree) without return types