#include "sources/connexity.h" #include #include #include "sources/utils/boolean.h" int* getConnectedComponents_core(int** NIix, int* lengthNIix, int n) { int* cc = (int*)calloc(n,sizeof(int)); Stack* toBeExplored = stack_new(int); int curInd = 0, nextInd; bool* alreadyExpanded = (bool*)calloc(n,sizeof(bool)); // while the entire graph hasn't been visited while (S_TRUE) { int label = curInd+1; cc[curInd] = label; stack_push(toBeExplored, curInd); // while new elements are discovered in current component, // mark them as expanded and stack their neighbors while (!stack_empty(toBeExplored)) { stack_top(toBeExplored, nextInd); stack_pop(toBeExplored); cc[nextInd] = label; for (int j=0; j