@@ -138,6 +138,7 @@ void ContractNode(ContractorThreadData *data,
138
138
const ContractorGraph &graph,
139
139
const NodeID node,
140
140
std::vector<EdgeWeight> &node_weights,
141
+ const std::vector<bool > &contractable,
141
142
ContractionStats *stats = nullptr )
142
143
{
143
144
auto &heap = data->heap ;
@@ -245,12 +246,24 @@ void ContractNode(ContractorThreadData *data,
245
246
if (RUNSIMULATION)
246
247
{
247
248
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);
249
256
}
250
257
else
251
258
{
252
259
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);
254
267
}
255
268
for (auto out_edge : graph.GetAdjacentEdgeRange (node))
256
269
{
@@ -344,18 +357,20 @@ void ContractNode(ContractorThreadData *data,
344
357
void ContractNode (ContractorThreadData *data,
345
358
const ContractorGraph &graph,
346
359
const NodeID node,
347
- std::vector<EdgeWeight> &node_weights)
360
+ std::vector<EdgeWeight> &node_weights,
361
+ const std::vector<bool > &contractable)
348
362
{
349
- ContractNode<false >(data, graph, node, node_weights, nullptr );
363
+ ContractNode<false >(data, graph, node, node_weights, contractable, nullptr );
350
364
}
351
365
352
366
ContractionStats SimulateNodeContraction (ContractorThreadData *data,
353
367
const ContractorGraph &graph,
354
368
const NodeID node,
355
- std::vector<EdgeWeight> &node_weights)
369
+ std::vector<EdgeWeight> &node_weights,
370
+ const std::vector<bool > &contractable)
356
371
{
357
372
ContractionStats stats;
358
- ContractNode<true >(data, graph, node, node_weights, &stats);
373
+ ContractNode<true >(data, graph, node, node_weights, contractable, &stats);
359
374
return stats;
360
375
}
361
376
@@ -487,7 +502,8 @@ bool UpdateNodeNeighbours(ContractorNodeData &node_data,
487
502
if (node_data.contractable [u])
488
503
{
489
504
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]);
491
507
}
492
508
}
493
509
return true ;
@@ -618,19 +634,21 @@ std::vector<bool> contractGraph(ContractorGraph &graph,
618
634
{
619
635
util::UnbufferedLog log;
620
636
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
+ });
634
652
log << " ok." ;
635
653
}
636
654
@@ -688,7 +706,7 @@ std::vector<bool> contractGraph(ContractorGraph &graph,
688
706
for (auto position = range.begin (), end = range.end (); position != end; ++position)
689
707
{
690
708
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 );
692
710
}
693
711
});
694
712
0 commit comments