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
|
#ifndef INCLUDED_GRAPH_H
#define INCLUDED_GRAPH_H
#include <stdlib.h>
#include <stdbool.h>
#include <gsl/gsl_matrix.h>
#include <raylib.h>
#include "distribution.h"
enum graph_type {
GRAPH_TYPE_NONE,
GRAPH_TYPE_POSITIVE = 1 << 0,
GRAPH_TYPE_NEGATIVE = 1 << 1,
GRAPH_TYPE_POSITIVE_NEGATIVE = GRAPH_TYPE_POSITIVE | GRAPH_TYPE_NEGATIVE,
};
struct edge {
size_t from;
size_t to;
};
struct edges {
struct edge *items;
size_t count;
size_t capacity;
};
typedef struct graph {
enum graph_type type;
size_t vertex_count;
gsl_matrix *adjecency_matrix;
gsl_matrix *weight_matrix;
gsl_matrix *capacity_matrix;
size_t *highlighted_path;
struct edges highlighted_edges;
} *GRAPH;
void generate_graph (GRAPH, DISTRIBUTION,
size_t vertex_count, enum graph_type);
void graph_unhighlight (GRAPH g);
void graph_edge_set (GRAPH, size_t from, size_t to,
double weight, double capacity);
void print_graph (GRAPH);
void highlight_graph (GRAPH, const gsl_matrix *);
// lab 1
gsl_matrix *shimbell_method (GRAPH, size_t edge_count, bool max);
size_t graph_count_routes (GRAPH, size_t from, size_t to);
// lab 2
size_t *dijkstra_positive (GRAPH, size_t from, size_t to, bool max);
size_t *floyd_warshall (GRAPH, size_t from, size_t to, bool max);
// lab 3
double max_flow_ford_fulkerson (GRAPH, size_t from, size_t to);
double min_cost_flow (GRAPH, size_t from, size_t to, double required_flow);
// lab 4
size_t count_spanning_trees (GRAPH);
gsl_matrix *min_weight_spannig_tree_prim (GRAPH);
gsl_matrix *min_weight_spannig_tree_boruvka (GRAPH);
void prufer_code (gsl_matrix *);
// lab 5
bool is_graph_eulerian (GRAPH);
bool is_graph_hamiltonian (GRAPH);
void graph_ensure_eulerian (GRAPH);
void graph_ensure_hamiltonian (GRAPH);
void find_hamiltonian_cycles (GRAPH);
#endif
|