diff options
Diffstat (limited to 'src/graph.h')
| -rw-r--r-- | src/graph.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/graph.h b/src/graph.h new file mode 100644 index 0000000..f55e975 --- /dev/null +++ b/src/graph.h | |||
| @@ -0,0 +1,71 @@ | |||
| 1 | #ifndef INCLUDED_GRAPH_H | ||
| 2 | #define INCLUDED_GRAPH_H | ||
| 3 | |||
| 4 | #include <stdlib.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | #include <gsl/gsl_matrix.h> | ||
| 7 | #include <raylib.h> | ||
| 8 | #include "distribution.h" | ||
| 9 | |||
| 10 | enum graph_type { | ||
| 11 | GRAPH_TYPE_NONE, | ||
| 12 | GRAPH_TYPE_POSITIVE = 1 << 0, | ||
| 13 | GRAPH_TYPE_NEGATIVE = 1 << 1, | ||
| 14 | GRAPH_TYPE_POSITIVE_NEGATIVE = GRAPH_TYPE_POSITIVE | GRAPH_TYPE_NEGATIVE, | ||
| 15 | }; | ||
| 16 | |||
| 17 | struct edge { | ||
| 18 | size_t from; | ||
| 19 | size_t to; | ||
| 20 | }; | ||
| 21 | |||
| 22 | struct edges { | ||
| 23 | struct edge *items; | ||
| 24 | size_t count; | ||
| 25 | size_t capacity; | ||
| 26 | }; | ||
| 27 | |||
| 28 | typedef struct graph { | ||
| 29 | enum graph_type type; | ||
| 30 | size_t vertex_count; | ||
| 31 | gsl_matrix *adjecency_matrix; | ||
| 32 | gsl_matrix *weight_matrix; | ||
| 33 | gsl_matrix *capacity_matrix; | ||
| 34 | size_t *highlighted_path; | ||
| 35 | struct edges highlighted_edges; | ||
| 36 | } *GRAPH; | ||
| 37 | |||
| 38 | void generate_graph (GRAPH, DISTRIBUTION, | ||
| 39 | size_t vertex_count, enum graph_type); | ||
| 40 | void graph_unhighlight (GRAPH g); | ||
| 41 | void graph_edge_set (GRAPH, size_t from, size_t to, | ||
| 42 | double weight, double capacity); | ||
| 43 | void print_graph (GRAPH); | ||
| 44 | void highlight_graph (GRAPH, const gsl_matrix *); | ||
| 45 | |||
| 46 | // lab 1 | ||
| 47 | gsl_matrix *shimbell_method (GRAPH, size_t edge_count, bool max); | ||
| 48 | size_t graph_count_routes (GRAPH, size_t from, size_t to); | ||
| 49 | |||
| 50 | // lab 2 | ||
| 51 | size_t *dijkstra_positive (GRAPH, size_t from, size_t to, bool max); | ||
| 52 | size_t *floyd_warshall (GRAPH, size_t from, size_t to, bool max); | ||
| 53 | |||
| 54 | // lab 3 | ||
| 55 | double max_flow_ford_fulkerson (GRAPH, size_t from, size_t to); | ||
| 56 | double min_cost_flow (GRAPH, size_t from, size_t to, double required_flow); | ||
| 57 | |||
| 58 | // lab 4 | ||
| 59 | size_t count_spanning_trees (GRAPH); | ||
| 60 | gsl_matrix *min_weight_spannig_tree_prim (GRAPH); | ||
| 61 | gsl_matrix *min_weight_spannig_tree_boruvka (GRAPH); | ||
| 62 | void prufer_code (gsl_matrix *); | ||
| 63 | |||
| 64 | // lab 5 | ||
| 65 | bool is_graph_eulerian (GRAPH); | ||
| 66 | bool is_graph_hamiltonian (GRAPH); | ||
| 67 | void graph_ensure_eulerian (GRAPH); | ||
| 68 | void graph_ensure_hamiltonian (GRAPH); | ||
| 69 | void find_hamiltonian_cycles (GRAPH); | ||
| 70 | |||
| 71 | #endif | ||
