-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPoint.h
More file actions
76 lines (60 loc) · 1.22 KB
/
Copy pathPoint.h
File metadata and controls
76 lines (60 loc) · 1.22 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef POINT_H
#define POINT_H
#include <vector>
using namespace std;
class Point{
public:
int ID; //Point index
int name; //Point real name
double* Data; //Point coordinate
int Layer; //Point layer
vector<Point*> Parents; //all parents of point
double ManhattanDist;
Point(int id, double* data){
ID = id;
name = id;
Data = data;
}
Point(int id, double* data, int dim, double* coor0){
ID = id;
Data = data;
ManhattanDist = GetManhattanDist(dim, coor0, data);
}
static double GetManhattanDist(int dim, double* coor1, double* coor2){
double dist = 0;
for (int i = 0; i < dim; i++)
{
dist += fabs(coor2[i]-coor1[i]);
}
return dist;
}
static double* CopyCoor(int dim, double* coor){
double* newCoor = new double[dim];
for (int i = 0; i < dim; i++)
{
newCoor[i]=coor[i];
}
return newCoor;
}
Point(){};
~Point(){
delete Data;
}
};
/***
** desc: 方法用于对于vector中的Point根据ID进行降序排列
**
*/
bool SortByIDDesc( Point*v1, Point *v2)
{
return v1->ID > v2->ID;
}
/***
** desc: 方法用于对于vector中的Point根据ID进行升序排列
**
*/
bool SortByIDAsc( Point*v1, Point *v2)
{
return v1->ID < v2->ID;
}
#endif