class_docstr: !
  @brief Class represents clustering algorithm K-Medians.
  @details The algorithm is less sensitive to outliers than K-Means. Medians are calculated instead of centroids.
  
  Example:
  @code
      from pyclustering.cluster.kmedians import kmedians
      from pyclustering.cluster import cluster_visualizer
      from pyclustering.utils import read_sample
      from pyclustering.samples.definitions import FCPS_SAMPLES
  
      # Load list of points for cluster analysis.
      sample = read_sample(FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS)
  
      # Create instance of K-Medians algorithm.
      initial_medians = [[0.0, 0.1], [2.5, 0.7]]
      kmedians_instance = kmedians(sample, initial_medians)
  
      # Run cluster analysis and obtain results.
      kmedians_instance.process()
      clusters = kmedians_instance.get_clusters()
      medians = kmedians_instance.get_medians()
  
      # Visualize clustering results.
      visualizer = cluster_visualizer()
      visualizer.append_clusters(clusters, sample)
      visualizer.append_cluster(initial_medians, marker='*', markersize=10)
      visualizer.append_cluster(medians, marker='*', markersize=10)
      visualizer.show()
  @endcode
class_docstr_tok: ["!","@","brief","Class","represents","clustering","algorithm","K-Medians",".","@","details","The","algorithm","is","less","sensitive","to","outliers","than","K-Means",".","Medians","are","calculated","instead","of","centroids",".","Example",":","@","code","from","pyclustering.cluster.kmedians","import","kmedians","from","pyclustering.cluster","import","cluster_visualizer","from","pyclustering.utils","import","read_sample","from","pyclustering.samples.definitions","import","FCPS_SAMPLES","#","Load","list","of","points","for","cluster","analysis",".","sample","=","read_sample","(","FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS",")","#","Create","instance","of","K-Medians","algorithm",".","initial_medians","=","[","[","0.0",",","0.1","]",",","[","2.5",",","0.7","]","]","kmedians_instance","=","kmedians","(","sample",",","initial_medians",")","#","Run","cluster","analysis","and","obtain","results",".","kmedians_instance.process","(",")","clusters","=","kmedians_instance.get_clusters","(",")","medians","=","kmedians_instance.get_medians","(",")","#","Visualize","clustering","results",".","visualizer","=","cluster_visualizer","(",")","visualizer.append_clusters","(","clusters",",","sample",")","visualizer.append_cluster","(","initial_medians",",","marker=","'","*","'",",","markersize=10",")","visualizer.append_cluster","(","medians",",","marker=","'","*","'",",","markersize=10",")","visualizer.show","(",")","@","endcode"]
docstr: !
  @brief Calculate Manhattan distance to each point from the each cluster. 
  @details Nearest points are captured by according clusters and as a result clusters are updated.
  
  @return (list) updated clusters as list of clusters where each cluster contains indexes of objects from data.
docstr_tok: ["!","@","brief","Calculate","Manhattan","distance","to","each","point","from","the","each","cluster",".","@","details","Nearest","points","are","captured","by","according","clusters","and","as","a","result","clusters","are","updated",".","@","return","(","list",")","updated","clusters","as","list","of","clusters","where","each","cluster","contains","indexes","of","objects","from","data","."]
code: def __update_clusters(self):
      """!
      @brief Calculate Manhattan distance to each point from the each cluster.
      @details Nearest points are captured by according clusters and as a result clusters are updated.
  
      @return (list) updated clusters as list of clusters where each cluster contains indexes of objects from data.
  
      """
  
      clusters = [[] for i in range(len(self.__medians))]
      for index_point in range(len(self.__pointer_data)):
          index_optim = -1
          dist_optim = 0.0
  
          for index in range(len(self.__medians)):
              dist = self.__metric(
                  self.__pointer_data[index_point],
                  self.__medians[index],
              )
  
              if (dist < dist_optim) or (index == 0):
                  index_optim = index
                  dist_optim = dist
  
          clusters[index_optim].append(index_point)
  
      # If cluster is not able to capture object it should be removed
      clusters = [cluster for cluster in clusters if len(cluster) > 0]
  
      return clusters
  
file_path: pyclustering/pyclustering/cluster/kmedians.py
imports: import math
  import numpy
  from pyclustering.cluster.encoder import type_encoding
  from pyclustering.utils.metric import distance_metric, type_metric
  import pyclustering.core.kmedians_wrapper
  from pyclustering.core.wrapper import ccore_library
  from pyclustering.core.metric_wrapper import metric_wrapper
label_desc: Use image node_id 8 for calling the kmedians obj's underlying member method code with example usage: obj.__update_clusters() and returns: clusters