lifo-dijkstraserv/src/dijkstragraph.h

59 lines
1.1 KiB
C
Raw Normal View History

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>
#define DIJKSTRA_WEIGHT_AUTO (-1)
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
};
/* 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);
/* 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