Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pgr prefix from files #2669

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*PGR-GNU*****************************************************************
File: pgr_allpairs.hpp
File: allpairs.hpp

Copyright (c) 2015 pgRouting developers
Mail: [email protected]
Expand Down Expand Up @@ -27,8 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

// http://www.cs.rpi.edu/~musser/archive/2005/gsd/restricted/FloydWarshall/FloydWarshall.pdf

#ifndef INCLUDE_ALLPAIRS_PGR_ALLPAIRS_HPP_
#define INCLUDE_ALLPAIRS_PGR_ALLPAIRS_HPP_
#ifndef INCLUDE_ALLPAIRS_ALLPAIRS_HPP_
#define INCLUDE_ALLPAIRS_ALLPAIRS_HPP_
#pragma once

#include <deque>
Expand All @@ -44,11 +44,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#include "c_types/iid_t_rt.h"
#include "cpp_common/basePath_SSEC.hpp"
#include "cpp_common/pgr_base_graph.hpp"
#include "cpp_common/base_graph.hpp"
#include "cpp_common/interruption.hpp"

// TODO(vicky) don't keep it here
#include "cpp_common/pgr_alloc.hpp"
#include "cpp_common/alloc.hpp"

namespace pgrouting {
template < class G > class Pgr_allpairs;
Expand Down Expand Up @@ -263,4 +263,4 @@ class Pgr_allpairs {

} // namespace pgrouting

#endif // INCLUDE_ALLPAIRS_PGR_ALLPAIRS_HPP_
#endif // INCLUDE_ALLPAIRS_ALLPAIRS_HPP_
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*PGR-GNU*****************************************************************
File: pgr_alphaShape.hpp
File: alphaShape.hpp

Copyright (c) 2018 pgRouting developers
Mail: [email protected]
Expand All @@ -26,8 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
********************************************************************PGR-GNU*/
/*! @file */

#ifndef INCLUDE_ALPHASHAPE_PGR_ALPHASHAPE_HPP_
#define INCLUDE_ALPHASHAPE_PGR_ALPHASHAPE_HPP_
#ifndef INCLUDE_ALPHASHAPE_ALPHASHAPE_HPP_
#define INCLUDE_ALPHASHAPE_ALPHASHAPE_HPP_
#pragma once

#ifndef __cplusplus
Expand All @@ -40,9 +40,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include <iosfwd>

#include "cpp_common/edge_xy_t.hpp"
#include "cpp_common/pgr_messages.hpp"
#include "cpp_common/messages.hpp"

#include "cpp_common/pgr_base_graph.hpp"
#include "cpp_common/base_graph.hpp"
#include "cpp_common/bline.hpp"


Expand Down Expand Up @@ -99,4 +99,4 @@ class Pgr_alphaShape : public Pgr_messages {
} // namespace alphashape
} // namespace pgrouting

#endif // INCLUDE_ALPHASHAPE_PGR_ALPHASHAPE_HPP_
#endif // INCLUDE_ALPHASHAPE_ALPHASHAPE_HPP_
8 changes: 4 additions & 4 deletions include/astar/astar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

********************************************************************PGR-GNU*/

#ifndef INCLUDE_ASTAR_PGR_ASTAR_HPP_
#define INCLUDE_ASTAR_PGR_ASTAR_HPP_
#ifndef INCLUDE_ASTAR_ASTAR_HPP_
#define INCLUDE_ASTAR_ASTAR_HPP_
#pragma once

#include <deque>
Expand All @@ -40,7 +40,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#include "visitors/astar_visitors.hpp"
#include "cpp_common/basePath_SSEC.hpp"
#include "cpp_common/pgr_base_graph.hpp"
#include "cpp_common/base_graph.hpp"
#include "cpp_common/interruption.hpp"
#include "c_types/ii_t_rt.h"

Expand Down Expand Up @@ -206,4 +206,4 @@ std::deque<Path> astar(
} // namespace algorithms
} // namespace pgrouting

#endif // INCLUDE_ASTAR_PGR_ASTAR_HPP_
#endif // INCLUDE_ASTAR_ASTAR_HPP_
8 changes: 4 additions & 4 deletions include/bdAstar/bdAstar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

********************************************************************PGR-GNU*/

#ifndef INCLUDE_BDASTAR_PGR_BDASTAR_HPP_
#define INCLUDE_BDASTAR_PGR_BDASTAR_HPP_
#ifndef INCLUDE_BDASTAR_BDASTAR_HPP_
#define INCLUDE_BDASTAR_BDASTAR_HPP_
#pragma once


#include <map>
#include <set>
#include <deque>

#include "cpp_common/pgr_bidirectional.hpp"
#include "cpp_common/bidirectional.hpp"
#include "cpp_common/basePath_SSEC.hpp"

namespace pgrouting {
Expand Down Expand Up @@ -223,4 +223,4 @@ std::deque<Path> bdastar(
} // namespace algorithms
} // namespace pgrouting

#endif // INCLUDE_BDASTAR_PGR_BDASTAR_HPP_
#endif // INCLUDE_BDASTAR_BDASTAR_HPP_
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*PGR-GNU*****************************************************************
File: pgr_bdDijkstra.hpp
File: bdDijkstra.hpp

Copyright (c) 2015 pgRouting developers
Mail: [email protected]
Expand All @@ -25,13 +25,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

********************************************************************PGR-GNU*/

#ifndef INCLUDE_BDDIJKSTRA_PGR_BDDIJKSTRA_HPP_
#define INCLUDE_BDDIJKSTRA_PGR_BDDIJKSTRA_HPP_
#ifndef INCLUDE_BDDIJKSTRA_BDDIJKSTRA_HPP_
#define INCLUDE_BDDIJKSTRA_BDDIJKSTRA_HPP_
#pragma once


#include "cpp_common/pgr_bidirectional.hpp"

#include <string>
#include <queue>
#include <utility>
Expand All @@ -40,6 +37,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include <functional>


#include "cpp_common/bidirectional.hpp"
#include "cpp_common/basePath_SSEC.hpp"


Expand Down Expand Up @@ -145,4 +143,4 @@ class Pgr_bdDijkstra : public Pgr_bidirectional<G> {
} // namespace bidirectional
} // namespace pgrouting

#endif // INCLUDE_BDDIJKSTRA_PGR_BDDIJKSTRA_HPP_
#endif // INCLUDE_BDDIJKSTRA_BDDIJKSTRA_HPP_
185 changes: 185 additions & 0 deletions include/bellman_ford/bellman_ford.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/*PGR-GNU*****************************************************************
File: bellman_ford.hpp

Copyright (c) 2015 pgRouting developers
Mail: [email protected]

Copyright (c) 2018 Sourabh Garg
Mail to: [email protected]

------

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

********************************************************************PGR-GNU*/

#ifndef INCLUDE_BELLMAN_FORD_BELLMAN_FORD_HPP_
#define INCLUDE_BELLMAN_FORD_BELLMAN_FORD_HPP_
#pragma once

#include <deque>
#include <set>
#include <vector>
#include <algorithm>
#include <sstream>
#include <string>
#include <functional>
#include <limits>
#include <map>
#include <boost/config.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/bellman_ford_shortest_paths.hpp>
#include "cpp_common/messages.hpp"
#include "cpp_common/basePath_SSEC.hpp"
#include "cpp_common/base_graph.hpp"
#include "cpp_common/interruption.hpp"
#include "c_types/ii_t_rt.h"

namespace pgrouting {

template < class G >
class Pgr_bellman_ford : public pgrouting::Pgr_messages {
public:
typedef typename G::V V;
typedef typename G::E E;
//@{



/** @brief bellman_ford one to a set of many
* @todo document this function
*/

std::deque<Path> bellman_ford(
G &graph,
int64_t start_vertex,
const std::set<int64_t> &end_vertex,
bool only_cost = false) {
// adjust predecessors and distances vectors
clear();
predecessors.resize(graph.num_vertices());
distances.resize(graph.num_vertices());

// get the graphs source and targets
if (!graph.has_vertex(start_vertex)) return std::deque<Path>();
auto v_source(graph.get_V(start_vertex));

std::set<V> s_v_targets;
for (const auto &vertex : end_vertex) {
if (graph.has_vertex(vertex)) {
s_v_targets.insert(graph.get_V(vertex));
}
}

std::vector<V> v_targets(s_v_targets.begin(), s_v_targets.end());
// perform the algorithm
bellman_ford_1_to_many(graph, v_source);

// get the results // route id are the targets
auto paths = get_paths(graph, v_source, v_targets, only_cost);

std::stable_sort(paths.begin(), paths.end(),
[](const Path &e1, const Path &e2)->bool {
return e1.end_id() < e2.end_id();
});

return paths;
}


/** @brief BellmanFord combinations **/
std::deque<Path> bellman_ford(
G &graph,
const std::map<int64_t, std::set<int64_t>> &combinations,
bool only_cost = false) {
std::deque<Path> paths;

for (const auto &comb : combinations) {
if (!graph.has_vertex(comb.first)) continue;
auto tmp_paths = bellman_ford(graph, comb.first, comb.second, only_cost);
paths.insert(paths.end(), tmp_paths.begin(), tmp_paths.end());
}

return paths;
}

//@}

private:
//! Call to BellmanFord 1 source to many targets
bool bellman_ford_1_to_many(
G &graph,
V source) {
log << std::string(__FUNCTION__) << "\n";
/* abort in case of an interruption occurs (e.g. the query is being cancelled) */
CHECK_FOR_INTERRUPTS();
try {
boost::bellman_ford_shortest_paths(
graph.graph,
static_cast<int>(graph.num_vertices()),
boost::predecessor_map(&predecessors[0])
.weight_map(get(&G::G_T_E::cost, graph.graph))
.distance_map(&distances[0])
.root_vertex(source));
} catch (boost::exception const& ex) {
(void)ex;
throw;
} catch (std::exception &e) {
(void)e;
throw;
} catch (...) {
throw;
}
return true;
}


// To Empty predecessors and distances vector for each function call
void clear() {
predecessors.clear();
distances.clear();
}


// used when multiple goals
std::deque<Path> get_paths(
const G &graph,
V source,
std::vector< V > &targets,
bool only_cost) const {
std::deque<Path> paths;
for (const auto target : targets) {
paths.push_back(Path(
graph,
source, target,
predecessors, distances,
only_cost, true));
}
return paths;
}



//! @name members
//@{
std::vector<V> predecessors;
std::vector<double> distances;

//@}
};

} // namespace pgrouting

#endif // INCLUDE_BELLMAN_FORD_BELLMAN_FORD_HPP_
Loading