lol
This commit is contained in:
16
render.c
16
render.c
@@ -132,7 +132,7 @@ static SDL_Color community_colors[] = {
|
||||
#define N_COLORS (sizeof(community_colors) / sizeof(community_colors[0]))
|
||||
|
||||
void render_graph(SDL_Renderer *renderer, const graph_t *graph,
|
||||
VISUALIZATION_TYPE type)
|
||||
VISUALIZATION_TYPE type, int k)
|
||||
{
|
||||
if (!renderer || !graph || !graph->adj_lists)
|
||||
return;
|
||||
@@ -145,14 +145,18 @@ void render_graph(SDL_Renderer *renderer, const graph_t *graph,
|
||||
|
||||
community_result_t *communities = NULL;
|
||||
louvain_result_t *louvain = NULL;
|
||||
cbla_result_t *cbla = NULL;
|
||||
|
||||
switch (type) {
|
||||
case CLIQUE:
|
||||
communities = find_k_clique_communities(graph, 3);
|
||||
communities = find_k_clique_communities(graph, k);
|
||||
break;
|
||||
case LOUVAIN:
|
||||
louvain = compute_louvain(graph);
|
||||
break;
|
||||
case CBLA:
|
||||
cbla = cbla_community_detection(graph, k);
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, 48, 48, 48, 255);
|
||||
@@ -193,6 +197,11 @@ void render_graph(SDL_Renderer *renderer, const graph_t *graph,
|
||||
col = (c == -1) ? (SDL_Color){ 168, 153, 132, 255 } :
|
||||
community_colors[c % N_COLORS];
|
||||
break;
|
||||
case CBLA:
|
||||
c = cbla->node_community[i];
|
||||
col = (c == -1) ? (SDL_Color){ 168, 153, 132, 255 } :
|
||||
community_colors[c % N_COLORS];
|
||||
break;
|
||||
}
|
||||
SDL_SetRenderDrawColor(renderer, col.r, col.g, col.b, col.a);
|
||||
|
||||
@@ -206,6 +215,9 @@ void render_graph(SDL_Renderer *renderer, const graph_t *graph,
|
||||
if (louvain != NULL) {
|
||||
free_louvain_result(louvain);
|
||||
}
|
||||
if (cbla != NULL) {
|
||||
free_cbla_result(cbla);
|
||||
}
|
||||
|
||||
free(layout);
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
Reference in New Issue
Block a user