45#ifndef __ADS_interop_kahip_KaHIP
46 #define __ADS_interop_kahip_KaHIP
53#if ! __has_include( <kaHIP_interface.h> )
54 #error "the interoperation with KaHIP needs the header of KaHIP"
61#include <kaHIP_interface.h>
101 ADS_PRE( ( ! g.directed() ) && ( k >= 1 ) && ( k <= g.n() ) &&
102 ( kahip_sizeof_idx() ==
int(
sizeof( kahip_idx ) ) ) );
105 P.
part.assign( std::size_t( g.n() ) , 0 );
106 if( ( g.n() == 0 ) || ( k == 1 ) )
108 int n = g.n() , parts = k;
109 double eps = o.imbalance;
112 auto * xadj =
const_cast< kahip_idx *
>( I.
offsets() );
113 auto * adjncy =
const_cast< kahip_idx *
>( I.
heads() );
115 o.weights ?
const_cast< kahip_idx *
>( I.
weights() ) :
nullptr;
116 kaffpa( &n ,
nullptr , xadj , adjcwgt , adjncy , &parts , &eps ,
true ,
118 o.mode , &cut , P.
part.data() );
119 P.
cut =
static_cast< long long >( cut );
131 const Input I( g , o.weights );
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The compressed rows of a StaticGraph handed to a library that takes them as plain arrays,...
A static GRAPH for the engineered algorithms, beyond the book [see Graph.h]: the compressed sparse ro...
#define ADS_PRE(cond)
[check]
Definition Contract.h:121
Partition partition(const G &g, const Input &I, int k, const Options &o=Options())
the partition of the nodes of into parts by kaffpa(), on the input of (whose arrays it reads in p...
Definition KaHIP.h:98
CsrInput< kahip_idx, kahip_idx > Input
the arrays of a graph for KaHIP: in place where the layouts agree
Definition KaHIP.h:91
a partition of the nodes of a graph into parts
Definition Csr.h:150
int k
the number of the parts
Definition Csr.h:153
long long cut
the weight of the edges between two parts
Definition Csr.h:152
std::vector< int > part
the part of each node, in
Definition Csr.h:151
the options of a partition by KaHIP
Definition KaHIP.h:79
int seed
the seed of KaHIP
Definition KaHIP.h:83
int mode
FAST, ECO, STRONG or their *SOCIAL
Definition KaHIP.h:80
bool weights
the weights of the arcs, if any, as adjcwgt
Definition KaHIP.h:81
double imbalance
the largest part over the mean, less 1
Definition KaHIP.h:82