rework: changed to basic implementation for dijkstra
This commit is contained in:
@@ -9,6 +9,8 @@ typedef struct Edge Edge;
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GRAPH_OK,
|
GRAPH_OK,
|
||||||
|
GRAPH_BAD_ALLOC,
|
||||||
|
GRAPH_NOT_FOUND,
|
||||||
} GraphErr ;
|
} GraphErr ;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -16,5 +18,18 @@ typedef enum {
|
|||||||
GRAPH_UNDIRECTED,
|
GRAPH_UNDIRECTED,
|
||||||
} GraphType;
|
} GraphType;
|
||||||
|
|
||||||
|
Graph *graph_create(GraphType type);
|
||||||
|
GraphErr graph_destroy(Graph *graph);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,19 +4,15 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
struct Vertex {
|
struct Vertex {
|
||||||
void *data;
|
|
||||||
ArrayList *edges;
|
ArrayList *edges;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Edge {
|
struct Edge {
|
||||||
size_t *to;
|
size_t to;
|
||||||
intmax_t weight;
|
size_t weight;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Graph {
|
struct Graph {
|
||||||
ArrayList *vertices;
|
ArrayList *vertices;
|
||||||
GraphType type;
|
GraphType type;
|
||||||
|
|
||||||
int (*cmp)(const void*, const void*);
|
|
||||||
void (*free_data)(void*);
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user