This commit is contained in:
Tiago Batista Cardoso
2026-02-28 11:10:17 +01:00
parent 2736884f46
commit 500e03af35
10 changed files with 508 additions and 28 deletions

48
algorithms.h Normal file
View File

@@ -0,0 +1,48 @@
//
// Created by Tiago Batista Cardoso on 2/26/2026.
//
#ifndef GRAPHE_ALGORITHMS_H
#define GRAPHE_ALGORITHMS_H
#include "structs.h"
// -- k-clique communities
struct community_t {
int *members; // node ids in this community
int size;
};
typedef struct community_t community_t;
struct community_result_t {
community_t *communities;
int count;
int *node_community; // node_community[i] = community index of node i (-1 if none)
};
typedef struct community_result_t community_result_t;
community_result_t *find_k_clique_communities(const graph_t *graph, int k);
void free_community_result(community_result_t *result);
// -- louvain
struct louvain_result_t {
int *node_community; // node_community[i] = community id of node i
int count; // total number of communities
double modularity; // final modularity score
};
typedef struct louvain_result_t louvain_result_t;
louvain_result_t *compute_louvain(const graph_t *graph);
void free_louvain_result(louvain_result_t *result);
// -- hybrid algorithm
struct hybrid_result_t {
int *node_community; // node_community[i] = community id of node i
int count; // total number of communities
};
typedef struct hybrid_result_t hybrid_result_t;
hybrid_result_t *hybrid_community_detection(const graph_t *graph, int k);
void free_hybrid_result(hybrid_result_t *result);
#endif