Skip to content

Commit

Permalink
(C/C++) removing unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
cvvergara committed Oct 22, 2024
1 parent fddc49e commit 48eea30
Show file tree
Hide file tree
Showing 25 changed files with 1 addition and 729 deletions.
152 changes: 0 additions & 152 deletions include/bellman_ford/bellman_ford.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,43 +56,6 @@ class Pgr_bellman_ford : public pgrouting::Pgr_messages {
typedef typename G::E E;
//@{

#if 0
//! @name BellmanFord
//@{
//! BellmanFord 1 to 1
Path bellman_ford(
G &graph,
int64_t start_vertex,
int64_t end_vertex,
bool only_cost = false) {
clear();
log << std::string(__FUNCTION__) << "\n";

// adjust predecessors and distances vectors
predecessors.resize(graph.num_vertices());
distances.resize(graph.num_vertices());


if (!graph.has_vertex(start_vertex)
|| !graph.has_vertex(end_vertex)) {
return Path(start_vertex, end_vertex);
}

// get the graphs source and target
auto v_source(graph.get_V(start_vertex));
auto v_target(graph.get_V(end_vertex));

// perform the algorithm
bellman_ford_1_to_1(graph, v_source, v_target);

// get the results
return Path(
graph,
v_source, v_target,
predecessors, distances,
only_cost, true);
}
#endif


/** @brief bellman_ford one to a set of many
Expand Down Expand Up @@ -135,91 +98,6 @@ class Pgr_bellman_ford : public pgrouting::Pgr_messages {
return paths;
}

#if 0
// BellmanFord many to 1
std::deque<Path> bellman_ford(
G &graph,
const std::vector < int64_t > &start_vertex,
int64_t end_vertex,
bool only_cost = false) {
std::deque<Path> paths;
log << std::string(__FUNCTION__) << "\n";
for (const auto &start : start_vertex) {
paths.push_back(
bellman_ford(graph, start, end_vertex, only_cost));
}

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


// BellmanFord many to many
std::deque<Path> bellman_ford(
G &graph,
const std::vector< int64_t > &start_vertex,
const std::vector< int64_t > &end_vertex,
bool only_cost = false) {
// a call to 1 to many is faster for each of the sources
std::deque<Path> paths;
log << std::string(__FUNCTION__) << "\n";

for (const auto &start : start_vertex) {
auto r_paths = bellman_ford(graph, start, end_vertex, only_cost);
paths.insert(paths.begin(), r_paths.begin(), r_paths.end());
}


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

// BellmanFord combinations
std::deque<Path> bellman_ford(
G &graph,
const std::vector<II_t_rt> &combinations,
bool only_cost = false) {
// a call to 1 to many is faster for each of the sources
std::deque<Path> paths;
log << std::string(__FUNCTION__) << "\n";

// group targets per distinct source
std::map< int64_t, std::vector<int64_t> > vertex_map;
for (const II_t_rt &comb : combinations) {
std::map< int64_t, std::vector<int64_t> >::iterator it = vertex_map.find(comb.d1.source);
if (it != vertex_map.end()) {
it->second.push_back(comb.d2.target);
} else {
std::vector<int64_t > targets{comb.d2.target};
vertex_map[comb.d1.source] = targets;
}
}

for (const auto &start_ends : vertex_map) {
std::deque<Path> result_paths = bellman_ford(
graph,
start_ends.first,
start_ends.second,
only_cost);
paths.insert(
paths.end(),
std::make_move_iterator(result_paths.begin()),
std::make_move_iterator(result_paths.end()));
}

return paths;
}
#endif

/** @brief BellmanFord combinations **/
std::deque<Path> bellman_ford(
Expand All @@ -240,36 +118,6 @@ class Pgr_bellman_ford : public pgrouting::Pgr_messages {
//@}

private:
#if 0
//! Call to BellmanFord 1 source to 1 target
bool bellman_ford_1_to_1(
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;
}
#endif

//! Call to BellmanFord 1 source to many targets
bool bellman_ford_1_to_many(
G &graph,
Expand Down
73 changes: 0 additions & 73 deletions include/bellman_ford/edwardMoore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,79 +47,6 @@ class Pgr_edwardMoore {
typedef typename G::E E;
typedef typename G::EO_i EO_i;

#if 0
std::deque<Path> edwardMoore(
G &graph,
const std::vector<int64_t> &start_vertex,
const std::vector<int64_t> &end_vertex) {
std::deque<Path> paths;

for (const auto &source : start_vertex) {
std::deque<Path> result_paths = one_to_many_edwardMoore(
graph,
source,
end_vertex);

paths.insert(
paths.begin(),
std::make_move_iterator(result_paths.begin()),
std::make_move_iterator(result_paths.end()));
}

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

return paths;
}

// preparation for the parallel arrays
std::deque<Path> edwardMoore(
G &graph,
const std::vector<II_t_rt> &combinations) {
std::deque<Path> paths;

// group targets per distinct source
std::map< int64_t, std::vector<int64_t> > vertex_map;
for (const II_t_rt &comb : combinations) {
std::map< int64_t, std::vector<int64_t> >::iterator it = vertex_map.find(comb.d1.source);
if (it != vertex_map.end()) {
it->second.push_back(comb.d2.target);
} else {
std::vector<int64_t > targets{comb.d2.target};
vertex_map[comb.d1.source] = targets;
}
}

for (const auto &start_ends : vertex_map) {
std::deque<Path> result_paths = one_to_many_edwardMoore(
graph,
start_ends.first,
start_ends.second);

paths.insert(
paths.end(),
std::make_move_iterator(result_paths.begin()),
std::make_move_iterator(result_paths.end()));
}

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

return paths;
}
#endif

/** @brief edwardMoore for combinations */
std::deque<Path> edwardMoore(
Expand Down
30 changes: 0 additions & 30 deletions include/breadthFirstSearch/binaryBreadthFirstSearch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,36 +51,6 @@ class Pgr_binaryBreadthFirstSearch {
typedef typename G::EO_i EO_i;
typedef typename G::E_i E_i;

#if 0
std::deque<Path> binaryBreadthFirstSearch(
G &graph,
const std::vector<int64_t> &start_vertex,
const std::vector<int64_t> &end_vertex) {
std::deque<Path> paths;

for (const auto &source : start_vertex) {
std::deque<Path> result_paths = one_to_many_binaryBreadthFirstSearch(
graph,
source,
end_vertex);
paths.insert(
paths.begin(),
std::make_move_iterator(result_paths.begin()),
std::make_move_iterator(result_paths.end()));
}

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

return paths;
}
#endif

std::deque<Path> binaryBreadthFirstSearch(
G &graph,
Expand Down
9 changes: 0 additions & 9 deletions include/cpp_common/ch_vertex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,6 @@ class CH_vertex {
size_t
check_vertices(std::vector < CH_vertex > vertices);

#if 0
std::vector < CH_vertex >
extract_vertices(
const Edge_t *data_edges, int64_t count);

std::vector < CH_vertex >
extract_vertices(
const std::vector < Edge_t > &data_edges);
#endif
} // namespace pgrouting

#endif // INCLUDE_CPP_COMMON_CH_VERTEX_HPP_
9 changes: 0 additions & 9 deletions include/cpp_common/xy_vertex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,6 @@ std::vector < XY_vertex >
extract_vertices(
const std::vector <Edge_xy_t > &data_edges);

#if 0
std::vector < XY_vertex > extract_vertices(
std::vector < XY_vertex > vertices,
const Edge_xy_t *data_edges, int64_t count);

std::vector < XY_vertex > extract_vertices(
std::vector < XY_vertex > vertices,
const std::vector <Edge_xy_t > data_edges);
#endif

} // namespace pgrouting

Expand Down
Loading

0 comments on commit 48eea30

Please sign in to comment.