69 real_t ntpwgts[2] = {0.5, 0.5};
117 idx_t i, ii,
j, k, nvtxs, pwgts[2], zeromaxpwgt, from, me,
118 bestcut=0, icut, mincut, inbfs;
124 nvtxs = graph->
nvtxs;
131 where = graph->
where;
138 for (inbfs=0; inbfs<niparts; inbfs++) {
139 iset(nvtxs, 1, where);
143 pwgts[1] = graph->
tvwgt[0];
146 for (ii=0; ii<nvtxs; ii++) {
148 if (pwgts[0]+vwgt[i] < zeromaxpwgt) {
152 if (pwgts[0] > zeromaxpwgt)
168 if (inbfs==0 || bestcut > graph->
mincut) {
170 icopy(nvtxs, where, bestwhere);
177 icopy(nvtxs, bestwhere, where);
193 pwgts[2], oneminpwgt, onemaxpwgt,
194 from, me, bestcut=0, icut, mincut, inbfs;
196 idx_t *queue, *touched, *gain, *bestwhere;
200 nvtxs = graph->
nvtxs;
207 where = graph->
where;
216 for (inbfs=0; inbfs<niparts; inbfs++) {
217 iset(nvtxs, 1, where);
219 iset(nvtxs, 0, touched);
221 pwgts[1] = graph->
tvwgt[0];
226 touched[queue[0]] = 1;
235 if (nleft == 0 || drain)
239 for (i=0; i<nvtxs; i++) {
240 if (touched[i] == 0) {
256 if (pwgts[0] > 0 && pwgts[1]-vwgt[i] < oneminpwgt) {
262 INC_DEC(pwgts[0], pwgts[1], vwgt[i]);
263 if (pwgts[1] <= onemaxpwgt)
267 for (j=xadj[i]; j<xadj[i+1]; j++) {
269 if (touched[k] == 0) {
304 if (inbfs == 0 || bestcut > graph->
mincut) {
306 icopy(nvtxs, where, bestwhere);
313 icopy(nvtxs, bestwhere, where);
328 idx_t i, ii,
j, k, nvtxs,
ncon, from, bestcut=0, mincut, inbfs, qnum;
334 nvtxs = graph->
nvtxs;
339 where = graph->
where;
345 for (inbfs=0; inbfs<2*niparts; inbfs++) {
347 iset(ncon, 0, counts);
350 for (ii=0; ii<nvtxs; ii++) {
352 qnum =
iargmax(ncon, vwgt+i*ncon);
353 where[
i] = (counts[qnum]++)%2;
364 if (inbfs == 0 || bestcut >= graph->
mincut) {
366 icopy(nvtxs, where, bestwhere);
373 icopy(nvtxs, bestwhere, where);
388 idx_t i,
j, k, nvtxs,
ncon, from, bestcut=0, mincut, inbfs;
393 nvtxs = graph->
nvtxs;
396 where = graph->
where;
400 for (inbfs=0; inbfs<2*niparts; inbfs++) {
401 iset(nvtxs, 1, where);
411 if (inbfs == 0 || bestcut >= graph->
mincut) {
413 icopy(nvtxs, where, bestwhere);
420 icopy(nvtxs, bestwhere, where);
436 idx_t i,
j, k, nvtxs, drain, nleft,
first,
last, pwgts[2], oneminpwgt,
437 onemaxpwgt, from, me, bestcut=0, icut, mincut, inbfs;
439 idx_t *queue, *touched, *gain, *bestwhere;
443 nvtxs = graph->
nvtxs;
459 graph->
where =
imalloc(nvtxs,
"GrowBisectionNode: where");
462 graph->
id =
imalloc(nvtxs,
"GrowBisectionNode: id");
463 graph->
ed =
imalloc(nvtxs,
"GrowBisectionNode: ed");
466 where = graph->
where;
469 for (inbfs=0; inbfs<niparts; inbfs++) {
470 iset(nvtxs, 1, where);
471 iset(nvtxs, 0, touched);
473 pwgts[1] = graph->
tvwgt[0];
477 touched[queue[0]] = 1;
485 if (nleft == 0 || drain)
489 for (i=0; i<nvtxs; i++) {
490 if (touched[i] == 0) {
506 if (pwgts[1]-vwgt[i] < oneminpwgt) {
512 INC_DEC(pwgts[0], pwgts[1], vwgt[i]);
513 if (pwgts[1] <= onemaxpwgt)
517 for (j=xadj[i]; j<xadj[i+1]; j++) {
519 if (touched[k] == 0) {
535 for (i=0; i<graph->
nbnd; i++) {
537 if (xadj[j+1]-xadj[j] > 0)
550 if (inbfs == 0 || bestcut > graph->
mincut) {
552 icopy(nvtxs, where, bestwhere);
557 icopy(nvtxs, bestwhere, where);
573 idx_t i,
j, k, nvtxs, bestcut=0, mincut, inbfs;
578 nvtxs = graph->
nvtxs;
583 graph->
where =
imalloc(nvtxs,
"GrowBisectionNode: where");
586 graph->
id =
imalloc(nvtxs,
"GrowBisectionNode: id");
587 graph->
ed =
imalloc(nvtxs,
"GrowBisectionNode: ed");
592 where = graph->
where;
595 for (inbfs=0; inbfs<niparts; inbfs++) {
596 iset(nvtxs, 1, where);
605 for (i=0; i<graph->
nbnd; i++) {
607 if (xadj[j+1]-xadj[j] > 0)
619 if (inbfs == 0 || bestcut > graph->
mincut) {
621 icopy(nvtxs, where, bestwhere);
626 icopy(nvtxs, bestwhere, where);
#define FM_2WayNodeRefine2Sided
idx_t idx_t idx_t idx_t * vwgt
#define Compute2WayNodePartitionParams
#define gk_startcputimer(tmr)
#define irandArrayPermute
for(size_t i=1;i< poses.size();++i)
#define gk_stopcputimer(tmr)
void McRandomBisection(ctrl_t *ctrl, graph_t *graph, real_t *ntpwgts, idx_t niparts)
#define Compute2WayPartitionParams
void gk_errexit(int signum, char *f_str,...)
EIGEN_CONSTEXPR Index first(const T &x) EIGEN_NOEXCEPT
NonlinearFactorGraph graph
void GrowBisectionNode(ctrl_t *ctrl, graph_t *graph, real_t *ntpwgts, idx_t niparts)
void Init2WayPartition(ctrl_t *ctrl, graph_t *graph, real_t *ntpwgts, idx_t niparts)
static const symbolic::SymbolExpr< internal::symbolic_last_tag > last
#define FM_2WayNodeRefine1Sided
#define ASSERT(expression)
void GrowBisection(ctrl_t *ctrl, graph_t *graph, real_t *ntpwgts, idx_t niparts)
#define ConstructSeparator
#define General2WayBalance
idx_t idx_t idx_t idx_t idx_t * perm
idx_t idx_t idx_t idx_t idx_t idx_t * adjwgt
#define INC_DEC(a, b, val)
void GrowBisectionNode2(ctrl_t *ctrl, graph_t *graph, real_t *ntpwgts, idx_t niparts)
void RandomBisection(ctrl_t *ctrl, graph_t *graph, real_t *ntpwgts, idx_t niparts)
void * gk_malloc(size_t nbytes, char *msg)
idx_t idx_t idx_t idx_t * where
void McGrowBisection(ctrl_t *ctrl, graph_t *graph, real_t *ntpwgts, idx_t niparts)
#define Setup2WayBalMultipliers
idx_t idx_t idx_t * adjncy
void InitSeparator(ctrl_t *ctrl, graph_t *graph, idx_t niparts)
#define Allocate2WayPartitionMemory
#define IFSET(a, flag, cmd)