/// <summary> /// Initializes a new instance of the <see cref="KNearestNeighbors{T}"/> class. /// </summary> /// <param name="k">The number of neighbors during classification</param> /// <param name="dataStructure">The backing data structure</param> public KNearestNeighbors(int k, Func <T, T, double> metric, ISpatialQueryable <T> dataStructure = null) { this.Metric = metric; this.K = k; this.internalDataStructure = dataStructure ?? new MetricSpaceSubset <T>(metric); this.clusterIndexDictionary = new Dictionary <int, List <int> >(); this.Clusters = new ClusterDictionary <int, T>(this.internalDataStructure, this.clusterIndexDictionary); }
/// <summary> /// Initializes a new instance of the <see cref="ClusterDictionary{TKey, TValue}"/> class. /// </summary> /// <param name="source">The <see cref="ISpatialQueryable{T}"/></param> /// <param name="internalDictionary">The <see cref="IDictionary{TKey,TValue}"/></param> public ClusterDictionary(ISpatialQueryable <TValue> source, IDictionary <TKey, List <int> > internalDictionary = null) { this.SourceDataStructure = source; this.clusterDictionary = internalDictionary ?? new Dictionary <TKey, List <int> >(); }