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

Function compute_modularity_simple

dlib/test/clustering.cpp:104–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102 }
103
104 double compute_modularity_simple (
105 const std::vector<sample_pair>& edges,
106 std::vector<unsigned long> labels
107 )
108 {
109 double m;
110 matrix<double> A,P;
111 make_modularity_matrices(edges, A, P, m);
112 matrix<double> B = A - P;
113
114 double Q = 0;
115 for (long r = 0; r < B.nr(); ++r)
116 {
117 for (long c = 0; c < B.nc(); ++c)
118 {
119 if (labels[r] == labels[c])
120 {
121 Q += B(r,c);
122 }
123 }
124 }
125 return 1.0/(2*m) * Q;
126 }
127
128// ----------------------------------------------------------------------------------------
129

Callers 1

test_modularityFunction · 0.85

Calls 4

make_modularity_matricesFunction · 0.85
BClass · 0.85
nrMethod · 0.45
ncMethod · 0.45

Tested by

no test coverage detected