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

Function test_newman_clustering

dlib/test/clustering.cpp:152–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 1

perform_testMethod · 0.85

Calls 6

print_spinnerFunction · 0.85
make_test_graphFunction · 0.85
remove_duplicate_edgesFunction · 0.85
newman_clusterFunction · 0.85
get_random_doubleMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected