2020-05-02 17:02:26 +02:00
|
|
|
#ifndef DIJKSTRAGRAPH_H
|
|
|
|
#define DIJKSTRAGRAPH_H
|
2020-05-01 20:48:36 +02:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
2020-05-02 17:13:27 +02:00
|
|
|
#define DIJKSTRA_WEIGHT_AUTO (-1)
|
|
|
|
|
2020-05-03 00:00:41 +02:00
|
|
|
typedef int dijkstra_cost;
|
|
|
|
#define DIJKSTRA_COST_MAX INT_MAX
|
|
|
|
#define DIJKSTRA_COST_MIN 1.0
|
2020-05-01 20:48:36 +02:00
|
|
|
|
2020-05-02 16:51:12 +02:00
|
|
|
struct dijkstra_solver {
|
|
|
|
GList *nodes;
|
|
|
|
GList *paths;
|
|
|
|
};
|
|
|
|
|
2020-05-01 20:48:36 +02:00
|
|
|
struct position {
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct dijkstra_path {
|
|
|
|
struct dijkstra_node *source;
|
|
|
|
struct dijkstra_node *destination;
|
|
|
|
char *name;
|
|
|
|
dijkstra_cost weight;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct dijkstra_node {
|
|
|
|
struct position position;
|
|
|
|
|
|
|
|
GList *paths;
|
|
|
|
|
2020-05-02 16:51:12 +02:00
|
|
|
int uid;
|
2020-05-01 20:48:36 +02:00
|
|
|
};
|
|
|
|
|
2020-05-03 00:00:41 +02:00
|
|
|
/* User Functions */
|
2020-05-02 16:51:12 +02:00
|
|
|
struct dijkstra_path *dijkstra_path_new_to_list(struct dijkstra_solver *solver,
|
2020-05-01 20:48:36 +02:00
|
|
|
float x1,
|
|
|
|
float y1,
|
|
|
|
float x2,
|
|
|
|
float y2,
|
|
|
|
char *name,
|
|
|
|
dijkstra_cost weight);
|
2020-05-02 16:51:12 +02:00
|
|
|
|
|
|
|
struct dijkstra_solver *dijkstra_solver_new();
|
|
|
|
void dijkstra_solver_free(struct dijkstra_solver *solver);
|
|
|
|
|
2020-05-03 00:00:41 +02:00
|
|
|
/* Library functions */
|
|
|
|
struct dijkstra_node *dijkstra_node_get_connection(struct dijkstra_node *node,
|
|
|
|
struct dijkstra_path *path);
|
|
|
|
|
|
|
|
/* For debugging only */
|
|
|
|
struct dijkstra_node *dijkstra_node_new_to_list(GList **list,
|
|
|
|
float x,
|
|
|
|
float y);
|
|
|
|
|
2020-05-02 17:02:26 +02:00
|
|
|
#endif // DIJKSTRAGRAPH_H
|