-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfibonacciheap.h
More file actions
47 lines (39 loc) · 1.52 KB
/
fibonacciheap.h
File metadata and controls
47 lines (39 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef FIBONACCIHEAP_H
#define FIBONACCIHEAP_H
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include "binaryheap.h"
#define MAX_NODES 100000
#define INF INT_MAX
// Fibonacci heap node structure
typedef struct FibNode {
int vertex; // Vertex index
int distance; // Distance value (key)
int degree; // Number of child nodes
int marked; // Mark flag (for delete operation)
struct FibNode* parent; // Parent node
struct FibNode* child; // Head of child node list
struct FibNode* left; // Left sibling node
struct FibNode* right; // Right sibling node
} FibNode;
// Fibonacci heap structure
typedef struct {
FibNode* min; // Minimum node
int num_nodes; // Total number of nodes
} FibonacciHeap;
// Fibonacci heap operation functions
FibonacciHeap* create_fib_heap();
FibNode* create_fib_node(int vertex, int distance);
void fib_heap_insert(FibonacciHeap* heap, FibNode* node);
FibNode* fib_heap_extract_min(FibonacciHeap* heap);
void fib_heap_decrease_key(FibonacciHeap* heap, FibNode* node, int new_distance);
int is_fib_heap_empty(FibonacciHeap* heap);
void free_fib_heap(FibonacciHeap* heap);
// Dijkstra algorithm functions
void dijkstra_fibonacci(Graph* graph, int src, int* dist, int* prev);
void reconstruct_path(int* prev, int target, int* path, int* path_length);
int shortest_path_length_fibonacci(Graph* graph, int src, int target, int* path, int* path_length);
#endif