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

Function make_test_graph

dlib/test/clustering.cpp:18–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16// ----------------------------------------------------------------------------------------
17
18 void make_test_graph(
19 dlib::rand& rnd,
20 std::vector<sample_pair>& edges,
21 std::vector<unsigned long>& labels,
22 const int groups,
23 const int group_size,
24 const int noise_level,
25 const double missed_edges
26 )
27 {
28 labels.resize(groups*group_size);
29
30 for (unsigned long i = 0; i < labels.size(); ++i)
31 {
32 labels[i] = i/group_size;
33 }
34
35 edges.clear();
36 for (int i = 0; i < groups; ++i)
37 {
38 for (int j = 0; j < group_size; ++j)
39 {
40 for (int k = 0; k < group_size; ++k)
41 {
42 if (j == k)
43 continue;
44
45 if (rnd.get_random_double() < missed_edges)
46 continue;
47
48 edges.push_back(sample_pair(j+group_size*i, k+group_size*i, 1));
49 }
50 }
51 }
52
53 for (int k = 0; k < groups*noise_level; ++k)
54 {
55 const int i = rnd.get_random_32bit_number()%labels.size();
56 const int j = rnd.get_random_32bit_number()%labels.size();
57 edges.push_back(sample_pair(i,j,1));
58 }
59
60 }
61
62// ----------------------------------------------------------------------------------------
63

Callers 3

test_modularityFunction · 0.85
test_newman_clusteringFunction · 0.85
test_chinese_whispersFunction · 0.85

Calls 7

get_random_doubleMethod · 0.80
sample_pairClass · 0.50
resizeMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected