@@ -138,6 +138,7 @@ void ContractNode(ContractorThreadData *data,
138138 const ContractorGraph &graph,
139139 const NodeID node,
140140 std::vector<EdgeWeight> &node_weights,
141+ const std::vector<bool > &contractable,
141142 ContractionStats *stats = nullptr )
142143{
143144 auto &heap = data->heap ;
@@ -245,12 +246,24 @@ void ContractNode(ContractorThreadData *data,
245246 if (RUNSIMULATION)
246247 {
247248 const int constexpr SIMULATION_SEARCH_SPACE_SIZE = 1000 ;
248- search (heap, graph, number_of_targets, SIMULATION_SEARCH_SPACE_SIZE, max_weight, node);
249+ search (heap,
250+ graph,
251+ contractable,
252+ number_of_targets,
253+ SIMULATION_SEARCH_SPACE_SIZE,
254+ max_weight,
255+ node);
249256 }
250257 else
251258 {
252259 const int constexpr FULL_SEARCH_SPACE_SIZE = 2000 ;
253- search (heap, graph, number_of_targets, FULL_SEARCH_SPACE_SIZE, max_weight, node);
260+ search (heap,
261+ graph,
262+ contractable,
263+ number_of_targets,
264+ FULL_SEARCH_SPACE_SIZE,
265+ max_weight,
266+ node);
254267 }
255268 for (auto out_edge : graph.GetAdjacentEdgeRange (node))
256269 {
@@ -344,18 +357,20 @@ void ContractNode(ContractorThreadData *data,
344357void ContractNode (ContractorThreadData *data,
345358 const ContractorGraph &graph,
346359 const NodeID node,
347- std::vector<EdgeWeight> &node_weights)
360+ std::vector<EdgeWeight> &node_weights,
361+ const std::vector<bool > &contractable)
348362{
349- ContractNode<false >(data, graph, node, node_weights, nullptr );
363+ ContractNode<false >(data, graph, node, node_weights, contractable, nullptr );
350364}
351365
352366ContractionStats SimulateNodeContraction (ContractorThreadData *data,
353367 const ContractorGraph &graph,
354368 const NodeID node,
355- std::vector<EdgeWeight> &node_weights)
369+ std::vector<EdgeWeight> &node_weights,
370+ const std::vector<bool > &contractable)
356371{
357372 ContractionStats stats;
358- ContractNode<true >(data, graph, node, node_weights, &stats);
373+ ContractNode<true >(data, graph, node, node_weights, contractable, &stats);
359374 return stats;
360375}
361376
@@ -487,7 +502,8 @@ bool UpdateNodeNeighbours(ContractorNodeData &node_data,
487502 if (node_data.contractable [u])
488503 {
489504 node_data.priorities [u] = EvaluateNodePriority (
490- SimulateNodeContraction (data, graph, u, node_data.weights ), node_data.depths [u]);
505+ SimulateNodeContraction (data, graph, u, node_data.weights , node_data.contractable ),
506+ node_data.depths [u]);
491507 }
492508 }
493509 return true ;
@@ -618,19 +634,21 @@ std::vector<bool> contractGraph(ContractorGraph &graph,
618634 {
619635 util::UnbufferedLog log;
620636 log << " initializing node priorities..." ;
621- tbb::parallel_for (tbb::blocked_range<std::size_t >(0 , remaining_nodes.size (), PQGrainSize),
622- [&](const auto &range)
623- {
624- ContractorThreadData *data = thread_data_list.GetThreadData ();
625- for (auto x = range.begin (), end = range.end (); x != end; ++x)
626- {
627- auto node = remaining_nodes[x].id ;
628- BOOST_ASSERT (node_data.contractable [node]);
629- node_data.priorities [node] = EvaluateNodePriority (
630- SimulateNodeContraction (data, graph, node, node_data.weights ),
631- node_data.depths [node]);
632- }
633- });
637+ tbb::parallel_for (
638+ tbb::blocked_range<std::size_t >(0 , remaining_nodes.size (), PQGrainSize),
639+ [&](const auto &range)
640+ {
641+ ContractorThreadData *data = thread_data_list.GetThreadData ();
642+ for (auto x = range.begin (), end = range.end (); x != end; ++x)
643+ {
644+ auto node = remaining_nodes[x].id ;
645+ BOOST_ASSERT (node_data.contractable [node]);
646+ node_data.priorities [node] = EvaluateNodePriority (
647+ SimulateNodeContraction (
648+ data, graph, node, node_data.weights , node_data.contractable ),
649+ node_data.depths [node]);
650+ }
651+ });
634652 log << " ok." ;
635653 }
636654
@@ -688,7 +706,7 @@ std::vector<bool> contractGraph(ContractorGraph &graph,
688706 for (auto position = range.begin (), end = range.end (); position != end; ++position)
689707 {
690708 const NodeID node = remaining_nodes[position].id ;
691- ContractNode (data, graph, node, node_data.weights );
709+ ContractNode (data, graph, node, node_data.weights , node_data. contractable );
692710 }
693711 });
694712
0 commit comments