tnc/tensornetwork/partitioning/
partition_config.rs1use std::{
2 ffi::{CStr, CString},
3 path::PathBuf,
4};
5
6use kahypar::{include_cstr, KaHyParContext};
7
8static MIN_CUT_CONFIG: &CStr = include_cstr!("cut_kKaHyPar_sea20.ini");
9static COMMUNITY_FINDING_CONFIG: &CStr = include_cstr!("km1_kKaHyPar_sea20.ini");
10
11pub enum PartitioningStrategy {
13 MinCut,
15 CommunityFinding,
17 Custom(PathBuf),
19}
20
21impl PartitioningStrategy {
22 pub(super) fn apply(self, context: &mut KaHyParContext) {
23 match self {
24 Self::MinCut => {
25 context.configure_from_str(MIN_CUT_CONFIG);
26 }
27 Self::CommunityFinding => {
28 context.configure_from_str(COMMUNITY_FINDING_CONFIG);
29 }
30 Self::Custom(path) => {
31 context
32 .configure_from_file(CString::new(path.to_str().unwrap()).unwrap().as_c_str());
33 }
34 }
35 }
36}