code: def ward_quick_segment(G, feature, stop=-1, qmax=1, verbose=False):
      """
      Agglomerative function based on a topology-defining graph
      and a feature matrix.
  
      Parameters
      ----------
      G: labs.graph.WeightedGraph instance
         the input graph (a topological graph essentially)
      feature array of shape (G.V,dim_feature)
          vectorial information related to the graph vertices
      stop1 : int or float, optional
          the stopping crterion if stop==-1, then no stopping criterion is used
      qmax : int, optional
          the maximum number of desired clusters (in the limit of the stopping
          criterion)
      verbose : bool, optional
          If True, print diagnostic information
  
      Returns
      -------
      u: array of shape (G.V)
         labelling of the graph vertices according to the criterion
      cost: array of shape (G.V - 1)
            the cost of each merge step during the clustering procedure
  
      Notes
      -----
      Hopefully a quicker version
  
      A euclidean distance is used in the feature space
  
      Caveat : only approximate
      """
      # basic check
      if feature.ndim == 1:
          feature = np.reshape(feature, (-1, 1))
  
      if feature.shape[0] != G.V:
          raise ValueError(
              "Incompatible dimension for the feature matrix and the graph"
          )
  
      n = G.V
      if stop == -1:
          stop = np.inf
      qmax = int(np.minimum(qmax, n - 1))
      t = ward_quick(G, feature, verbose)
      if verbose:
          t.plot()
  
      u1 = np.zeros(n, np.int_)
      u2 = np.zeros(n, np.int_)
      if stop >= 0:
          u1 = t.partition(stop)
      if qmax > 0:
          u2 = t.split(qmax)
  
      if u1.max() < u2.max():
          u = u2
      else:
          u = u1
  
      cost = t.get_height()
      cost = cost[t.isleaf() == False]
      return u, cost
  
imports: from warnings import warn
  import numpy
  from ..graph.forest import Forest
  from ..graph.graph import WeightedGraph
label_desc: Use image node_id 11 for calling a global function with example usage: ward_quick_segment(G, feature, stop, qmax, verbose) and returns: u,  cost