summaryrefslogtreecommitdiff
path: root/lib/get_dual_clusters.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/get_dual_clusters.c')
-rw-r--r--lib/get_dual_clusters.c30
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;
+}