diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2013-12-06 15:19:35 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2013-12-06 15:19:35 +0100 |
commit | bd715870e1a688073d0a23b7f75bf2a6635f7a2b (patch) | |
tree | 9f1ea1570e5edea4bdd9200f00815d71335bb284 /src/lib/eina_graph_private.h | |
parent | ca99540270f229485e64caed4aa949e129ddf1d8 (diff) | |
download | eina_graph-bd715870e1a688073d0a23b7f75bf2a6635f7a2b.zip eina_graph-bd715870e1a688073d0a23b7f75bf2a6635f7a2b.tar.gz |
add Eina_Graph: unweighted undirected graph
Diffstat (limited to 'src/lib/eina_graph_private.h')
-rw-r--r-- | src/lib/eina_graph_private.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/lib/eina_graph_private.h b/src/lib/eina_graph_private.h index a75ed6b..75dfffb 100644 --- a/src/lib/eina_graph_private.h +++ b/src/lib/eina_graph_private.h @@ -60,4 +60,42 @@ extern int _eina_graph_log_dom; #endif #define DBG(...) EINA_LOG_DOM_DBG(_eina_graph_log_dom, __VA_ARGS__) +typedef struct _Eina_Graph_Adjacents +{ + unsigned int *data; + unsigned int total; + unsigned int count; +} Eina_Graph_Adjacents; + +static inline void +eina_graph_adjacents_free(Eina_Graph_Adjacents *adjs) +{ + if (adjs->data) + free(adjs->data); + adjs->data = NULL; +} + +Eina_Bool +_eina_graph_adjacents_grow(Eina_Graph_Adjacents *adjs, unsigned int step); + +static inline Eina_Bool +eina_graph_adjacents_push(Eina_Graph_Adjacents *adjs, unsigned int v, unsigned int step) +{ + if (EINA_UNLIKELY((adjs->count + 1) > adjs->total)) + if (!_eina_graph_adjacents_grow(adjs, step)) + return EINA_FALSE; + + adjs->data[adjs->count++] = v; + + return EINA_TRUE; +} + +typedef struct _Eina_Graph +{ + unsigned int vertices; + unsigned int edges; + unsigned int step; + Eina_Graph_Adjacents *adjs; +} _Eina_Graph; + #endif /* _EINA_GRAPH_PRIVATE_H */ |