MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / leiden_count_communities

Function leiden_count_communities

tests/test_store_arch.c:1525–1542  ·  view source on GitHub ↗

Count distinct community labels in a result. */

Source from the content-addressed store, hash-verified

1523
1524/* Count distinct community labels in a result. */
1525static int leiden_count_communities(const cbm_louvain_result_t *r, int n) {
1526 int *seen = malloc((size_t)n * sizeof(int));
1527 int nd = 0;
1528 for (int i = 0; i < n; i++) {
1529 bool found = false;
1530 for (int j = 0; j < nd; j++) {
1531 if (seen[j] == r[i].community) {
1532 found = true;
1533 break;
1534 }
1535 }
1536 if (!found) {
1537 seen[nd++] = r[i].community;
1538 }
1539 }
1540 free(seen);
1541 return nd;
1542}
1543
1544/* Verify every community induces a connected subgraph under `edges` — the
1545 * property Leiden's refinement guarantees and single-level Louvain does not. */

Callers 1

test_store_arch.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected