-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgraph.h
78 lines (61 loc) · 1.83 KB
/
graph.h
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef GRAPH_H
#define GRAPH_H
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <assert.h>
#include "io_handling.h"
/* Structs */
struct node_t {
int node_idx;
float latitude;
float longitude;
struct edge_t *first_edge;
struct prev_t *d;
int code;
char *name;
};
struct prev_t {
int dist;
struct node_t *prev;
};
struct node_info_t {
int node_idx;
int total_cost;
};
struct edge_t {
struct edge_t *next_edge;
struct node_t *to_node;
int cost;
};
struct graph_t {
struct node_t *n_list;
int node_count;
int edge_count;
};
/* Methods */
/* Method to print a graph. */
void graph_print(struct graph_t *graph);
/* Method to add a position of interest to a graph. */
void graph_insert_poi(struct graph_t *graph, int node_idx, int node_code, char* name);
/* Method to add a node to a graph. */
void graph_insert_node(struct graph_t *graph, int node_idx, float latitude, float longitude);
/* Method to add an edge to a graph */
void graph_insert_edge(struct graph_t *graph, int from_idx, int to_idx, int cost);
/* Method to free graph and all nodes and edges. */
void graph_free(struct graph_t *graph);
/* Method to parse nodes into graph from file. */
/* Return true if an error occurs. */
bool parse_node_file(char *file_name, struct graph_t *graph);
/* Method to parse edges into graph from file. */
/* Return true if an error occurs. */
bool parse_edge_file(char *file_name, struct graph_t *graph);
/* Method to parse points of interest into graph from file. */
/* Return true if an error occurs. */
bool parse_poi_file(char *file_name, struct graph_t *graph);
/* Method for transposing a graph. */
struct graph_t *graph_transpose(struct graph_t *graph);
/* Method for copying a graph. */
struct graph_t *graph_copy(struct graph_t *graph);
#endif