61 lines
1.2 KiB
C
61 lines
1.2 KiB
C
#ifndef DIJKSTRAGRAPH_H
|
|
#define DIJKSTRAGRAPH_H
|
|
|
|
#include <glib.h>
|
|
|
|
#define DIJKSTRA_WEIGHT_AUTO (-1)
|
|
|
|
typedef int dijkstra_cost;
|
|
#define DIJKSTRA_COST_MAX INT_MAX
|
|
#define DIJKSTRA_COST_MIN 1.0
|
|
|
|
struct dijkstra_solver {
|
|
GList *nodes;
|
|
GList *paths;
|
|
};
|
|
|
|
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;
|
|
|
|
int uid;
|
|
};
|
|
|
|
/* User Functions */
|
|
struct dijkstra_path *dijkstra_path_new_to_list(struct dijkstra_solver *solver,
|
|
float x1,
|
|
float y1,
|
|
float x2,
|
|
float y2,
|
|
char *name,
|
|
dijkstra_cost weight);
|
|
|
|
struct dijkstra_solver *dijkstra_solver_new();
|
|
void dijkstra_solver_free(struct dijkstra_solver *solver);
|
|
|
|
/* Library functions */
|
|
struct dijkstra_node *dijkstra_node_get_connection(struct dijkstra_node *node,
|
|
struct dijkstra_path *path);
|
|
struct dijkstra_node *dijkstra_node_find_closest_node(struct dijkstra_solver *solver,
|
|
struct position *position);
|
|
|
|
/* For debugging only */
|
|
struct dijkstra_node *dijkstra_node_new_to_list(GList **list,
|
|
float x,
|
|
float y);
|
|
|
|
#endif // DIJKSTRAGRAPH_H
|