graph结构体node重新规划

This commit is contained in:
建峰 2025-04-25 10:47:42 +08:00
parent c661ebaea6
commit b788dd74ee

View File

@ -13,22 +13,36 @@
#include "common.h" #include "common.h"
struct _graph_node { struct _graph_edge
void *obj; {
uint32_t **edge; struct _graph_edge* _next;
uint8_t *visited; uint32_t weight;
}; };
struct _graph { struct _graph_vertex
{
void* obj;
struct _graph_edge* edge;
bool* visited;
};
struct _graph_node
{
struct _graph_vertex* edge;
};
struct _graph
{
// -------------------- private -------------------- // -------------------- private --------------------
struct _graph_node* _head; struct _graph_node* _head;
uint32_t **edges;
uint32_t _size; uint32_t _size;
uint32_t _obj_size; uint32_t _obj_size;
uint32_t _capacity; uint32_t _capacity;
uint32_t _ratio; uint32_t _ratio;
struct _iterator _iter;
void (*_destory)(struct _graph* self); void (*_destory)(struct _graph* self);
// -------------------- public -------------------- // -------------------- public --------------------
@ -48,6 +62,9 @@ struct _graph {
bool (*empty)(struct _graph* self); bool (*empty)(struct _graph* self);
bool (*full)(struct _graph* self); bool (*full)(struct _graph* self);
// iter
iterator_t (*iter)(struct _graph* self);
// others // others
bool (*from_matrix)(struct _graph* self, void* obj, uint32_t* edges, uint32_t size); bool (*from_matrix)(struct _graph* self, void* obj, uint32_t* edges, uint32_t size);