Graph Convolutional Branch and Bound v1.0.0
A TSP solver that combines a graph convolutional network with a 1-Tree branch-and-bound.
Loading...
Searching...
No Matches
graph.h
Go to the documentation of this file.
1
14#ifndef BRANCHANDBOUND_1TREE_GRAPH_H
15#define BRANCHANDBOUND_1TREE_GRAPH_H
19#include "../problem_settings.h"
20
21
23typedef enum GraphKind{
27
28
30typedef struct Node {
31 double x;
32 double y;
33 unsigned short positionInGraph;
34 unsigned short num_neighbours;
35 unsigned short neighbours [MAX_VERTEX_NUM - 1];
37
38
40typedef struct Edge {
41 unsigned short src;
42 unsigned short dest;
43 unsigned short symbol;
44 double weight;
45 double prob;
46 unsigned short positionInGraph;
48
49
51typedef struct Graph {
53 double cost;
54 unsigned short num_nodes;
55 unsigned short num_edges;
57 Node nodes [MAX_VERTEX_NUM];
59 Edge edges_matrix [MAX_VERTEX_NUM] [MAX_VERTEX_NUM];
61
62
70void create_graph(Graph* graph, List * nodes, List * edges, GraphKind kind);
71
72
78void create_euclidean_graph(Graph * graph, List * nodes);
79
80
85void print_graph(const Graph * graph);
86
87
88#endif //BRANCHANDBOUND_1TREE_GRAPH_H
void create_graph(Graph *graph, List *nodes, List *edges, GraphKind kind)
Create a new instance of a Graph with all the needed parameters.
Definition: graph.c:18
void print_graph(const Graph *graph)
Print Nodes, Edges and other information of the Graph.
Definition: graph.c:101
GraphKind
Enum to specify the kind of the Graph.
Definition: graph.h:23
@ WEIGHTED_GRAPH
The Graph is weighted.
Definition: graph.h:24
@ UNWEIGHTED_GRAPH
The Graph is unweighted.
Definition: graph.h:25
void create_euclidean_graph(Graph *graph, List *nodes)
Create a new instance of an euclidean graphs only the Nodes are necessary.
Definition: graph.c:71
The declaration of the functions to manipulate the List.
The declaration of the functions to manipulate the ListIterator.
#define MAX_EDGES_NUM
The maximum number of edges in the Graph.
Structure of an Edge.
Definition: graph.h:40
unsigned short dest
ID of the destination vertex.
Definition: graph.h:42
unsigned short src
ID of the source vertex.
Definition: graph.h:41
double prob
Probability of the Edge to be in an optimal tour.
Definition: graph.h:45
double weight
Weight of the Edge, 1 if the data_structures is not weighted.
Definition: graph.h:44
unsigned short symbol
Symbol of the Edge, i.e. its unique ID.
Definition: graph.h:43
unsigned short positionInGraph
Position of the Edge in the list of Edges of the Graph.
Definition: graph.h:46
Structure of a Graph.
Definition: graph.h:51
Edge edges_matrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM]
Adjacency matrix of the Graph.
Definition: graph.h:59
unsigned short num_edges
Number of Edges in the Graph.
Definition: graph.h:55
bool orderedEdges
True if the Edges are ordered by weight, false otherwise.
Definition: graph.h:56
Edge edges[MAX_EDGES_NUM]
Array of Edges.
Definition: graph.h:58
GraphKind kind
Type of the Graph.
Definition: graph.h:52
Node nodes[MAX_VERTEX_NUM]
Array of Nodes.
Definition: graph.h:57
double cost
Sum of the weights of the Edges in the Graph.
Definition: graph.h:53
unsigned short num_nodes
Number of Nodes in the Graph.
Definition: graph.h:54
The double linked list.
Definition: linked_list.h:35
Structure of a Node.
Definition: graph.h:30
double x
x coordinate of the Node.
Definition: graph.h:31
double y
y coordinate of the Node.
Definition: graph.h:32
unsigned short num_neighbours
Number of neighbours of the Node.
Definition: graph.h:34
unsigned short positionInGraph
Position of the Node in the list of Nodes of the Graph, i.e. its unique ID.
Definition: graph.h:33
unsigned short neighbours[MAX_VERTEX_NUM - 1]
Array of IDs of the Node's neighbors.
Definition: graph.h:35