Main Page
Namespaces
Classes
Files
File List
File Members
src
NNH.c
Go to the documentation of this file.
1
#include "
LKH.h
"
2
3
int
NNH
()
4
{
5
Node
*From, *To, *Start, *
NN
;
6
int
Max = INT_MIN, Min, Visited = 0,
D
, i;
7
8
for
(i = 2; i <=
DimensionSaved
; i++)
9
NodeSet
[i].V = 0;
10
Start = From = &
NodeSet
[1];
11
while
(++Visited <
DimensionSaved
) {
12
From->
V
= 1;
13
Min = INT_MAX;
14
NN = 0;
15
for
(i = 2; i <=
DimensionSaved
; i++) {
16
To = &
NodeSet
[i];
17
if
(!To->
V
&&
18
(
D
=
ProblemType
!=
ATSP
?
Distance
(From, To) :
19
From->
C
[To->
Id
]) < Min) {
20
Min =
D
;
21
NN = To;
22
}
23
}
24
From =
NN
;
25
if
(Min > Max)
26
Max = Min;
27
}
28
D
=
ProblemType
!=
ATSP
?
Distance
(From, Start) : From->
C
[Start->
Id
];
29
if
(
D
> Max)
30
Max =
D
;
31
return
Max;
32
}
D
CostFunction D
Definition:
LKH.h:304
Node
Definition:
LKH.h:68
Node::Id
int Id
Definition:
LKH.h:69
Distance
CostFunction Distance
Definition:
LKH.h:304
NodeSet
Node * NodeSet
Definition:
LKH.h:235
ATSP
Definition:
LKH.h:41
DimensionSaved
int DimensionSaved
Definition:
LKH.h:191
LKH.h
Node::C
int * C
Definition:
LKH.h:88
Node::V
int V
Definition:
LKH.h:75
ProblemType
int ProblemType
Definition:
LKH.h:290
NN
Definition:
LKH.h:51
NNH
int NNH()
Definition:
NNH.c:3
glkh_solver
Author(s): Francisco Suarez-Ruiz
autogenerated on Mon Jun 10 2019 13:50:26