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

Function test_modularity

dlib/test/clustering.cpp:130–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128// ----------------------------------------------------------------------------------------
129
130 void test_modularity(dlib::rand& rnd)
131 {
132 print_spinner();
133 std::vector<sample_pair> edges;
134 std::vector<ordered_sample_pair> oedges;
135 std::vector<unsigned long> labels;
136
137 make_test_graph(rnd, edges, labels, 10, 30, 3, 0.10);
138 if (rnd.get_random_double() < 0.5)
139 remove_duplicate_edges(edges);
140 convert_unordered_to_ordered(edges, oedges);
141
142
143 const double m1 = modularity(edges, labels);
144 const double m2 = compute_modularity_simple(edges, labels);
145 const double m3 = modularity(oedges, labels);
146
147 DLIB_TEST(std::abs(m1-m2) < 1e-12);
148 DLIB_TEST(std::abs(m2-m3) < 1e-12);
149 DLIB_TEST(std::abs(m3-m1) < 1e-12);
150 }
151
152 void test_newman_clustering(dlib::rand& rnd)
153 {

Callers 1

perform_testMethod · 0.85

Calls 8

print_spinnerFunction · 0.85
make_test_graphFunction · 0.85
remove_duplicate_edgesFunction · 0.85
modularityFunction · 0.85
absFunction · 0.85
get_random_doubleMethod · 0.80

Tested by

no test coverage detected