forked from beckysag/traveling-salesman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwoOpt.h
33 lines (22 loc) · 827 Bytes
/
twoOpt.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
//==================================================================
// File : twoOpt.h
// Author : rsagalyn
// Date : Aug 25, 2013
// Description : Perform optimizations on graph
//==================================================================
#ifndef MYGRAPH_H
#define MYGRAPH_H
#include <vector>
#include <stack>
#include <iostream>
//#include <cstdlib>
//#include <cmath>
using namespace std;
// Non-looping version of two-opt optimization heuristic
int twoOpt(int **graph, vector<int> &path, int &pathLength, int n);
// 2-Opt helper function: swap two nodes
int is_path_shorter(int **graph, int v1, int v2, int v3, int v4, int &total_distance);
void reverse(vector<int> &path, int start, int end, int n);
// move this to tsp class
int get_path_length(int **graph, vector<int> &path, int size);
#endif