#ifndef INCLUDED_GRAPH_H #define INCLUDED_GRAPH_H #include #include #include #include #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