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