Skip to content

Commit

Permalink
withPoints Code Simplifiction similar to dijkstra
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhinJ committed Jun 8, 2023
1 parent 358f521 commit 06bb8cd
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions src/ksp/withPoints_ksp_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include <deque>
#include <vector>

#include "yen/pgr_ksp.hpp"

#include "withPoints/pgr_withPoints.hpp"
#include "c_types/ii_t_rt.h"
#include "cpp_common/combinations.h"
#include "cpp_common/pgr_alloc.hpp"
#include "cpp_common/pgr_assert.h"

#include "yen/pgr_ksp.hpp"
#include "withPoints/pgr_withPoints.hpp"

using pgrouting::yen::Pgr_ksp;

// CREATE OR REPLACE FUNCTION pgr_withPointsKSP(
Expand All @@ -60,8 +62,14 @@ do_pgr_withPointsKsp(
Edge_t *edges, size_t total_edges,
Point_on_edge_t *points_p, size_t total_points,
Edge_t *edges_of_points, size_t total_edges_of_points,
#if 0
int64_t start_pid,
int64_t end_pid,
#endif
II_t_rt *combinationsArr, size_t total_combinations,
int64_t *start_pidsArr, size_t size_start_pidsArr,
int64_t *end_pidsArr, size_t size_end_pidsArr,

size_t k,
bool directed,
bool heap_paths,
Expand All @@ -81,12 +89,14 @@ do_pgr_withPointsKsp(
std::ostringstream err;
std::ostringstream notice;
try {
pgassert(total_edges != 0);
pgassert(!(*log_msg));
pgassert(!(*notice_msg));
pgassert(!(*err_msg));
pgassert(!(*return_tuples));
pgassert(*return_count == 0);
pgassert(total_edges != 0);
pgassert(total_combinations != 0 || (size_start_pidsArr != 0 && size_end_pidsArr != 0));


pgrouting::Pg_points_graph pg_graph(
std::vector<Point_on_edge_t>(
Expand All @@ -107,7 +117,7 @@ do_pgr_withPointsKsp(
return -1;
}


#if 0
int64_t start_vid(start_pid);
int64_t end_vid(end_pid);

Expand All @@ -116,10 +126,16 @@ do_pgr_withPointsKsp(
log << "driving_side" << driving_side << "\n";
log << "start_vid" << start_vid << "\n";
log << "end_vid" << end_vid << "\n";
#endif

graphType gType = directed? DIRECTED: UNDIRECTED;

std::deque< Path > paths;

auto combinations = total_combinations?
pgrouting::utilities::get_combinations(combinationsArr, total_combinations)
: pgrouting::utilities::get_combinations(start_pidsArr, size_start_pidsArr, end_pidsArr, size_end_pidsArr);

auto vertices(pgrouting::extract_vertices(edges, total_edges));
vertices = pgrouting::extract_vertices(vertices, pg_graph.new_edges());

Expand All @@ -133,12 +149,16 @@ do_pgr_withPointsKsp(
log << "Working with directed Graph\n";
pgrouting::DirectedGraph digraph(vertices, gType);
digraph.insert_edges(edges, total_edges);
digraph.insert_edges(pg_graph.new_edges());

#if 0
log << "graph after inserting edges\n";
log << digraph << "\n";

digraph.insert_edges(pg_graph.new_edges());
log << "graph after inserting new edges\n";
log << digraph << "\n";
#endif

//TODO

Pgr_ksp< pgrouting::DirectedGraph > fn_yen;
paths = fn_yen.Yen(digraph, start_vid, end_vid, k, heap_paths);
Expand Down

0 comments on commit 06bb8cd

Please sign in to comment.