class_docstr: This is the basic field structure,
       which contains the weighted graph structure
       plus an array of data (the 'field')
  field is an array of size(n, p)
        where n is the number of vertices of the graph
        and p is the field dimension
class_docstr_tok: ["This","is","the","basic","field","structure",",","which","contains","the","weighted","graph","structure","plus","an","array","of","data","(","the","'field","'",")","field","is","an","array","of","size","(","n",",","p",")","where","n","is","the","number","of","vertices","of","the","graph","and","p","is","the","field","dimension"]
docstr: Ward's clustering of self
  
  Parameters
  ----------
  nbcluster: int,
             the number of desired clusters
  
  Returns
  -------
  label: array of shape (self.V)
         the resulting field label
  J (float): the resulting inertia
docstr_tok: ["Ward","'s","clustering","of","self","Parameters","--","--","--","--","--","nbcluster",":","int",",","the","number","of","desired","clusters","Returns","--","--","--","-","label",":","array","of","shape","(","self.V",")","the","resulting","field","label","J","(","float",")",":","the","resulting","inertia"]
code: def ward(self, nbcluster):
      """Ward's clustering of self
  
      Parameters
      ----------
      nbcluster: int,
                 the number of desired clusters
  
      Returns
      -------
      label: array of shape (self.V)
             the resulting field label
      J (float): the resulting inertia
      """
      from nipy.algorithms.clustering.hierarchical_clustering import (
          ward_segment,
      )
  
      label, J = ward_segment(self, self.field, qmax=nbcluster)
  
      # compute the resulting inertia
      inertia = 0
      for j in range(nbcluster):
          lj = np.nonzero(label == j)[0]
          cent = np.mean(self.field[lj], 0)
          inertia += np.sum((cent - self.field[lj]) ** 2)
      return label, inertia
  
imports: from warnings import warn
  import numpy
  from .graph import Graph, WeightedGraph
label_desc: Use image node_id 16 for calling the Field obj's underlying member method code with example usage: obj.ward(nbcluster) and returns: label,  inertia