#ifndef INCLUDED_C_NONRECURSIVEDFS_H #define INCLUDED_C_NONRECURSIVEDFS_H #ifndef INCLUDED_C_GRAPH_H #include #endif /*INCLUDED_C_GRAPH_H*/ #ifndef INCLUDED_C_VERTEXIDLIST_H #include #endif /*INCLUDED_C_VERTEXIDLIST_H*/ /* ------------------------------------------------------------------------------------------------------------------ */ /* */ typedef struct { c_bool_t* marked; // marked[v] = true if v is reachable from source c_size_t* edge_to; // edge_to[v] = last vertex on path from source to v c_size_t count; // Total number of vertices connected to source c_size_t source; // Source root vertex index c_Allocator_t allocator; // Memory allocator reference instance copy } c_NonrecursiveDFS_t; /* ------------------------------------------------------------------------------------------------------------------ */ /* */ /** * @brief Computes the vertices connected to a source vertex iteratively. * @param self Pointer to the uninitialized search state structure. * @param G Pointer to the constant target graph object to analyze. * @param s The source root vertex index. * @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_NonrecursiveDFS_Init(c_NonrecursiveDFS_t* self, const c_Graph_t* G, c_VertexId_t s, c_Allocator_t* allocator); /** * @brief Drops all internal allocation states within the search instance safely. */ void c_NonrecursiveDFS_Destroy(c_NonrecursiveDFS_t* self); /** * @brief Is there a path between the source vertex and vertex v? */ c_bool_t c_NonrecursiveDFS_HasPathTo(const c_NonrecursiveDFS_t* self, c_VertexId_t v); /** * @brief Recovers a path track from the source vertex to target v. */ c_err_t c_NonrecursiveDFS_PathTo(const c_NonrecursiveDFS_t* self, c_size_t v, c_VertexIdList_t* path); /** * @brief Returns the total number of vertices structurally connected to the source vertex. */ c_size_t c_NonrecursiveDFS_Count(const c_NonrecursiveDFS_t* self); #endif /*INCLUDED_C_NONRECURSIVEDFS_H*/