|
35 | 35 | #include "mt-kahypar/datastructures/static_hypergraph.h" |
36 | 36 | #include "mt-kahypar/datastructures/partitioned_hypergraph.h" |
37 | 37 | #include "mt-kahypar/datastructures/connectivity_info.h" |
| 38 | +#include "mt-kahypar/partition/connected_components/compute_components.h" |
38 | 39 | #include "mt-kahypar/partition/context.h" |
39 | 40 | #include "mt-kahypar/partition/metrics.h" |
40 | 41 | #include "mt-kahypar/io/hypergraph_factory.h" |
@@ -100,6 +101,11 @@ int main(int argc, char* argv[]) { |
100 | 101 | " - hmetis: hMETIS hypergraph file format\n" |
101 | 102 | " - metis: METIS graph file format" |
102 | 103 | )->default_str("hmetis"); |
| 104 | + app.add_option( |
| 105 | + "--connected-blocks", |
| 106 | + context.partition.connected_blocks, |
| 107 | + "Ensure that the blocks of the resulting partition are connected" |
| 108 | + )->capture_default_str(); |
103 | 109 | app.add_option( |
104 | 110 | "-f,--fixed,--fixed-vertices", |
105 | 111 | context.partition.fixed_vertex_filename, |
@@ -150,6 +156,19 @@ int main(int argc, char* argv[]) { |
150 | 156 | } |
151 | 157 | } |
152 | 158 |
|
| 159 | + // Check connected blocks |
| 160 | + if ( context.partition.connected_blocks ) { |
| 161 | + vec<vec<connected_components::ConnectedComponent>> components; |
| 162 | + connected_components::compute_components_per_block(phg, context, components); |
| 163 | + |
| 164 | + for ( PartitionID i = 0; i < context.partition.k; ++i ) { |
| 165 | + if ( components[i].size() > 1 ) { |
| 166 | + LOG << RED << "Block" << i << "has" << components[i].size() << "components and is therefore not connected" << END; |
| 167 | + success = false; |
| 168 | + } |
| 169 | + } |
| 170 | + } |
| 171 | + |
153 | 172 | std::cout << "***********************" << context.partition.k |
154 | 173 | << "-way Partition Result************************" << std::endl; |
155 | 174 | std::cout << "cut =" << metrics::quality(phg, Objective::cut) << std::endl; |
|
0 commit comments