Files
graphe/algorithms.h
Tiago Batista Cardoso 2d3865079d lol
2026-02-28 22:41:19 +01:00

61 lines
1.6 KiB
C

//
// 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;
typedef struct {
int **list;
int count;
int capacity;
int k;
} clique_store_t;
int find_max_clique_size(const graph_t *graph);
void compute_kclique_distribution(const graph_t *graph);
void store_clique(clique_store_t *store, int *current);
void enumerate_cliques(const graph_t *graph, clique_store_t *store,
int *current, int depth, int start);
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);
// -- cbla algorithm
struct cbla_result_t {
int *node_community; // node_community[i] = community id of node i
int count; // total number of communities
};
typedef struct cbla_result_t cbla_result_t;
cbla_result_t *cbla_community_detection(const graph_t *graph, int k);
void free_cbla_result(cbla_result_t *result);
#endif