GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_distinct.c
Go to the documentation of this file.
1 #include <grass/cluster.h>
2 
3 int I_cluster_distinct(struct Cluster *C, double separation)
4 {
5  int class1, class2;
6  int distinct;
7  double dmin;
8  double dsep;
9 
10  /* compute sum of squares for each class */
11  I_cluster_sum2(C);
12 
13  /* find closest classes */
14  distinct = 1;
15  dmin = separation;
16  for (class1 = 0; class1 < (C->nclasses - 1); class1++) {
17  if (C->count[class1] < 2)
18  continue;
19  for (class2 = class1 + 1; class2 < C->nclasses; class2++) {
20  if (C->count[class2] < 2)
21  continue;
22  dsep = I_cluster_separation(C, class1, class2);
23 
24  if (dsep >= 0.0 && dsep < dmin) {
25  distinct = 0;
26  C->merge1 = class1;
27  C->merge2 = class2;
28  dmin = dsep;
29  }
30  }
31  }
32 
33  return distinct;
34 }
DCELL dmin
Definition: g3dcolor.c:53
#define C
Definition: intr_char.c:17
int I_cluster_sum2(struct Cluster *C)
Definition: c_sum2.c:4
double I_cluster_separation(struct Cluster *C, int class1, int class2)
Definition: c_sep.c:6
int I_cluster_distinct(struct Cluster *C, double separation)
Definition: c_distinct.c:3