| 150 | } |
| 151 | |
| 152 | void test_newman_clustering(dlib::rand& rnd) |
| 153 | { |
| 154 | print_spinner(); |
| 155 | std::vector<sample_pair> edges; |
| 156 | std::vector<unsigned long> labels; |
| 157 | |
| 158 | make_test_graph(rnd, edges, labels, 5, 30, 3, 0.10); |
| 159 | if (rnd.get_random_double() < 0.5) |
| 160 | remove_duplicate_edges(edges); |
| 161 | |
| 162 | |
| 163 | std::vector<unsigned long> labels2; |
| 164 | |
| 165 | unsigned long num_clusters = newman_cluster(edges, labels2); |
| 166 | DLIB_TEST(labels.size() == labels2.size()); |
| 167 | DLIB_TEST(num_clusters == 5); |
| 168 | |
| 169 | for (unsigned long i = 0; i < labels.size(); ++i) |
| 170 | { |
| 171 | for (unsigned long j = 0; j < labels.size(); ++j) |
| 172 | { |
| 173 | if (labels[i] == labels[j]) |
| 174 | { |
| 175 | DLIB_TEST(labels2[i] == labels2[j]); |
| 176 | } |
| 177 | else |
| 178 | { |
| 179 | DLIB_TEST(labels2[i] != labels2[j]); |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | void test_chinese_whispers(dlib::rand& rnd) |
| 186 | { |
no test coverage detected