MCPcopy Create free account
hub / github.com/davisking/dlib / brute_force_potts_model_on_graph

Function brute_force_potts_model_on_graph

dlib/test/graph_cuts.cpp:347–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345
346 template <typename graph_type>
347 void brute_force_potts_model_on_graph (
348 const graph_type& g,
349 std::vector<node_label>& labels_
350 )
351 {
352 std::vector<node_label> labels;
353 labels.resize(g.number_of_nodes());
354
355 const unsigned long num = (unsigned long)std::pow(2.0, (double)g.number_of_nodes());
356
357 double best_score = -std::numeric_limits<double>::infinity();
358 for (unsigned long i = 0; i < num; ++i)
359 {
360 for (unsigned long j = 0; j < g.number_of_nodes(); ++j)
361 {
362 unsigned long T = (1)<<j;
363 T = (T&i);
364 if (T != 0)
365 labels[j] = SINK_CUT;
366 else
367 labels[j] = SOURCE_CUT;
368 }
369
370
371 double score = potts_model_score(g,labels);
372 if (score > best_score)
373 {
374 best_score = score;
375 labels_ = labels;
376 }
377 }
378 }
379
380// ----------------------------------------------------------------------------------------
381

Callers 1

test_graph_potts_modelFunction · 0.85

Calls 3

potts_model_scoreFunction · 0.85
resizeMethod · 0.45
number_of_nodesMethod · 0.45

Tested by

no test coverage detected