| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | // Base implementation of a size and radius-constrained clustering algorithm. |
| | | 4 | | // |
| | | 5 | | // The size is defined as the maximum number of hierarchical objects within a cluster, and the |
| | | 6 | | // radius denotes the maximum distance from the cluster's centroid to any of its assigned |
| | | 7 | | // hierarchical objects. |
| | | 8 | | public abstract class SizeAndRadiusConstrainedClustererBase : ClustererBase { |
| | | 9 | | // Maximum cluster size. |
| | 13 | 10 | | protected readonly int _maxSize = 0; |
| | | 11 | | |
| | | 12 | | // Maximum cluster radius. |
| | 13 | 13 | | protected readonly float _maxRadius = 0; |
| | | 14 | | |
| | 26 | 15 | | public SizeAndRadiusConstrainedClustererBase(int maxSize, float maxRadius) { |
| | 13 | 16 | | if (maxSize <= 0) { |
| | 0 | 17 | | throw new ArgumentOutOfRangeException("Maximum size must be positive.", nameof(maxSize)); |
| | | 18 | | } |
| | 13 | 19 | | if (maxRadius < 0) { |
| | 0 | 20 | | throw new ArgumentOutOfRangeException("Maximum radius must be non-negative.", |
| | | 21 | | nameof(maxRadius)); |
| | | 22 | | } |
| | 13 | 23 | | _maxSize = maxSize; |
| | 13 | 24 | | _maxRadius = maxRadius; |
| | 13 | 25 | | } |
| | | 26 | | } |