61 for( i = 0; i <
nnodes; i++ )
87 STP_Vectype(
int) biconn_stack = cutnodes->biconn_stack;
89 assert(stack_start >= 0);
92 assert(biconn_comproot[ncomps] == -1);
93 assert(ncomps == 1 || biconn_comproot[ncomps - 1] != -1);
95 biconn_comproot[ncomps] = root;
97 for(
int size =
StpVecGetSize(biconn_stack); size != stack_start; size-- )
99 const int compnode = biconn_stack[size - 1];
104 assert(biconn_nodesmark[compnode] == 0);
105 assert(compnode != root);
107 biconn_nodesmark[compnode] = ncomps;
122 #ifdef CUTTREE_PRINT_STATISTICS 123 int* childcount_terms = cutnodes->childcount_terms;
124 int* childcount_nodes = cutnodes->childcount_nodes;
129 int mylowpoint = myhittime;
132 const SCIP_Bool nodeIsRoot = (parent == -1);
134 nodes_hittime[node] = myhittime;
140 const int head = g->
head[e];
146 if( nodes_hittime[head] < 0 )
148 const int stack_start =
StpVecGetSize(cutnodes->biconn_stack);
149 assert(head != parent);
153 #ifdef CUTTREE_PRINT_STATISTICS 154 childcount_nodes[node] += childcount_nodes[head] + 1;
155 childcount_terms[node] += childcount_terms[head] + (
Is_term(g->
term[head]) ? 1 : 0);
180 else if( head != parent )
182 assert(nodes_hittime[head] >= 0);
183 if( mylowpoint > nodes_hittime[head] )
184 mylowpoint = nodes_hittime[head];
188 if( nodeIsRoot && nchildren > 1 )
211 const int lastroot = cutnodes->artpoints[
StpVecGetSize(cutnodes->artpoints) - 1];
218 for(
int i = 0; i < g->
knots; i++ )
240 const int*
const nodes = bidecomp->
nodes;
241 const int*
const starts = bidecomp->
starts;
246 for(
int i = 0; i < ncomps; i++ )
248 const int comp_start = starts[i];
249 const int comp_end = starts[i + 1];
250 const int comp_root = biconn_comproots[i];
252 assert(comp_start <= comp_end);
254 SCIPdebugMessage(
"component %d is of size %d (root=%d); nodes: \n", i, comp_end - comp_start,
257 for(
int j = comp_start; j != comp_end; j++ )
259 const int comp_node = nodes[j];
266 if( biconn_nodesmark[comp_node] != i )
270 for( k = 0; k < ncomps; k++ )
272 if( comp_node == biconn_comproots[k] )
281 printf(
"ERROR: no component root found \n");
302 int* RESTRICT nodes = bidecomp->
nodes;
303 int* RESTRICT starts = bidecomp->
starts;
309 for(
int i = 0; i <= ncomps; i++ )
312 for(
int i = 0; i <
nnodes; i++ )
316 const int compid = biconn_nodesmark[i];
317 assert(0 <= compid && compid < ncomps);
324 for(
int i = 0; i < ncomps; i++ )
326 const int comproot = biconn_comproots[i];
327 if( biconn_nodesmark[comproot] != i && g->
grad[comproot] > 0 )
331 for(
int i = 1; i <= ncomps; i++ )
332 starts[i] += starts[i - 1];
334 assert(starts[ncomps] == starts[ncomps - 1]);
337 for(
int i = 0; i <
nnodes; i++ )
341 const int compid = biconn_nodesmark[i];
342 assert(0 <= compid && compid < ncomps);
345 nodes[starts[compid]] = i;
347 assert(compid == 0 || starts[compid - 1] <= starts[compid]);
351 for(
int i = 0; i < ncomps; i++ )
353 const int comproot = biconn_comproots[i];
354 if( biconn_nodesmark[comproot] != i && g->
grad[comproot] > 0 )
357 nodes[starts[i]] = comproot;
361 assert(starts[0] == 0);
362 assert(starts[ncomps] <= nnodes + ncomps);
372 const GRAPH* orggraph,
376 const int*
const gMark = orggraph->
mark;
380 const int root = orggraph->
source;
391 for(
int i = 0; i <
nnodes; i++ )
392 nodes_isVisited[i] =
FALSE;
394 nodes_isVisited[root] =
TRUE;
408 const int head = orggraph->
head[
a];
410 if( !nodes_isVisited[head] )
414 assert(!markedIsFound);
416 markedIsFound =
TRUE;
421 nodes_isVisited[head] =
TRUE;
426 assert(markedIsFound);
449 int* biconn_nodesmark;
450 int* biconn_comproots;
458 #ifdef CUTTREE_PRINT_STATISTICS 460 int* childcount_nodes;
461 int* childcount_terms;
466 for(
int k = 0; k <
nnodes; k++ )
467 childcount_nodes[k] = 0;
469 for(
int k = 0; k <
nnodes; k++ )
470 childcount_terms[k] = 0;
472 cn->childcount_nodes = childcount_nodes;
473 cn->childcount_terms = childcount_terms;
481 for(
int k = 0; k <
nnodes; k++ )
482 nodes_hittime[k] = -1;
485 for(
int k = 0; k <
nnodes; k++ )
486 biconn_comproots[k] = -1;
489 for(
int k = 0; k <
nnodes; k++ )
490 biconn_nodesmark[k] = 0;
493 cn->artpoints =
NULL;
494 cn->biconn_stack =
NULL;
519 assert(scip && cutnodes);
530 #ifdef CUTTREE_PRINT_STATISTICS 580 assert(scip && cutnodes);
584 bidecomp = *bidecomposition;
589 bidecomp->
nodes = nodes;
590 bidecomp->
starts = starts;
606 assert(scip && g && bidecomposition);
623 assert(scip && bidecomposition);
625 bidecomp = *bidecomposition;
645 int*
const gMark = g->
mark;
648 const int*
const compnodes = bidecomp->
nodes;
649 const int compstart = bidecomp->
starts[compindex];
650 const int compend = bidecomp->
starts[compindex + 1];
653 for(
int i = 0; i <
nnodes; i++ )
658 for(
int i = compstart; i != compend; i++ )
660 const int compnode = compnodes[i];
665 if( contractionRecord[compnode] != -1 )
669 SCIPdebugMessage(
"(taking contracted node %d instead of %d:) \n", contractionRecord[compnode], compnode);
680 gMark[realnode] =
TRUE;
690 const GRAPH* orggraph,
691 const GRAPH* subgraph,
695 const int* nodemap_OrgToSub;
697 assert(bidecomp && orggraph && subroot);
708 *subroot = nodemap_OrgToSub[*subroot];
724 assert(0 <= compindex && compindex < bidecomp->nbicomps);
727 const int compstart = bidecomp->
starts[compindex];
728 const int compend = bidecomp->
starts[compindex + 1];
730 assert(compstart <= compend);
732 if( compend - compstart <= 1 )
734 SCIPdebugMessage(
"component %d is of size %d, SKIP! \n", compindex, compend - compstart);
750 const int*
const isMarked = g->
mark;
754 for(
int i = 0; i <
nnodes; i++ )
760 return (nnodes_real < 75000);
770 const int*
const starts = bidecomp->
starts;
772 const int ncomps = bidecomp->
nbicomps;
773 const int nallnodes = starts[ncomps] - starts[0];
777 assert(0 <= compindex && compindex < ncomps);
778 assert(nallnodes > 0);
780 compnnodes = starts[compindex + 1] - starts[compindex];
784 assert(
GE(ratio, 0.0));
795 const int*
const starts = bidecomp->
starts;
797 const int ncomps = bidecomp->
nbicomps;
798 const int ncompnodes = starts[ncomps] - starts[0];
799 int maxcompnnodes = 0;
802 assert(0 < ncompnodes);
806 for(
int i = 0; i < ncomps; i++ )
808 const int compnnodes = starts[i + 1] - starts[i];
809 if( maxcompnnodes < compnnodes )
810 maxcompnnodes = compnnodes;
818 assert(
GT(maxratio, 0.0));
#define STP_Vectype(type)
#define StpVecGetSize(vec)
int graph_knot_getContractionRecordAncestor(int, const SUBINOUT *)
SCIP_Bool graph_pc_isRootedPcMw(const GRAPH *)
SCIP_Bool bidecomposition_isPossible(const GRAPH *g)
#define SCIPfreeMemoryArray(scip, ptr)
#define SCIPallocMemoryArray(scip, ptr, num)
static void cutNodesComputePostProcess(const GRAPH *g, CUTNODES *cutnodes)
const int * graph_subinoutGetContractionRecord(const SUBINOUT *)
void graph_knot_printInfo(const GRAPH *, int)
void graph_subinoutFree(SCIP *, SUBINOUT **)
enum SCIP_Retcode SCIP_RETCODE
void bidecomposition_free(SCIP *scip, BIDECOMP **bidecomposition)
#define StpVecPopBack(vec)
#define StpVecReserve(scip, vec, _size_)
#define SCIPfreeBufferArray(scip, ptr)
static void cutNodesSetDfsRoot(const GRAPH *g, CUTNODES *cutnodes)
header only, simple implementation of an STL like vector
several decomposition methods for Steiner tree problems
SCIP_Real bidecomposition_getCompNodeRatio(const BIDECOMP *bidecomp, int compindex)
static void decomposeBuildCsr(const CUTNODES *cutnodes, const GRAPH *g, BIDECOMP *bidecomp)
void bidecomposition_markSub(const BIDECOMP *bidecomp, int compindex, GRAPH *g)
void bidecomposition_cutnodesCompute(const GRAPH *g, CUTNODES *cutnodes)
static SCIP_Bool decomposeCsrIsValid(const CUTNODES *cutnodes, const GRAPH *g, const BIDECOMP *bidecomp)
SCIP_Real bidecomposition_getMaxcompNodeRatio(const BIDECOMP *bidecomp)
SCIP_RETCODE bidecomposition_cutnodesInit(SCIP *scip, const GRAPH *g, CUTNODES **cutnodes)
#define SCIPallocBufferArray(scip, ptr, num)
SCIP_RETCODE bidecomposition_initSubInOut(SCIP *scip, const GRAPH *g, BIDECOMP *bidecomposition)
SCIP_Bool graph_isMarked(const GRAPH *)
const int * graph_subinoutGetOrgToSubNodeMap(const SUBINOUT *)
static void cutNodesProcessComponent(int root, int stack_start, CUTNODES *cutnodes)
void bidecomposition_cutnodesFree(SCIP *scip, CUTNODES **cutnodes)
#define StpVecIsEmpty(vec)
#define SCIPfreeMemory(scip, ptr)
SCIP_Bool graph_pc_knotIsDummyTerm(const GRAPH *, int)
SCIP_RETCODE graph_subinoutInit(SCIP *, const GRAPH *, SUBINOUT **)
static SCIP_RETCODE decomposeGetFirstMarked(SCIP *scip, const GRAPH *orggraph, int *subroot)
static void cutNodesComputeDfs(const GRAPH *g, int node, int parent, CUTNODES *cutnodes)
SCIP_Bool graph_pc_isPcMw(const GRAPH *)
#define StpVecFree(scip, vec)
int graph_get_nNodes(const GRAPH *)
#define SCIPallocMemory(scip, ptr)
SCIP_Bool graph_knot_isInRange(const GRAPH *, int)
#define StpVecPushBack(scip, vec, value)
SCIP_Bool bidecomposition_componentIsTrivial(const BIDECOMP *bidecomp, int compindex)
SCIP_RETCODE bidecomposition_getMarkedSubRoot(SCIP *scip, const BIDECOMP *bidecomp, const GRAPH *orggraph, const GRAPH *subgraph, int *subroot)
SCIP_RETCODE bidecomposition_init(SCIP *scip, const CUTNODES *cutnodes, const GRAPH *g, BIDECOMP **bidecomposition)