2026-09-05 13:36:43 +08:00
|
|
|
#ifndef INCLUDED_C_GRAPH_H
|
|
|
|
|
#define INCLUDED_C_GRAPH_H
|
|
|
|
|
|
|
|
|
|
#ifndef INCLUDED_C_ADJLIST_H
|
|
|
|
|
#include <c_AdjList.h>
|
|
|
|
|
#endif /*INCLUDED_C_ADJLIST_H*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
|
|
|
|
/* */
|
|
|
|
|
|
2026-09-07 18:48:16 +08:00
|
|
|
typedef c_uint_t c_VertexId_t;
|
|
|
|
|
|
2026-09-05 13:36:43 +08:00
|
|
|
typedef struct {
|
|
|
|
|
c_size_t V;
|
|
|
|
|
c_size_t E;
|
|
|
|
|
c_AdjList_t* adj_list;
|
|
|
|
|
c_Allocator_t allocator;
|
|
|
|
|
}c_Graph_t;
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
|
|
|
|
/* */
|
|
|
|
|
|
|
|
|
|
c_err_t c_Graph_Init(c_Graph_t* self, c_size_t V, c_Allocator_t* allocator);
|
|
|
|
|
|
|
|
|
|
void c_Graph_Destroy(c_Graph_t* self);
|
|
|
|
|
|
2026-09-07 18:48:16 +08:00
|
|
|
c_err_t c_Graph_AddEdge(c_Graph_t* self, c_VertexId_t v, c_VertexId_t w);
|
2026-09-05 13:36:43 +08:00
|
|
|
|
2026-09-07 18:48:16 +08:00
|
|
|
c_err_t c_Graph_RemoveEdge(c_Graph_t* self, c_VertexId_t v, c_VertexId_t w);
|
2026-09-05 13:36:43 +08:00
|
|
|
|
2026-09-07 18:48:16 +08:00
|
|
|
c_bool_t c_Graph_HasEdge(const c_Graph_t* self, c_VertexId_t v, c_VertexId_t w);
|
2026-09-05 13:36:43 +08:00
|
|
|
|
2026-09-07 18:48:16 +08:00
|
|
|
c_size_t c_Graph_Degree(c_Graph_t* self, c_VertexId_t v);
|
2026-09-05 13:36:43 +08:00
|
|
|
|
2026-09-07 18:48:16 +08:00
|
|
|
c_AdjList_t* c_Graph_GetAdjList(c_Graph_t* self, c_VertexId_t v);
|
2026-09-05 13:36:43 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Creates a complete deep copy of a source graph.
|
|
|
|
|
* @param dst Pointer to the target destination graph structure to initialize.
|
|
|
|
|
* @param src Pointer to the constant source graph to replicate.
|
|
|
|
|
* @param allocator Pointer to the allocator to be used by the new cloned graph.
|
|
|
|
|
* @return C_SUCCESS on success, or an error code (e.g., C_ERR_NOMEM, C_ERR_PARAM).
|
|
|
|
|
*/
|
|
|
|
|
c_err_t c_Graph_Copy(c_Graph_t* dst, const c_Graph_t* src, c_Allocator_t* allocator);
|
|
|
|
|
|
|
|
|
|
#endif /*INCLUDED_C_GRAPH_H*/
|