Graph
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#ifndef INCLUDED_C_NONRECURSIVEDIRECTEDDFS_H
|
||||
#define INCLUDED_C_NONRECURSIVEDIRECTEDDFS_H
|
||||
|
||||
#ifndef INCLUDED_C_DIGRAPH_H
|
||||
#include <c_Digraph.h>
|
||||
#endif /*INCLUDED_C_DIGRAPH_H*/
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
typedef struct {
|
||||
c_bool_t* marked; /* Visited tracking array (size of graph->V) */
|
||||
c_size_t count; /* Total number of vertices reachable from source(s) */
|
||||
c_Allocator_t allocator; /* Copied allocator from the graph for isolation */
|
||||
} c_NonrecursiveDirectedDFS_t;
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
/**
|
||||
* @brief Computes vertices reachable from a single source vertex 's' using a stack
|
||||
*/
|
||||
c_err_t c_NonrecursiveDirectedDFS_Init(c_NonrecursiveDirectedDFS_t* self, c_Digraph_t* graph, c_size_t s, c_Allocator_t* allocator);
|
||||
|
||||
/**
|
||||
* @brief Releases internal tracking buffers
|
||||
*/
|
||||
void c_NonrecursiveDirectedDFS_Destroy(c_NonrecursiveDirectedDFS_t* self);
|
||||
|
||||
/* ================================================================================================================== */
|
||||
/* Inline Query Interfaces */
|
||||
|
||||
C_STATIC_FORCE_INLINE c_bool_t c_NonrecursiveDirectedDFS_HasPathTo(c_NonrecursiveDirectedDFS_t* self, c_size_t v, c_size_t total_V) {
|
||||
if (!self || !self->marked || v >= total_V) return C_FALSE;
|
||||
return self->marked[v];
|
||||
}
|
||||
|
||||
C_STATIC_FORCE_INLINE c_size_t c_NonrecursiveDirectedDFS_GetCount(c_NonrecursiveDirectedDFS_t* self) {
|
||||
return self ? self->count : 0;
|
||||
}
|
||||
|
||||
#endif /*INCLUDED_C_NONRECURSIVEDIRECTEDDFS_H*/
|
||||
Reference in New Issue
Block a user