From: erg Date: Wed, 13 Jul 2005 20:29:40 +0000 (+0000) Subject: Add hierarchical constraints. This is enabled only if the compile-time X-Git-Tag: LAST_LIBGRAPH~32^2~7462 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b4c5b00309b4e8eccca1dfe9342ced9d236110e1;p=graphviz Add hierarchical constraints. This is enabled only if the compile-time variable DIGCOLA is defined. At present, by default this is undefined. --- diff --git a/lib/neatogen/bfs.h b/lib/neatogen/bfs.h index 36a8d68a1..a027d91dd 100644 --- a/lib/neatogen/bfs.h +++ b/lib/neatogen/bfs.h @@ -18,8 +18,6 @@ extern "C" { #endif - - #ifndef _BFS_H_ #define _BFS_H_ diff --git a/lib/neatogen/defs.h b/lib/neatogen/defs.h index 6ee65a16a..8579c5638 100644 --- a/lib/neatogen/defs.h +++ b/lib/neatogen/defs.h @@ -18,8 +18,6 @@ extern "C" { #endif - - #ifndef _DEFS_H_ #define _DEFS_H_ @@ -32,6 +30,7 @@ extern "C" { int *edges; float *ewgts; Style *styles; + float *edists; /* directed dist reflecting the direction of the edge */ }; typedef int DistType; /* must be signed!! */ @@ -90,6 +89,9 @@ extern "C" { node_t *np; /* original node */ #ifdef USE_STYLES Style *styles; +#endif +#ifdef DIGCOLA + float *edists; /* directed dist reflecting the direction of the edge */ #endif } vtx_data; diff --git a/lib/neatogen/kkutils.c b/lib/neatogen/kkutils.c index d42dfd791..5e34abf20 100644 --- a/lib/neatogen/kkutils.c +++ b/lib/neatogen/kkutils.c @@ -177,6 +177,30 @@ double distance_kD(double **coords, int dim, int i, int j) return sqrt(sum); } +static float* fvals; +static int +fcmpf (int* ip1, int* ip2) +{ + float d1 = fvals[*ip1]; + float d2 = fvals[*ip2]; + if (d1 < d2) return -1; + else if (d1 > d2) return 1; + else return 0; +} + +void quicksort_placef(float *place, int *ordering, int first, int last) +{ + if (first < last) { + fvals = place; + qsort(ordering+first, last-first+1, sizeof(ordering[0]), (qsort_cmpf)fcmpf); + } +} + +/* quicksort_place: + * For now, we keep the current implementation for stability, but + * we should consider replacing this with an implementation similar to + * quicksort_placef above. + */ void quicksort_place(double *place, int *ordering, int first, int last) { if (first < last) {