code: def stubs_clustering(network,use_reduced_coordinates=True, line_length_factor=1.0):
      
  
      busmap = busmap_by_stubs(network)
  
      #reset coordinates to the new reduced guys, rather than taking an average
      if use_reduced_coordinates:
          # TODO : FIX THIS HACK THAT HAS UNEXPECTED SIDE-EFFECTS,
          # i.e. network is changed in place!!
          network.buses.loc[busmap.index,['x','y']] = network.buses.loc[busmap,['x','y']].values
  
      return get_clustering_from_busmap(network, busmap, line_length_factor=line_length_factor)
docs: Cluster network by reducing stubs and stubby trees
      (i.e. sequentially reducing dead-ends).
  
      Parameters
      ----------
      network : pypsa.Network
      use_reduced_coordinates : boolean
          If True, do not average clusters, but take from busmap.
      line_length_factor : float
          Factor to multiply the crow-flies distance between new buses in order to get new
          line lengths.
  
      Returns
      -------
      Clustering : named tuple
          A named tuple containing network, busmap and linemap