#ifndef INCLUDED_C_CC_H #define INCLUDED_C_CC_H #ifndef INCLUDED_C_GRAPH_H #include #endif /*INCLUDED_C_GRAPH_H*/ /* ------------------------------------------------------------------------------------------------------------------ */ /* */ typedef struct { c_bool_t* marked; // marked[v] = has vertex v been discovered? c_size_t* id; // id[v] = connected component identifier id of v c_size_t* size; // size[id] = number of vertices in component id c_size_t count; // Total number of isolated connected components c_size_t V; c_Allocator_t allocator; // Memory allocator reference instance copy } c_CC_t; /** * @brief Computes the connected components partition of an undirected graph. * @param self Pointer to the uninitialized connected components state tracker. * @param G Pointer to the constant target graph object to process. * @param allocator Memory allocator instance pointer to deploy. * @return C_SUCCESS on success, or an error status code on allocation failure. */ c_err_t c_CC_Init(c_CC_t* self, const c_Graph_t* G, c_Allocator_t* allocator); /** * @brief Drops all internal allocation states within the CC structural instance safely. */ void c_CC_Destroy(c_CC_t* self); /** * @brief Are vertices v and w in the same connected component cluster? */ c_bool_t c_CC_Connected(const c_CC_t* self, c_VertexId_t v, c_VertexId_t w); /** * @brief Returns the component identifier id containing vertex v (ranges from 0 to Count()-1). */ c_size_t c_CC_Id(const c_CC_t* self, c_VertexId_t v); /** * @brief Returns the number of vertices in the connected component cluster containing vertex v. */ c_size_t c_CC_Size(const c_CC_t* self, c_VertexId_t v); /** * @brief Returns the total number of connected components clusters in the graph. */ c_size_t c_CC_Count(const c_CC_t* self); #endif /*INCLUDED_C_CC_H*/