| 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 |
no test coverage detected