diff options
author | Jaron Kent-Dobias <jkentdobias@g.hmc.edu> | 2016-08-22 10:11:14 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jkentdobias@g.hmc.edu> | 2016-08-22 10:11:14 -0400 |
commit | 2bb0740b68fdb62d45adc00204b3990ca42ade77 (patch) | |
tree | a52975e3460da781467ddb70aaa8d76840d01bb4 /src/get_dual_clusters.c | |
download | fuse_networks-2bb0740b68fdb62d45adc00204b3990ca42ade77.tar.gz fuse_networks-2bb0740b68fdb62d45adc00204b3990ca42ade77.tar.bz2 fuse_networks-2bb0740b68fdb62d45adc00204b3990ca42ade77.zip |
started repo again without all the data files gunking the works
Diffstat (limited to 'src/get_dual_clusters.c')
-rw-r--r-- | src/get_dual_clusters.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/get_dual_clusters.c b/src/get_dual_clusters.c new file mode 100644 index 0000000..488793f --- /dev/null +++ b/src/get_dual_clusters.c @@ -0,0 +1,36 @@ + +#include "fracture.h" + +unsigned int *get_clusters(finst *instance, cholmod_common *c) { + cholmod_sparse *s_dual = gen_adjacency(instance, true, false, 0, c); + + unsigned int *dual_marks = find_components(s_dual, 0); + CHOL_F(free_sparse)(&s_dual, c); + + return dual_marks; +} + +unsigned int *get_cluster_dist(finst *instance, cholmod_common *c) { + unsigned int *clusters = get_clusters(instance, c); + unsigned int *cluster_dist = (unsigned int *)calloc( + instance->network->num_dual_verts, sizeof(unsigned int)); + + unsigned int cur_mark = 0; + while (true) { + cur_mark++; + unsigned int num_in_cluster = 0; + for (unsigned int i = 0; i < instance->network->num_dual_verts; i++) { + if (clusters[i] == cur_mark) + num_in_cluster++; + } + + if (num_in_cluster == 0) + break; + + cluster_dist[num_in_cluster - 1]++; + } + + free(clusters); + + return cluster_dist; +} |