This commit is contained in:
Tiago Batista Cardoso
2026-02-28 22:41:19 +01:00
parent 500e03af35
commit 2d3865079d
21 changed files with 1072 additions and 570 deletions

View File

@@ -5,8 +5,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "algorithms.h"
#include <time.h>
// -- helper methods
@@ -49,7 +49,7 @@ static double k_i_in(const graph_t *graph, int i, int c, int *community)
return sum;
}
// Sum of degrees of all nodes in community c
// sum of degrees of all nodes in community c
static double sigma_tot(const graph_t *graph, int c, int *community)
{
double sum = 0.0;
@@ -171,6 +171,11 @@ static int compact(int *community, int n)
louvain_result_t *compute_louvain(const graph_t *graph)
{
clock_t start, end;
double cpu_time_used;
printf("[compute_louvain()] starting...\n");
start = clock();
int n = graph->n;
double m = (double)count_edges(graph);
@@ -203,6 +208,11 @@ louvain_result_t *compute_louvain(const graph_t *graph)
result->node_community = community;
result->count = count;
result->modularity = Q;
end = clock();
cpu_time_used = ((double)(end - start)) / CLOCKS_PER_SEC;
printf("[compute_louvain()] done (%f s)\n", cpu_time_used);
return result;
}