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: Geodesic k-means algorithm
  i.e. obtention of clusters that are topologically
  connected and minimally variable concerning the information
  of self.field
  
  Parameters
  ----------
  seeds: array of shape(p), optional,
         initial indices of the seeds within the field
         if seeds==None the labels are used as initialization
  labels: array of shape(self.V) initial labels, optional,
          it is expected that labels take their values
          in a certain range (0..lmax)
          if Labels==None, this is not used
          if seeds==None and labels==None,  an ewxception is raised
  maxiter: int, optional,
           maximal number of iterations
  eps: float, optional,
       increase of inertia at which convergence is declared
  
  Returns
  -------
  seeds: array of shape (p), the final seeds
  label : array of shape (self.V), the resulting field label
  J: float, inertia value
docstr_tok: ["Geodesic","k-means","algorithm","i.e",".","obtention","of","clusters","that","are","topologically","connected","and","minimally","variable","concerning","the","information","of","self.field","Parameters","--","--","--","--","--","seeds",":","array","of","shape","(","p",")",",","optional",",","initial","indices","of","the","seeds","within","the","field","if","seeds==None","the","labels","are","used","as","initialization","labels",":","array","of","shape","(","self.V",")","initial","labels",",","optional",",","it","is","expected","that","labels","take","their","values","in","a","certain","range","(","0","..","lmax",")","if","Labels==None",",","this","is","not","used","if","seeds==None","and","labels==None",",","an","ewxception","is","raised","maxiter",":","int",",","optional",",","maximal","number","of","iterations","eps",":","float",",","optional",",","increase","of","inertia","at","which","convergence","is","declared","Returns","--","--","--","-","seeds",":","array","of","shape","(","p",")",",","the","final","seeds","label",":","array","of","shape","(","self.V",")",",","the","resulting","field","label","J",":","float",",","inertia","value"]
code: def geodesic_kmeans(
      self, seeds=None, label=None, maxiter=100, eps=1.0e-4, verbose=0
  ):
      """Geodesic k-means algorithm
      i.e. obtention of clusters that are topologically
      connected and minimally variable concerning the information
      of self.field
  
      Parameters
      ----------
      seeds: array of shape(p), optional,
             initial indices of the seeds within the field
             if seeds==None the labels are used as initialization
      labels: array of shape(self.V) initial labels, optional,
              it is expected that labels take their values
              in a certain range (0..lmax)
              if Labels==None, this is not used
              if seeds==None and labels==None,  an ewxception is raised
      maxiter: int, optional,
               maximal number of iterations
      eps: float, optional,
           increase of inertia at which convergence is declared
  
      Returns
      -------
      seeds: array of shape (p), the final seeds
      label : array of shape (self.V), the resulting field label
      J: float, inertia value
      """
      if np.size(self.field) == 0:
          raise ValueError("No field has been defined so far")
  
      if (seeds is None) and (label is None):
          raise ValueError("No initialization has been provided")
      k = np.size(seeds)
      inertia_old = NEGINF
      if seeds is None:
          k = label.max() + 1
          if np.size(np.unique(label)) != k:
              raise ValueError("missing values, cannot proceed")
          seeds = np.zeros(k).astype(np.int_)
          for j in range(k):
              lj = np.nonzero(label == j)[0]
              cent = np.mean(self.field[lj], 0)
              tj = np.argmin(np.sum((cent - self.field[lj]) ** 2, 1))
              seeds[j] = lj[tj]
      else:
          k = np.size(seeds)
  
      for i in range(maxiter):
          # voronoi labelling
          label = self.constrained_voronoi(seeds)
          # update the seeds
          inertia = 0
          pinteria = 0
          for j in range(k):
              lj = np.nonzero(label == j)[0]
              pinteria += np.sum(
                  (self.field[seeds[j]] - self.field[lj]) ** 2
              )
              cent = np.mean(self.field[lj], 0)
              tj = np.argmin(np.sum((cent - self.field[lj]) ** 2, 1))
              seeds[j] = lj[tj]
              inertia += np.sum((cent - self.field[lj]) ** 2)
          if verbose:
              print(i, inertia)
          if np.absolute(inertia_old - inertia) < eps:
              break
          inertia_old = inertia
      return seeds, label, inertia
  
imports: from warnings import warn
  import numpy
  from .graph import Graph, WeightedGraph
label_desc: Use image node_id 15 for calling the Field obj's underlying member method code with example usage: obj.geodesic_kmeans(seeds, label, maxiter, eps, verbose) and returns: seeds,  label,  inertia