|
16 | 16 | #include <boost/property_map/vector_property_map.hpp> |
17 | 17 | #include <boost/static_assert.hpp> |
18 | 18 | #include <boost/type_traits/is_same.hpp> |
| 19 | +#include <boost/concept/assert.hpp> |
19 | 20 | #include <map> |
20 | 21 | #include <unordered_map> |
21 | 22 |
|
@@ -65,6 +66,35 @@ namespace centrality_detail { |
65 | 66 | }; |
66 | 67 | } |
67 | 68 |
|
| 69 | +template <typename QualityFunction, typename Graph, typename CommunityMap, typename WeightMap> |
| 70 | +struct LouvainQualityFunctionConcept |
| 71 | +{ |
| 72 | + using weight_type = typename property_traits<WeightMap>::value_type; |
| 73 | + using community_type = typename property_traits<CommunityMap>::value_type; |
| 74 | + using vertex_descriptor = typename graph_traits<Graph>::vertex_descriptor; |
| 75 | + |
| 76 | + void constraints() |
| 77 | + { |
| 78 | + weight_type q1 = QualityFunction::quality(g, cmap, wmap); |
| 79 | + weight_type q2 = QualityFunction::quality(g, cmap, wmap, k, in, tot, m); |
| 80 | + weight_type q3 = QualityFunction::quality_from_incremental(in, tot, m, num_communities); |
| 81 | + QualityFunction::remove(in, tot, comm, weight_val, weight_val, weight_val); |
| 82 | + QualityFunction::insert(in, tot, comm, weight_val, weight_val, weight_val); |
| 83 | + weight_type gain = QualityFunction::gain(tot, m, comm, weight_val, weight_val); |
| 84 | + } |
| 85 | + |
| 86 | + Graph g; |
| 87 | + CommunityMap cmap; |
| 88 | + WeightMap wmap; |
| 89 | + vector_property_map<weight_type> k; |
| 90 | + associative_property_map<std::map<community_type, weight_type>> in; |
| 91 | + associative_property_map<std::map<community_type, weight_type>> tot; |
| 92 | + weight_type m; |
| 93 | + weight_type weight_val; |
| 94 | + community_type comm; |
| 95 | + std::size_t num_communities; |
| 96 | +}; |
| 97 | + |
68 | 98 | // Modularity: Q = sum_c [ (L_c/m) - (k_c/2m)^2 ] |
69 | 99 | // L_c = internal edge weight for community c |
70 | 100 | // k_c = sum of degrees in community c |
|
0 commit comments