From 3d81d499061c757ace9e92f2e8849b4db9a42a3b Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 19 Apr 2012 15:47:53 -0400 Subject: [PATCH] Added comments. Cleaned up the code --- jozov_persistent.c | 87 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 73 insertions(+), 14 deletions(-) diff --git a/jozov_persistent.c b/jozov_persistent.c index f5fb4e7..9a76e8a 100644 --- a/jozov_persistent.c +++ b/jozov_persistent.c @@ -27,12 +27,14 @@ typedef struct Zone { float denscontrast; /* density contrast */ double vol; /* Total volume of all particles in the zone */ double voljoin; /* Total volume of all particles in the joined void */ + float smallest_saddle; /* Smallest saddle */ } ZONE; typedef struct ZoneT { int nadj; /* Number of zones on border */ int *adj; /* Each adjacent zone, with ... */ float *slv; /* Smallest Linking Volume */ + float smallest_saddle; /* Smallest saddle point value */ } ZONET; void findrtop(double *a, int na, int *iord, int nb); @@ -114,11 +116,11 @@ int main(int argc,char **argv) { fread(&j,1,sizeof(int),adj); if (j < np) { /* Set both halves of the pair */ - assert(i < j); + assert(i < j); if (p[i].ncnt == p[i].nadj) { - p[i].adj = (int *)realloc(p[i].adj, (p[i].nadj+1)*sizeof(int)); - p[i].nadj++; + p[i].adj = (int *)realloc(p[i].adj, (p[i].nadj+1)*sizeof(int)); + p[i].nadj++; } if (p[j].ncnt == p[j].nadj) { @@ -136,17 +138,17 @@ int main(int argc,char **argv) { fclose(adj); /* Check that we got all the pairs */ -// adj = fopen(adjfile, "r"); -// fread(&np,1, sizeof(int),adj); + // adj = fopen(adjfile, "r"); + // fread(&np,1, sizeof(int),adj); for (i=0;i p[i].dens) { /* there could be a weakest link through testpart */ @@ -282,8 +288,13 @@ int main(int argc,char **argv) { } } if (already == 0) { - zt[h].adj[zt[h].nadj] = zonenum[jumped[testpart]]; - zt[h].slv[zt[h].nadj] = p[i].dens; + int q = zt[h].nadj; + + zt[h].adj[q] = zonenum[jumped[testpart]]; + zt[h].slv[q] = p[i].dens; + if (zt[h].smallest_saddle > zt[h].slv[q]) + zt[h].smallest_saddle = zt[h].slv[q]; + zt[h].nadj++; } } @@ -308,6 +319,7 @@ int main(int argc,char **argv) { free(zt[h].adj); free(zt[h].slv); z[h].np = numinh[z[h].core]; + z[h].smallest_saddle = zt[h].smallest_saddle; } free(zt); free(numinh); @@ -379,6 +391,12 @@ int main(int argc,char **argv) { } fwrite(&nzones,1,4,zon2); + +#define CORE_DENSITY(a) p[z[a].core].dens +#define SADDLE_DENSITY(a) z[a].smallest_saddle +#define COMPARE_ZONES_BEATEN(a,b) (CORE_DENSITY(a) < CORE_DENSITY(b)) + + for (h = 0; h maxdenscontrast) {