#ifndef JEFF_GRAPH_H #define JEFF_GRAPH_H #include /* Types */ typedef struct node { void *data; uint64_t index; } node_t; typedef struct edge { node_t *n1, *n2; void *data; uint64_t index; } edge_t; typedef struct graph { node_t **nodes; unsigned int node_count; edge_t **edges; unsigned int edge_count; } graph_t; /* Functions */ graph_t *graph_new(); void graph_free(graph_t *); edge_t *graph_edge_new(node_t *a, node_t *b, void *data); void graph_edge_free(edge_t *e); node_t *graph_node_add(graph_t *g, void *data); void graph_edge_add(graph_t *g, edge_t *edge); void graph_node_visit(graph_t *g, void *data, void (*f)(graph_t*, node_t*, void *data)); void graph_edge_visit(graph_t *g, void *data, void (*f)(graph_t*, edge_t*, void *data)); node_t *graph_node_find(graph_t *g, void *data, int (*f)(node_t *n, void *data)); edge_t *graph_edge_find(graph_t *g, void *data, int (*f)(edge_t *e, void *data)); #endif /* JEFF_GRAPH_H */