class_docstr: !
  @brief Class represents clustering algorithm CURE with KD-tree optimization.
  @details CCORE option can be used to use the pyclustering core - C/C++ shared library for processing that significantly increases performance.
  
  Here is an example how to perform cluster analysis of sample 'Lsun':
  @code
      from pyclustering.cluster import cluster_visualizer;
      from pyclustering.cluster.cure import cure;
      from pyclustering.utils import read_sample;
      from pyclustering.samples.definitions import FCPS_SAMPLES;
  
      # Input data in following format [ [0.1, 0.5], [0.3, 0.1], ... ].
      input_data = read_sample(FCPS_SAMPLES.SAMPLE_LSUN);
  
      # Allocate three clusters.
      cure_instance = cure(input_data, 3);
      cure_instance.process();
      clusters = cure_instance.get_clusters();
  
      # Visualize allocated clusters.
      visualizer = cluster_visualizer();
      visualizer.append_clusters(clusters, input_data);
      visualizer.show();
  @endcode
class_docstr_tok: ["!","@","brief","Class","represents","clustering","algorithm","CURE","with","KD-tree","optimization",".","@","details","CCORE","option","can","be","used","to","use","the","pyclustering","core","-","C\/C++","shared","library","for","processing","that","significantly","increases","performance",".","Here","is","an","example","how","to","perform","cluster","analysis","of","sample","'Lsun","'",":","@","code","from","pyclustering.cluster","import","cluster_visualizer",";","from","pyclustering.cluster.cure","import","cure",";","from","pyclustering.utils","import","read_sample",";","from","pyclustering.samples.definitions","import","FCPS_SAMPLES",";","#","Input","data","in","following","format","[","[","0.1",",","0.5","]",",","[","0.3",",","0.1","]",",","...","]",".","input_data","=","read_sample","(","FCPS_SAMPLES.SAMPLE_LSUN",")",";","#","Allocate","three","clusters",".","cure_instance","=","cure","(","input_data",",","3",")",";","cure_instance.process","(",")",";","clusters","=","cure_instance.get_clusters","(",")",";","#","Visualize","allocated","clusters",".","visualizer","=","cluster_visualizer","(",")",";","visualizer.append_clusters","(","clusters",",","input_data",")",";","visualizer.show","(",")",";","@","endcode"]
docstr: !
  @brief Find closest cluster to the specified cluster in line with distance.
  
  @param[in] cluster (cure_cluster): Cluster for which nearest cluster should be found.
  @param[in] distance (double): Closest distance to the previous cluster.
  
  @return (tuple) Pair (nearest CURE cluster, nearest distance) if the nearest cluster has been found, otherwise None is returned.
docstr_tok: ["!","@","brief","Find","closest","cluster","to","the","specified","cluster","in","line","with","distance",".","@","param","[","in","]","cluster","(","cure_cluster",")",":","Cluster","for","which","nearest","cluster","should","be","found",".","@","param","[","in","]","distance","(","double",")",":","Closest","distance","to","the","previous","cluster",".","@","return","(","tuple",")","Pair","(","nearest","CURE","cluster",",","nearest","distance",")","if","the","nearest","cluster","has","been","found",",","otherwise","None","is","returned","."]
code: def __closest_cluster(self, cluster, distance):
      """!
      @brief Find closest cluster to the specified cluster in line with distance.
  
      @param[in] cluster (cure_cluster): Cluster for which nearest cluster should be found.
      @param[in] distance (double): Closest distance to the previous cluster.
  
      @return (tuple) Pair (nearest CURE cluster, nearest distance) if the nearest cluster has been found, otherwise None is returned.
  
      """
  
      nearest_cluster = None
      nearest_distance = float("inf")
  
      real_euclidean_distance = distance**0.5
  
      for point in cluster.rep:
          # Nearest nodes should be returned (at least it will return itself).
          nearest_nodes = self.__tree.find_nearest_dist_nodes(
              point, real_euclidean_distance
          )
          for candidate_distance, kdtree_node in nearest_nodes:
              if (
                  (candidate_distance < nearest_distance)
                  and (kdtree_node is not None)
                  and (kdtree_node.payload is not cluster)
              ):
                  nearest_distance = candidate_distance
                  nearest_cluster = kdtree_node.payload
  
      return (nearest_cluster, nearest_distance)
  
imports: import numpy
  from pyclustering.cluster.encoder import type_encoding
  from pyclustering.utils import euclidean_distance_square
  from pyclustering.container.kdtree import kdtree
  from pyclustering.core.wrapper import ccore_library
  import pyclustering.core.cure_wrapper
label_desc: Use image node_id 13 for calling the cure obj's underlying member method code with example usage: obj.__closest_cluster(cluster, distance) and returns: nearest_cluster,  nearest_distance