2026-05-06 09:45:22 -06:00
|
|
|
#ifndef GRAPH_H
|
|
|
|
|
#define GRAPH_H
|
|
|
|
|
|
2026-05-06 11:29:28 -06:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
typedef struct Graph Graph;
|
|
|
|
|
typedef struct Vertex Vertex;
|
|
|
|
|
typedef struct Edge Edge;
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
GRAPH_OK,
|
2026-05-06 19:58:33 -06:00
|
|
|
GRAPH_BAD_ALLOC,
|
2026-05-06 20:20:45 -06:00
|
|
|
GRAPH_VERTEX_NOT_FOUND,
|
|
|
|
|
GRAPH_NULL_ARG,
|
2026-05-06 11:29:28 -06:00
|
|
|
} GraphErr ;
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
|
GRAPH_DIRECTED,
|
|
|
|
|
GRAPH_UNDIRECTED,
|
|
|
|
|
} GraphType;
|
2026-05-06 09:45:22 -06:00
|
|
|
|
2026-05-06 19:58:33 -06:00
|
|
|
Graph *graph_create(GraphType type);
|
2026-05-06 20:20:45 -06:00
|
|
|
GraphErr graph_destroy(Graph **graph);
|
2026-05-06 19:58:33 -06:00
|
|
|
|
|
|
|
|
GraphErr graph_add_vertex(Graph *graph);
|
|
|
|
|
|
|
|
|
|
GraphErr graph_connect_vertex(
|
|
|
|
|
Graph *graph,
|
|
|
|
|
size_t node1,
|
|
|
|
|
size_t node2,
|
|
|
|
|
size_t weight);
|
|
|
|
|
|
|
|
|
|
GraphErr graph_vertex_count(size_t *out);
|
|
|
|
|
GraphErr graph_get_vertex(Graph *graph, size_t index, Vertex *out);
|
2026-05-06 09:45:22 -06:00
|
|
|
|
|
|
|
|
#endif
|