code: def strategy_smallest_last(G, colors):
      """Returns a deque of the nodes of ``G``, "smallest" last.
  
      Specifically, the degrees of each node are tracked in a bucket queue.
      From this, the node of minimum degree is repeatedly popped from the
      graph, updating its neighbors' degrees.
  
      ``G`` is a NetworkX graph. ``colors`` is ignored.
  
      This implementation of the strategy runs in $O(n + m)$ time
      (ignoring polylogarithmic factors), where $n$ is the number of nodes
      and $m$ is the number of edges.
  
      This strategy is related to :func:`strategy_independent_set`: if we
      interpret each node removed as an independent set of size one, then
      this strategy chooses an independent set of size one instead of a
      maximal independent set.
  
      """
      H = G.copy()
      result = deque()
  
      # Build initial degree list (i.e. the bucket queue data structure)
      degrees = defaultdict(
          set
      )  # set(), for fast random-access removals
      lbound = float("inf")
      for node, d in H.degree():
          degrees[d].add(node)
          lbound = min(lbound, d)  # Lower bound on min-degree.
  
      def find_min_degree():
          # Save time by starting the iterator at `lbound`, not 0.
          # The value that we find will be our new `lbound`, which we set later.
          return next(
              d for d in itertools.count(lbound) if d in degrees
          )
  
      for _ in G:
          # Pop a min-degree node and add it to the list.
          min_degree = find_min_degree()
          u = degrees[min_degree].pop()
          if not degrees[min_degree]:  # Clean up the degree list.
              del degrees[min_degree]
          result.appendleft(u)
  
          # Update degrees of removed node's neighbors.
          for v in H[u]:
              degree = H.degree(v)
              degrees[degree].remove(v)
              if not degrees[degree]:  # Clean up the degree list.
                  del degrees[degree]
              degrees[degree - 1].add(v)
  
          # Finally, remove the node.
          H.remove_node(u)
          lbound = (
              min_degree - 1
          )  # Subtract 1 in case of tied neighbors.
  
      return result
  
imports: import itertools
  from collections import defaultdict, deque
  import networkx
  from networkx.utils import arbitrary_element, py_random_state
label_desc: Use image node_id 3 for calling a global function with example usage: strategy_smallest_last(G, colors) and returns: result, next