45 const size_t edge_count,
47 const std::vector<Rule> &ruleList) :
64 size_t total_edges)
const {
65 int64_t v_min_id = INT64_MAX;
67 for (z = 0; z < total_edges; z++) {
68 if (edges[z].source < v_min_id)
69 v_min_id = edges[z].
source;
71 if (edges[z].target < v_min_id)
72 v_min_id = edges[z].
target;
75 for (z = 0; z < total_edges; z++) {
76 edges[z].
source -= v_min_id;
77 edges[z].
target -= v_min_id;
97 if (pos ==
ILLEGAL)
return (std::numeric_limits<double>::max)();
99 if (
m_parent[
static_cast<size_t>(ed_id)].isIllegal(pos)) {
101 auto cur_edge = &
m_edges[
static_cast<size_t>(ed_id)];
103 pelement.
node = cur_edge->startNode();
104 pelement.
cost = cur_edge->cost();
106 pelement.
node = cur_edge->endNode();
107 pelement.
cost = cur_edge->r_cost();
109 pelement.
edge = cur_edge->edgeID();
113 return pelement.
cost;
117 static_cast<int64_t
>(
m_parent[
static_cast<size_t>(ed_id)].e_idx[
static_cast<size_t>(pos)]),
118 static_cast<Position>(
m_parent[
static_cast<size_t>(ed_id)].v_pos[
static_cast<size_t>(pos)]));
120 auto cur_edge = &
m_edges[
static_cast<size_t>(ed_id)];
122 pelement.
node = cur_edge->startNode();
123 pelement.
cost =
m_dCost[
static_cast<size_t>(ed_id)].endCost - ret;
124 ret =
m_dCost[
static_cast<size_t>(ed_id)].endCost;
126 pelement.
node = cur_edge->endNode();
127 pelement.
cost =
m_dCost[
static_cast<size_t>(ed_id)].startCost - ret;
128 ret =
m_dCost[
static_cast<size_t>(ed_id)].startCost;
130 pelement.
edge = cur_edge->edgeID();
144 int64_t edge_id =
edge.edgeID();
149 int64_t st_edge_ind = edge_ind;
150 for (
const auto &rule : vecRules) {
153 edge_ind = st_edge_ind;
156 for (
auto const &precedence : rule.precedencelist()) {
157 if (precedence !=
m_edges[
static_cast<size_t>(edge_ind)].edgeID()) {
161 auto m_parent_ind =
m_parent[
static_cast<size_t>(edge_ind)].e_idx[
static_cast<size_t>(v_pos)];
162 v_pos =
m_parent[
static_cast<size_t>(edge_ind)].v_pos[
static_cast<size_t>(v_pos)];
163 edge_ind =
static_cast<int64_t
>(m_parent_ind);
177 return m_dCost[edge_idx].startCost +
180 return m_dCost[edge_idx].endCost +
192 auto vecIndex = cur_edge.
get_idx(isStart);
194 for (
const auto &index : vecIndex) {
198 static_cast<int64_t
>(cur_edge.
idx()),
201 if ((
edge.startNode() == cur_node) && (
edge.
cost() >= 0.0)) {
207 if (totalCost <
m_dCost[index].endCost) {
208 m_dCost[index].endCost = totalCost;
217 if ((
edge.endNode() == cur_node) && (
edge.r_cost() >= 0.0)) {
219 edge.r_cost() + extra_cost,
223 if (totalCost <
m_dCost[index].startCost) {
224 m_dCost[index].startCost = totalCost;
238 const std::vector<Rule> &ruleList) {
239 for (
const auto &rule : ruleList) {
240 auto dest_edge_id = rule.dest_id();
246 m_ruleTable.insert(std::make_pair(dest_edge_id, r));
260 const int64_t start_vertex,
261 const int64_t end_vertex) {
293 const std::vector<int64_t> sources,
294 const std::vector<int64_t> targets) {
295 std::deque<Path> paths;
296 for (
const auto &s : sources) {
297 for (
const auto &t : targets) {
298 paths.push_back(
process(s, t));
302 std::sort(paths.begin(), paths.end(),
303 [](
const Path &e1,
const Path &e2)->bool {
304 return e1.end_id() < e2.end_id();
306 std::stable_sort(paths.begin(), paths.end(),
307 [](
const Path &e1,
const Path &e2)->bool {
308 return e1.start_id() < e2.start_id();
321 que.push(std::make_pair(cost,
322 std::make_pair(e_idx, isStart)));
337 && cur_edge.
cost() >= 0.0) {
344 && cur_edge.
r_cost() >= 0.0) {
357 while (!
que.empty()) {
358 auto cur_pos =
que.top();
361 auto cure_idxex = cur_pos.second.first;
362 cur_edge =
m_edges[
static_cast<size_t>(cure_idxex)];
364 if (cur_pos.second.second) {
369 if (cur_edge.
cost() < 0.0)
continue;
377 if (cur_edge.
r_cost() < 0.0)
continue;
396 m_dCost.resize(edge_count + 1);
426 m_path.Path::recalculate_agg_cost();
437 const size_t edge_count,
438 const bool directed) {
439 for (
size_t i = 0; i < edge_count; i++) {
440 auto current_edge = &edges[i];
445 if (current_edge->cost < 0 && current_edge->reverse_cost > 0) {
446 std::swap(current_edge->cost, current_edge->reverse_cost);
447 std::swap(current_edge->source, current_edge->target);
451 if (current_edge->reverse_cost < 0) {
452 current_edge->reverse_cost = current_edge->cost;
463 size_t firstEdge_idx,
464 size_t secondEdge_idx) {
468 if (firstEdge.
r_cost() >= 0.0) {
473 && secondEdge.
r_cost() >= 0.0) {
478 &&secondEdge.
cost() >= 0.0) {
486 size_t firstEdge_idx,
487 size_t secondEdge_idx) {
491 if (firstEdge.
cost() >= 0.0) {
496 && secondEdge.
r_cost() >= 0.0) {
501 && secondEdge.
cost() >= 0.0) {
545 for (
const auto e_idx : itNodeMap->second) {
556 for (
const auto e_idx : itNodeMap->second) {