diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2017-02-10 12:19:46 -0500 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2017-02-10 12:19:46 -0500 |
commit | 0ef0c0ce1d904be2b4e1f4da62dc029d8572c983 (patch) | |
tree | 12978013d870186240c08d1fdd6a7ce8781bca93 /lib/get_dual_clusters.c | |
parent | 9a93a3b88a604672f557950e6c7f3fe815bcf163 (diff) | |
parent | 901b9f16494f37890be17ef4bb66e6efc6873340 (diff) | |
download | fuse_networks-0ef0c0ce1d904be2b4e1f4da62dc029d8572c983.tar.gz fuse_networks-0ef0c0ce1d904be2b4e1f4da62dc029d8572c983.tar.bz2 fuse_networks-0ef0c0ce1d904be2b4e1f4da62dc029d8572c983.zip |
Merge branch 'tmp'
Diffstat (limited to 'lib/get_dual_clusters.c')
-rw-r--r-- | lib/get_dual_clusters.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/get_dual_clusters.c b/lib/get_dual_clusters.c new file mode 100644 index 0000000..eaf7562 --- /dev/null +++ b/lib/get_dual_clusters.c @@ -0,0 +1,30 @@ + +#include "fracture.h" + +components_t *get_clusters(net_t *instance) { + components_t *c = graph_components_get(instance->graph, instance->fuses, true); + return c; +} + +unsigned int *get_cluster_dist(net_t *instance) { + components_t *c = get_clusters(instance); + unsigned int *cluster_dist = (unsigned int *)calloc( + instance->graph->dnv, sizeof(unsigned int)); + + for (uint32_t i = 1; i <= c->n; i++) { + unsigned int num_in_cluster = 0; + for (unsigned int j = 0; j < instance->graph->dnv; j++) { + if (c->labels[j] == i) + num_in_cluster++; + } + + if (num_in_cluster == 0) + break; + + cluster_dist[num_in_cluster - 1]++; + } + + graph_components_free(c); + + return cluster_dist; +} |