Skip to content

Commit

Permalink
move vector creation and allocation to outside of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ghoshkaj committed Mar 15, 2018
1 parent 1497056 commit 94970d7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 30 deletions.
6 changes: 3 additions & 3 deletions include/extractor/tarjan_scc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ template <typename GraphT> class TarjanSCC
continue;
}

if (before_recursion) // (u,v)
if (before_recursion)
{
// Mark frame to handle tail of recursion
recursion_stack.emplace(currentFrame);
processing_node_before_recursion[v] = false; // do we have component parts yet?
processing_node_before_recursion[v] = false;

// Mark essential information for SCC
tarjan_node_list[v].index = index;
Expand All @@ -124,7 +124,7 @@ template <typename GraphT> class TarjanSCC
}
}
}
else // after recursion
else
{
processing_node_before_recursion[v] = true;
tarjan_node_list[u].low_link =
Expand Down
6 changes: 0 additions & 6 deletions src/engine/routing_algorithms/direct_shortest_path.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "engine/routing_algorithms/direct_shortest_path.hpp"
#include "engine/routing_algorithms/many_to_many.hpp"
#include "engine/routing_algorithms/routing_base.hpp"
#include "engine/routing_algorithms/routing_base_ch.hpp"
#include "engine/routing_algorithms/routing_base_mld.hpp"
Expand Down Expand Up @@ -45,11 +44,6 @@ InternalRouteResult directShortestPathSearch(SearchEngineData<ch::Algorithm> &en
std::vector<NodeID> unpacked_nodes;
std::vector<EdgeID> unpacked_edges;

std::cout << "Packed Path in direct_shortest_path: ";
for (auto i = packed_leg.begin(); i != packed_leg.end(); ++i)
std::cout << *i << " ";
std::cout << std::endl;

if (!packed_leg.empty())
{
unpacked_nodes.reserve(packed_leg.size());
Expand Down
36 changes: 15 additions & 21 deletions src/engine/routing_algorithms/many_to_many_ch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
{
const NodeID to = facade.GetTarget(edge);
const auto edge_weight = data.weight;

const auto edge_duration = data.duration;

BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
Expand Down Expand Up @@ -161,7 +162,8 @@ void backwardRoutingStep(const DataFacade<Algorithm> &facade,
std::vector<NodeID>
retrievePackedPathFromSearchSpace(NodeID middle_node_id,
const unsigned column_idx,
std::vector<NodeBucket> &search_space_with_buckets)
std::vector<NodeBucket> &search_space_with_buckets,
std::vector<NodeID> &packed_leg)
{

// [ 0 1 2 3 ]
Expand All @@ -184,7 +186,7 @@ retrievePackedPathFromSearchSpace(NodeID middle_node_id,
search_space_with_buckets.end(),
middle_node_id,
NodeBucket::ColumnCompare(column_idx));
std::vector<NodeID> packed_leg;

NodeID current_node_id = middle_node_id;

BOOST_ASSERT_MSG(std::distance(bucket_list.first, bucket_list.second) == 1,
Expand Down Expand Up @@ -223,6 +225,7 @@ std::vector<EdgeDuration> manyToManySearch(SearchEngineData<ch::Algorithm> &engi
std::vector<NodeID> middle_nodes_table(number_of_entries, SPECIAL_NODEID);

std::vector<NodeBucket> search_space_with_buckets;
std::vector<NodeID> packed_leg;

engine_working_data.InitializeOrClearUnpackingCacheThreadLocalStorage();

Expand Down Expand Up @@ -259,7 +262,7 @@ std::vector<EdgeDuration> manyToManySearch(SearchEngineData<ch::Algorithm> &engi
auto &query_heap = *(engine_working_data.many_to_many_heap);
insertSourceInHeap(query_heap, source_phantom);

// Explore search spacekewl thanks
// Explore search space
while (!query_heap.Empty())
{
forwardRoutingStep(facade,
Expand Down Expand Up @@ -290,33 +293,23 @@ std::vector<EdgeDuration> manyToManySearch(SearchEngineData<ch::Algorithm> &engi
durations_table[row_idx * number_of_targets + column_idx] = MAXIMAL_EDGE_DURATION;
continue;
}

// Step 1: Find path from source to middle node
std::vector<NodeID> packed_leg_from_source_to_middle;
ch::retrievePackedPathFromSingleManyToManyHeap(
query_heap,
middle_node_id,
packed_leg_from_source_to_middle); // packed_leg_from_source_to_middle
std::reverse(packed_leg_from_source_to_middle.begin(),
packed_leg_from_source_to_middle.end());
packed_leg); // packed_leg_from_source_to_middle
std::reverse(packed_leg.begin(), packed_leg.end());

packed_leg.push_back(middle_node_id);

// Step 2: Find path from middle to target node
std::vector<NodeID> packed_leg_from_middle_to_target =
retrievePackedPathFromSearchSpace(
middle_node_id,
column_idx,
search_space_with_buckets); // packed_leg_from_middle_to_target

// Step 3: Join them together
std::vector<NodeID> packed_leg;
packed_leg.reserve(packed_leg_from_source_to_middle.size() + 1 +
packed_leg_from_middle_to_target.size());
packed_leg.insert(packed_leg.end(),
packed_leg_from_source_to_middle.begin(),
packed_leg_from_source_to_middle.end());
packed_leg.push_back(middle_node_id);
packed_leg.insert(packed_leg.end(),
packed_leg_from_middle_to_target.begin(),
packed_leg_from_middle_to_target.end());
search_space_with_buckets,
packed_leg); // packed_leg_from_middle_to_target

if (packed_leg.size() == 1 && (needsLoopForward(source_phantom, target_phantom) ||
needsLoopBackwards(source_phantom, target_phantom)))
{
Expand Down Expand Up @@ -370,6 +363,7 @@ std::vector<EdgeDuration> manyToManySearch(SearchEngineData<ch::Algorithm> &engi
durations_table[row_idx * number_of_targets + column_idx] += offset;
}
}
packed_leg.clear();
}
}

Expand Down

0 comments on commit 94970d7

Please sign in to comment.