-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGraphElements.h
92 lines (78 loc) · 1.86 KB
/
GraphElements.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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
///////////////////////////////////////////////////////////////////////////////
/// GraphElements.h
/// <TODO: insert file description here>
///
/// @remarks <TODO: insert remarks here>
///
/// @author Yan Qi @date 5/28/2010
///
/// $Id: GraphElements.h 65 2010-09-08 06:48:36Z yan.qi.asu $
///////////////////////////////////////////////////////////////////////////////
#ifndef __GraphElements_h
#define __GraphElements_h
#include <string>
#include <iostream>
template<class T>
class WeightGreater
{
public:
// Determine priority.
bool operator()(const T& a, const T& b) const
{
return a.Weight() > b.Weight();
}
bool operator()(const T* a, const T* b) const
{
return a->Weight() > b->Weight();
}
};
template<class T>
class WeightLess
{
public:
// Determine priority.
bool operator()(const T& a, const T& b) const
{
return a.Weight() < b.Weight();
}
bool operator()(const T* a, const T* b) const
{
return a->Weight() < b->Weight();
}
};
//////////////////////////////////////////////////////////////////////////
// A class for the object deletion
//////////////////////////////////////////////////////////////////////////
template<class T>
class DeleteFunc
{
public:
void operator()(const T* it) const
{
delete it;
}
};
/**************************************************************************
* BaseVertex
* <TODO: insert class description here>
*
*
* @remarks <TODO: insert remarks here>
*
* @author Yan Qi @date 6/6/2010
**************************************************************************/
class BaseVertex
{
size_t m_nID;
double m_dWeight;
public:
size_t getID() const { return m_nID; }
void setID(size_t ID_) { m_nID = ID_; }
double Weight() const { return m_dWeight; }
void Weight(double val) { m_dWeight = val; }
void PrintOut(std::ostream& out_stream)
{
out_stream << m_nID;
}
};
#endif