#include <assert.h>
#include <vector>
#include <algorithm>
#include "FastCluster/fastcluster.h"
#include "fastcluster_dm.cpp.inc"
#include "fastcluster_R_dm.cpp.inc"
Go to the source code of this file.
|
bool | fc_isnan (double x) |
|
void | cutree_k (int n, const int *merge, int nclust, int *labels) |
|
void | cutree_cdist (int n, const int *merge, double *height, double cdist, int *labels) |
|
int | hclust_fast (int n, double *distmat, int method, int *merge, double *height) |
|
◆ cutree_cdist()
void cutree_cdist |
( |
int |
n, |
|
|
const int * |
merge, |
|
|
double * |
height, |
|
|
double |
cdist, |
|
|
int * |
labels |
|
) |
| |
Definition at line 116 of file fastcluster.cpp.
121 for (k=0; k<(
n-1); k++)
123 if (height[k] >= cdist)
void cutree_k(int n, const int *merge, int nclust, int *labels)
◆ cutree_k()
void cutree_k |
( |
int |
n, |
|
|
const int * |
merge, |
|
|
int |
nclust, |
|
|
int * |
labels |
|
) |
| |
Definition at line 37 of file fastcluster.cpp.
42 if (nclust >
n || nclust < 2)
44 for (j=0; j<
n; j++) labels[j] = 0;
50 std::vector<int> last_merge(
n, 0);
51 for (k=1; k<=(
n-nclust); k++)
58 last_merge[-m1-1] = last_merge[-m2-1] = k;
60 else if (m1 < 0 || m2 < 0)
69 for(l = 0; l <
n; l++)
70 if (last_merge[l] == m1)
78 if( last_merge[l] == m1 || last_merge[l] == m2 )
86 std::vector<int> z(
n,-1);
89 if (last_merge[j] == 0)
95 if (z[last_merge[j]] < 0)
97 z[last_merge[j]] = label++;
99 labels[j] = z[last_merge[j]];
◆ fc_isnan()
bool fc_isnan |
( |
double |
x | ) |
|
◆ hclust_fast()
int hclust_fast |
( |
int |
n, |
|
|
double * |
distmat, |
|
|
int |
method, |
|
|
int * |
merge, |
|
|
double * |
height |
|
) |
| |
Definition at line 156 of file fastcluster.cpp.
160 cluster_result Z2(
n-1);
164 MST_linkage_core(
n, distmat, Z2);
169 NN_chain_core<METHOD_METR_COMPLETE, t_float>(
n, distmat,
NULL, Z2);
174 double* members =
new double[
n];
175 for (
int i=0; i<
n; i++) members[i] = 1;
176 NN_chain_core<METHOD_METR_AVERAGE, t_float>(
n, distmat, members, Z2);
182 generic_linkage<METHOD_METR_MEDIAN, t_float>(
n, distmat,
NULL, Z2);
189 int* order =
new int[
n];
192 generate_R_dendrogram<true>(merge, height, order, Z2,
n);
196 generate_R_dendrogram<false>(merge, height, order, Z2,
n);