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

Function test_graph_potts_model

dlib/test/graph_cuts.cpp:417–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

415// ----------------------------------------------------------------------------------------
416
417 void test_graph_potts_model(
418 dlib::rand& rnd
419 )
420 {
421 using namespace std;
422 double brute_force_score;
423 double graph_cut_score;
424
425 graph<double,double>::kernel_1a_c temp;
426 make_random_undirected_graph(rnd,temp);
427
428 {
429 std::vector<node_label> labels;
430
431 brute_force_potts_model_on_graph(temp, labels);
432
433 for (unsigned long i = 0; i < temp.number_of_nodes(); ++i)
434 {
435 dlog << LTRACE << "node " << i << ": "<< (int)labels[i];
436 }
437
438 brute_force_score = potts_model_score(temp, labels);
439 dlog << LTRACE << "brute force score: "<< brute_force_score;
440 }
441 dlog << LTRACE << "******************";
442
443 {
444 std::vector<node_label> labels;
445 find_max_factor_graph_potts(temp, labels);
446 DLIB_TEST(temp.number_of_nodes() == labels.size());
447
448 for (unsigned long i = 0; i < temp.number_of_nodes(); ++i)
449 {
450 dlog << LTRACE << "node " << i << ": "<< (int)labels[i];
451 }
452 graph_cut_score = potts_model_score(temp, labels);
453 dlog << LTRACE << "graph cut score: "<< graph_cut_score;
454 }
455
456 DLIB_TEST_MSG(graph_cut_score == brute_force_score, std::abs(graph_cut_score - brute_force_score));
457
458 dlog << LTRACE << "##################";
459 dlog << LTRACE << "##################";
460 dlog << LTRACE << "##################";
461 }
462
463// ----------------------------------------------------------------------------------------
464

Callers 1

perform_testMethod · 0.85

Calls 7

potts_model_scoreFunction · 0.85
absFunction · 0.85
number_of_nodesMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected