Main Page
Namespaces
Classes
Files
File List
File Members
src
Distance_SPECIAL.c
Go to the documentation of this file.
1
#include "
LKH.h
"
2
3
/*
4
* The Distance_SPECIAL function may be used to specify a user defined
5
* distance fuction. The function is used when the EDGE_WEIGHT_TYPE is
6
* SPECIAL.
7
*
8
* Example:
9
*
10
* int Distance_SPECIAL(Node * Na, Node * Nb)
11
* {
12
* double dx = Na->X - Nb->X;
13
* double dy = Na->Y - Nb->Y;
14
* return (int) (1000 * sqrt(dx * dx + dy * dy));
15
* }
16
*/
17
18
int
Distance_SPECIAL
(
Node
* Na,
Node
* Nb)
19
{
20
const
double
GridSize = 100000000;
21
double
dx = Na->
X
- Nb->
X
;
22
double
dy = Na->
Y
- Nb->
Y
;
23
if
(dx < 0)
24
dx = -dx;
25
if
(dy < 0)
26
dy = -dy;
27
if
(GridSize - dx < dx)
28
dx = GridSize - dx;
29
if
(GridSize - dy < dy)
30
dy = GridSize - dy;
31
return
(
int
) (sqrt(dx * dx + dy * dy) + 0.5);
32
}
Node::Y
double Y
Definition:
LKH.h:123
Node
Definition:
LKH.h:68
Node::X
double X
Definition:
LKH.h:123
Distance_SPECIAL
int Distance_SPECIAL(Node *Na, Node *Nb)
Definition:
Distance_SPECIAL.c:18
LKH.h
glkh_solver
Author(s): Francisco Suarez-Ruiz
autogenerated on Mon Jun 10 2019 13:50:26