PGROUTING
3.2
compPaths.cpp
Go to the documentation of this file.
1
/*PGR-GNU*****************************************************************
2
File: compPaths.cpp
3
4
Generated with Template by:
5
Copyright (c) 2015 pgRouting developers
6
Mail:
[email protected]
7
8
Function's developer:
9
Copyright (c) 2017 Vidhan Jain
10
Mail:
[email protected]
11
12
------
13
14
This program is free software; you can redistribute it and/or modify
15
it under the terms of the GNU General Public License as published by
16
the Free Software Foundation; either version 2 of the License, or
17
(at your option) any later version.
18
19
This program is distributed in the hope that it will be useful,
20
but WITHOUT ANY WARRANTY; without even the implied warranty of
21
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
GNU General Public License for more details.
23
24
You should have received a copy of the GNU General Public License
25
along with this program; if not, write to the Free Software
26
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27
28
********************************************************************PGR-GNU*/
29
30
#include <cmath>
31
#include <limits>
32
33
#include "
cpp_common/pgr_assert.h
"
34
#include "
cpp_common/compPaths.h
"
35
#include "
cpp_common/basePath_SSEC.hpp
"
36
37
38
namespace
pgrouting
{
39
40
bool
compPathsLess::operator()
(
const
Path
&p1,
const
Path
&p2)
const
{
41
/*
42
* less cost is best
43
*/
44
if
(!(std::fabs(p2.
tot_cost
() - p1.
tot_cost
())
45
<
46
std::numeric_limits<double>::epsilon())) {
47
if
(p1.
tot_cost
() > p2.
tot_cost
())
48
return
false
;
49
if
(p1.
tot_cost
() < p2.
tot_cost
())
50
return
true
;
51
}
52
53
// paths costs are equal now check by length
54
if
(p1.
size
() > p2.
size
())
55
return
false
;
56
if
(p1.
size
() < p2.
size
())
57
return
true
;
58
59
// pgassert(p1.tot_cost() == p2.tot_cost());
60
pgassert
(p1.
size
() == p2.
size
());
61
62
// paths weights & lengths are equal now check by node ID
63
unsigned
int
i;
64
for
(i = 0; i < p1.
size
(); i++) {
65
if
(p1[i].node > p2[i].node)
66
return
false
;
67
if
(p1[i].node < p2[i].node)
68
return
true
;
69
}
70
71
// pgassert(p1.tot_cost() == p2.tot_cost());
72
pgassert
(p1.
size
() == p2.
size
());
73
#ifdef NDEBUG
74
for
(i = 0; i < p1.
size
(); i++) {
75
pgassert
(p1[i].node == p2[i].node);
76
}
77
#endif
78
79
// we got here and everything is equal
80
return
false
;
81
}
82
83
}
// namespace pgrouting
Path
Definition:
basePath_SSEC.hpp:47
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition:
pgr_assert.h:94
compPaths.h
pgr_assert.h
An assert functionality that uses C++ throw().
pgrouting::compPathsLess::operator()
bool operator()(const Path &p1, const Path &p2) const
Definition:
compPaths.cpp:40
Path::size
size_t size() const
Definition:
basePath_SSEC.hpp:71
pgrouting
Book keeping class for swapping orders between vehicles.
Definition:
pgr_alphaShape.cpp:56
Path::tot_cost
double tot_cost() const
Definition:
basePath_SSEC.hpp:69
basePath_SSEC.hpp
src
cpp_common
compPaths.cpp
Generated on Tue May 25 2021 15:09:47 for PGROUTING by
1.8.17