12void order_nodes(
const int N,
const int *
const merge,
const t_index *
const node_size,
int *
const order) {
25 auto_array_ptr<pos_node> queue(N/2);
38 parent = queue[idx].node;
41 child = merge[parent];
49 queue[idx].node =
child-1;
51 pos += node_size[
child-1];
54 child = merge[parent+N-1];
60 queue[idx].node =
child-1;
66#define size_(r_) ( ((r_<N) ? 1 : node_size[r_-N]) )
68template <const
bool sorted>
69void generate_R_dendrogram(
int *
const merge,
double *
const height,
int *
const order, cluster_result & Z2,
const int N) {
72 union_find
nodes(sorted ? 0 : N);
74 std::stable_sort(Z2[0], Z2[N-1]);
78 auto_array_ptr<t_index> node_size(N-1);
80 for (t_index i=0; i<N-1; ++i) {
88 node1 =
nodes.Find(Z2[i]->node1);
89 node2 =
nodes.Find(Z2[i]->node2);
92 nodes.Union(node1, node2);
106 merge[i] = (node1<N) ? -
static_cast<int>(node1)-1
107 :
static_cast<int>(node1)-N+1;
108 merge[i+N-1] = (node2<N) ? -
static_cast<int>(node2)-1
109 :
static_cast<int>(node2)-N+1;
110 height[i] = Z2[i]->dist;
111 node_size[i] = size_(node1) + size_(node2);
114 order_nodes(N, merge, node_size, order);
iter_range< typename GenericGraphTraits< GraphType >::nodes_iterator > nodes(const GraphType &G)