2023-07-31 11:21:22 +09:30
|
|
|
#ifndef LIGHTNING_PLUGINS_RENEPAY_DIJKSTRA_H
|
|
|
|
#define LIGHTNING_PLUGINS_RENEPAY_DIJKSTRA_H
|
|
|
|
#include "config.h"
|
|
|
|
#include <ccan/short_types/short_types.h>
|
|
|
|
#include <ccan/tal/tal.h>
|
|
|
|
#include <gheap.h>
|
|
|
|
|
|
|
|
/* Allocation of resources for the heap. */
|
2023-07-31 11:21:25 +09:30
|
|
|
struct dijkstra *dijkstra_new(const tal_t *ctx, size_t max_num_nodes);
|
2023-07-31 11:21:22 +09:30
|
|
|
|
|
|
|
/* Initialization of the heap for a new Dijkstra search. */
|
2023-07-31 11:21:25 +09:30
|
|
|
void dijkstra_init(struct dijkstra *dijkstra);
|
2023-07-31 11:21:22 +09:30
|
|
|
|
|
|
|
/* Inserts a new element in the heap. If node_idx was already in the heap then
|
|
|
|
* its distance value is updated. */
|
2023-07-31 11:21:25 +09:30
|
|
|
void dijkstra_update(struct dijkstra *dijkstra, u32 node_idx, s64 distance);
|
2023-07-31 11:21:22 +09:30
|
|
|
|
2023-07-31 11:21:25 +09:30
|
|
|
u32 dijkstra_top(const struct dijkstra *dijkstra);
|
|
|
|
bool dijkstra_empty(const struct dijkstra *dijkstra);
|
|
|
|
void dijkstra_pop(struct dijkstra *dijkstra);
|
2023-07-31 11:21:22 +09:30
|
|
|
|
2023-07-31 11:21:25 +09:30
|
|
|
const s64* dijkstra_distance_data(const struct dijkstra *dijkstra);
|
2023-07-31 11:21:22 +09:30
|
|
|
|
|
|
|
/* Number of elements on the heap. */
|
2023-07-31 11:21:25 +09:30
|
|
|
size_t dijkstra_size(const struct dijkstra *dijkstra);
|
2023-07-31 11:21:22 +09:30
|
|
|
|
|
|
|
/* Maximum number of elements the heap can host */
|
2023-07-31 11:21:25 +09:30
|
|
|
size_t dijkstra_maxsize(const struct dijkstra *dijkstra);
|
2023-07-31 11:21:22 +09:30
|
|
|
|
|
|
|
#endif /* LIGHTNING_PLUGINS_RENEPAY_DIJKSTRA_H */
|