CMR  1.3.0
seymour_internal.h
Go to the documentation of this file.
1 #ifndef CMR_SEYMOUR_INTERNAL_H
2 #define CMR_SEYMOUR_INTERNAL_H
3 
4 #include <time.h>
5 
6 #include "densematrix.h"
7 
8 #include <cmr/matroid.h>
9 #include <cmr/seymour.h>
10 #include <cmr/series_parallel.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 
18 {
19  size_t used;
21  bool isTernary;
23  int8_t regularity;
25  int8_t graphicness;
27  int8_t cographicness;
29  bool testedR10;
34  size_t numChildren;
41  size_t numRows;
42  size_t* rowsToChild;
45  size_t numColumns;
46  size_t* columnsToChild;
49  size_t memMinors;
50  size_t numMinors;
67  size_t* pivotRows;
68  size_t* pivotColumns;
69  size_t numPivots;
93 };
94 
95 typedef struct DecompositionTask
96 {
101  clock_t startClock;
102  double timeLimit;
104 
105 
118  bool recurse
119 );
120 
125 CMR_EXPORT
127  CMR* cmr,
128  CMR_SEYMOUR_NODE* child,
129  CMR_SEYMOUR_NODE* parent,
130  size_t childIndex,
131  FILE* stream,
132  size_t indent,
133  bool printChildren,
134  bool printParentElements,
135  bool printMatrices,
136  bool printGraphs,
137  bool printReductions,
138  bool printPivots
139 );
140 
148  CMR* cmr,
150  CMR_MINOR* minor
151 );
152 
158  CMR* cmr,
160  size_t numChildren
161 );
162 
168  CMR* cmr,
170  size_t numChildren
171 );
172 
180  CMR* cmr,
181  CMR_SEYMOUR_NODE* parent,
182  size_t childIndex,
183  CMR_CHRMAT* matrix,
184  CMR_CHRMAT* transpose,
185  CMR_ELEMENT* rowsToParent,
186  CMR_ELEMENT* columnsToParent
187 );
188 
194  CMR* cmr,
196  CMR_SUBMAT* violator
197 );
198 
203  CMR* cmr,
205  CMR_SUBMAT* reducedSubmatrix
206 );
207 
215  CMR* cmr,
217  CMR_SEPA* separation
218 );
219 
227  CMR* cmr,
229  size_t numPivots,
230  size_t* pivotRows,
231  size_t* pivotColumns,
232  CMR_CHRMAT* matrix,
233  CMR_CHRMAT* transpose
234 );
235 
243  CMR* cmr,
245 );
246 
254  CMR* cmr,
256  size_t* rowsToChild,
257  size_t* columnsToChild,
258  size_t numChildBaseRows,
259  size_t numChildBaseColumns,
260  size_t extraRow,
261  size_t extraColumn1,
262  size_t extraColumn2,
263  int8_t extraEntry
264 );
265 
273  CMR* cmr,
275  size_t* rowsToChild,
276  size_t* columnsToChild,
277  size_t numChildBaseRows,
278  size_t numChildBaseColumns,
279  size_t extraRow,
280  size_t extraColumn1,
281  size_t extraColumn2,
282  int8_t extraEntry
283 );
284 
292  CMR* cmr,
294  size_t* rowsToChild,
295  size_t* columnsToChild,
296  size_t numChildBaseRows,
297  size_t numChildBaseColumns,
298  size_t extraRow1,
299  size_t extraRow2,
300  int8_t extraEntry
301 );
302 
310  CMR* cmr,
312  size_t* rowsToChild,
313  size_t* columnsToChild,
314  size_t numChildBaseRows,
315  size_t numChildBaseColumns,
316  size_t extraColumn1,
317  size_t extraColumn2,
318  int8_t extraEntry
319 );
320 
327 );
328 
329 
335  CMR* cmr,
336  CMR_SEYMOUR_NODE* dec,
337  DecompositionTask** ptask,
340  clock_t startClock,
341  double timeLimit
342 );
343 
349  CMR* cmr,
350  DecompositionTask** ptask
351 );
352 
353 typedef struct DecompositionQueue
354 {
360 
366  CMR* cmr,
367  DecompositionQueue** pqueue
368 );
369 
375  CMR* cmr,
376  DecompositionQueue** pqueue
377 );
378 
384  DecompositionQueue* queue
385 );
386 
392  DecompositionQueue* queue
393 );
394 
395 
401  DecompositionQueue* queue,
402  DecompositionTask* task
403 );
404 
409 CMR_ERROR
411  CMR* cmr,
412  DecompositionTask* task,
413  DecompositionQueue* queue,
414  CMR_SEPA* separation
415 );
416 
421 CMR_ERROR
423  CMR* cmr,
424  DecompositionTask* task,
425  DecompositionQueue* queue
426 );
427 
434 CMR_ERROR
436  CMR* cmr,
437  DecompositionTask* task,
438  DecompositionQueue* queue
439 );
440 
447 CMR_ERROR
449  CMR* cmr,
450  DecompositionTask* task,
451  DecompositionQueue* queue
452 );
453 
461 CMR_ERROR
463  CMR* cmr,
464  DecompositionTask* task,
465  DecompositionQueue* queue
466 );
467 
473  CMR* cmr,
474  DecompositionTask* task,
475  DecompositionQueue* queue
476 );
477 
483  CMR* cmr,
484  DecompositionTask* task,
485  CMR_SUBMAT* wheelSubmatrix
486 );
487 
499  CMR* cmr,
500  DecompositionTask* task,
501  DecompositionQueue* queue
502 );
503 
509  CMR* cmr,
510  DecompositionTask* task,
511  DecompositionQueue* queue
512 );
513 
519  CMR* cmr,
520  DecompositionTask* task,
521  DecompositionQueue* queue
522 );
523 
533  CMR* cmr,
534  DecompositionTask* task,
535  DecompositionQueue* queue
536 );
537 
548  CMR* cmr,
549  CMR_CHRMAT* matrix,
550  bool ternary,
551  CMR_SEYMOUR_NODE** proot,
552  CMR_SEYMOUR_PARAMS* params,
553  CMR_SEYMOUR_STATS* stats,
554  double timeLimit
555 );
556 
562  CMR* cmr,
563  CMR_SEYMOUR_NODE* subtree,
564  CMR_SEYMOUR_PARAMS* params,
565  CMR_SEYMOUR_STATS* stats,
566  double timeLimit
567 );
568 
574  CMR* cmr,
575  size_t numNodes,
576  CMR_SEYMOUR_NODE** nodes,
577  CMR_SEYMOUR_PARAMS* params,
578  CMR_SEYMOUR_STATS* stats,
579  double timeLimit
580 );
581 
582 #ifdef __cplusplus
583 }
584 #endif
585 
586 #endif /* CMR_SEYMOUR_INTERNAL_H */
int CMR_ELEMENT
Definition: element.h:20
CMR_ERROR
Type for return codes of library functions.
Definition: env.h:32
int CMR_GRAPH_EDGE
Reference to an edge of CMR_GRAPH.
Definition: graph.h:31
CMR_SEYMOUR_THREESUM_FLAG
Flags that indicate the type of -separation.
Definition: seymour.h:40
CMR_SEYMOUR_NODE_TYPE
Definition: seymour.h:212
Functionality for matroids.
Recognition of series-parallel matrices.
Functionality for Seymour decomposition.
CMR_ERROR CMRregularityNestedMinorSequenceSearchThreeSeparation(CMR *cmr, DecompositionTask *task, DecompositionQueue *queue)
Searches for 3-separations along the sequence of nested minors and decomposes as a 3-sum.
Definition: regularity_partition.c:733
CMR_ERROR CMRregularityTestGraphicness(CMR *cmr, DecompositionTask *task, DecompositionQueue *queue)
Tests matrix for graphicness/network and stores it in dec.
Definition: regularity_graphic.c:1792
CMR_ERROR CMRregularityTestR10(CMR *cmr, DecompositionTask *task, DecompositionQueue *queue)
Tests matrix for representing .
Definition: regularity_r10.c:8
CMR_ERROR CMRseymourAddMinor(CMR *cmr, CMR_SEYMOUR_NODE *node, CMR_MINOR *minor)
Adds a minor to a Seymour decomposition node.
Definition: seymour.c:913
CMR_ERROR CMRregularityDecomposeThreeSum(CMR *cmr, DecompositionTask *task, DecompositionQueue *queue, CMR_SEPA *separation)
Applies a 3-sum decomposition.
Definition: regularity_threesum.c:224
struct DecompositionQueue DecompositionQueue
CMR_ERROR CMRregularityInitNestedMinorSequence(CMR *cmr, DecompositionTask *task, CMR_SUBMAT *wheelSubmatrix)
Initializes a sequence of nested minors with one minor, for a given wheelSubmatrix.
Definition: regularity_nested_minor_sequence.c:1052
CMR_ERROR CMRregularityRefineDecomposition(CMR *cmr, size_t numNodes, CMR_SEYMOUR_NODE **nodes, CMR_SEYMOUR_PARAMS *params, CMR_SEYMOUR_STATS *stats, double timeLimit)
Replaces the subtrees of several nodes of a matroid decomposition tree by new ones.
Definition: seymour.c:2352
CMR_ERROR CMRregularitySearchOneSum(CMR *cmr, DecompositionTask *task, DecompositionQueue *queue)
Performs a 1-sum decomposition of matrix and stores it in dec.
Definition: regularity_onesum.c:20
CMR_ERROR CMRseymourUpdateThreeSumCreateMixedFirstChild(CMR *cmr, CMR_SEYMOUR_NODE *node, size_t *rowsToChild, size_t *columnsToChild, size_t numChildBaseRows, size_t numChildBaseColumns, size_t extraRow1, size_t extraRow2, int8_t extraEntry)
Creates mixed first child of an initialized 3-sum node.
Definition: seymour.c:1508
CMR_ERROR CMRseymourCreateChildFromMatrices(CMR *cmr, CMR_SEYMOUR_NODE *parent, size_t childIndex, CMR_CHRMAT *matrix, CMR_CHRMAT *transpose, CMR_ELEMENT *rowsToParent, CMR_ELEMENT *columnsToParent)
Creates a decomposition node as a child.
Definition: seymour.c:966
void CMRregularityQueueAdd(DecompositionQueue *queue, DecompositionTask *task)
Adds a task to a decomposition queue.
Definition: seymour.c:2138
CMR_ERROR CMRseymourUpdateViolator(CMR *cmr, CMR_SEYMOUR_NODE *node, CMR_SUBMAT *violator)
Initialize an existing unknown decomposition node to be irregular with a violator submatrix.
Definition: seymour.c:1051
CMR_ERROR CMRseymourSetNumChildren(CMR *cmr, CMR_SEYMOUR_NODE *node, size_t numChildren)
Sets the number of children and allocates memory accordingly.
Definition: seymour.c:945
DecompositionTask * CMRregularityQueueRemove(DecompositionQueue *queue)
Removes a task from a decomposition queue.
Definition: seymour.c:2128
CMR_ERROR CMRseymourUpdateSeriesParallel(CMR *cmr, CMR_SEYMOUR_NODE *node, CMR_SUBMAT *reducedSubmatrix)
Updates an existing unknown Seymour decomposition node to be a series-parallel node.
Definition: seymour.c:1068
CMR_ERROR CMRregularityTaskCreateRoot(CMR *cmr, CMR_SEYMOUR_NODE *dec, DecompositionTask **ptask, CMR_SEYMOUR_PARAMS *params, CMR_SEYMOUR_STATS *stats, clock_t startClock, double timeLimit)
Creates a decomposition task for the root of the decomposition.
Definition: seymour.c:2050
CMR_ERROR CMRseymourDecompose(CMR *cmr, CMR_CHRMAT *matrix, bool ternary, CMR_SEYMOUR_NODE **proot, CMR_SEYMOUR_PARAMS *params, CMR_SEYMOUR_STATS *stats, double timeLimit)
Tests ternary or binary linear matroid for regularity.
Definition: seymour.c:2234
CMR_ERROR CMRregularityQueueCreate(CMR *cmr, DecompositionQueue **pqueue)
Initializes a decomposition queue.
Definition: seymour.c:2085
CMR_ERROR CMRregularityExtendNestedMinorSequence(CMR *cmr, DecompositionTask *task, DecompositionQueue *queue)
Extends an incomplete sequence of nested 3-connected minors for the matrix of a decomposition node.
Definition: regularity_nested_minor_sequence.c:627
CMR_ERROR CMRregularityQueueFree(CMR *cmr, DecompositionQueue **pqueue)
Frees the decomposition queue.
Definition: seymour.c:2100
CMR_ERROR CMRseymourUpdateThreeSumInit(CMR *cmr, CMR_SEYMOUR_NODE *node)
Initialize an existing unknown decomposition node as a 3-sum node.
Definition: seymour.c:1209
CMR_ERROR CMRseymourUpdateThreeSumCreateMixedSecondChild(CMR *cmr, CMR_SEYMOUR_NODE *node, size_t *rowsToChild, size_t *columnsToChild, size_t numChildBaseRows, size_t numChildBaseColumns, size_t extraColumn1, size_t extraColumn2, int8_t extraEntry)
Creates mixed second child of an initialized 3-sum node.
Definition: seymour.c:1641
CMR_ERROR CMRseymourUpdateTwoSum(CMR *cmr, CMR_SEYMOUR_NODE *node, CMR_SEPA *separation)
Initialize an existing unknown decomposition node as a 2-separation node according to the given separ...
Definition: seymour.c:1090
CMR_ERROR CMRregularityNestedMinorSequenceGraphicness(CMR *cmr, DecompositionTask *task, DecompositionQueue *queue)
Tests each minor of the sequence of nested 3-connected minors for graphicness.
Definition: regularity_graphic.c:1623
CMR_ERROR CMRseymourUpdateOneSum(CMR *cmr, CMR_SEYMOUR_NODE *node, size_t numChildren)
Initialize an existing unknown decomposition node as a 1-sum with numChildren children.
Definition: seymour.c:1009
CMR_ERROR CMRseymourSetAttributes(CMR_SEYMOUR_NODE *node)
Set regularity and (co)graphicness attributes of a decomposition tree.
Definition: seymour.c:1799
CMR_ERROR CMRseymourUpdatePivots(CMR *cmr, CMR_SEYMOUR_NODE *node, size_t numPivots, size_t *pivotRows, size_t *pivotColumns, CMR_CHRMAT *matrix, CMR_CHRMAT *transpose)
Initialize an existing unknown decomposition node as a pivot node according to the given arrays of pi...
Definition: seymour.c:1173
CMR_ERROR CMRregularityNestedMinorSequenceCographicness(CMR *cmr, DecompositionTask *task, DecompositionQueue *queue)
Tests each minor of the sequence of nested 3-connected minors for graphicness.
Definition: regularity_graphic.c:1710
char * CMRseymourConsistency(CMR_SEYMOUR_NODE *node, bool recurse)
Checks a Seymour decomposition node for consistency.
CMR_ERROR CMRregularityTestCographicness(CMR *cmr, DecompositionTask *task, DecompositionQueue *queue)
Tests matrix for cographicness/conetwork and stores it in dec.
Definition: regularity_graphic.c:1877
CMR_ERROR CMRregularityCompleteDecomposition(CMR *cmr, CMR_SEYMOUR_NODE *subtree, CMR_SEYMOUR_PARAMS *params, CMR_SEYMOUR_STATS *stats, double timeLimit)
Replaces the subtree of a matroid decomposition tree by a new one.
Definition: seymour.c:2262
CMR_ERROR CMRseymourUpdateThreeSumCreateWideSecondChild(CMR *cmr, CMR_SEYMOUR_NODE *node, size_t *rowsToChild, size_t *columnsToChild, size_t numChildBaseRows, size_t numChildBaseColumns, size_t extraRow, size_t extraColumn1, size_t extraColumn2, int8_t extraEntry)
Creates wide second child of an initialized 3-sum node.
Definition: seymour.c:1362
bool CMRregularityQueueEmpty(DecompositionQueue *queue)
Returns whether a queue is empty.
Definition: seymour.c:2121
struct DecompositionTask DecompositionTask
CMR_ERROR CMRregularityTaskFree(CMR *cmr, DecompositionTask **ptask)
Frees a decomposition task.
Definition: seymour.c:2072
CMR_EXPORT CMR_ERROR CMRseymourPrintChild(CMR *cmr, CMR_SEYMOUR_NODE *child, CMR_SEYMOUR_NODE *parent, size_t childIndex, FILE *stream, size_t indent, bool printChildren, bool printParentElements, bool printMatrices, bool printGraphs, bool printReductions, bool printPivots)
Prints the decomposition child to stream.
Definition: seymour.c:353
CMR_ERROR CMRseymourUpdateThreeSumCreateWideFirstChild(CMR *cmr, CMR_SEYMOUR_NODE *node, size_t *rowsToChild, size_t *columnsToChild, size_t numChildBaseRows, size_t numChildBaseColumns, size_t extraRow, size_t extraColumn1, size_t extraColumn2, int8_t extraEntry)
Creates wide first child of an initialized 3-sum node.
Definition: seymour.c:1220
CMR_ERROR CMRregularityDecomposeSeriesParallel(CMR *cmr, DecompositionTask *task, DecompositionQueue *queue)
Splits off series-parallel elements from the matrix of the decomposition node.
Definition: regularity_series_parallel.c:10
Row-wise representation of sparse char matrix.
Definition: matrix.h:220
Definition: env_internal.h:45
Definition: graph.h:49
A minor of a matroid.
Definition: matroid.h:121
Definition: separation.h:52
Parameters for Seymour decomposition algorithm.
Definition: seymour.h:93
Statistics for Seymour decomposition algorithm.
Definition: seymour.h:169
Represents a series-parallel reduction.
Definition: series_parallel.h:61
Row and column indices for a submatrix.
Definition: matrix.h:28
Definition: seymour_internal.h:354
bool foundNongraphicness
Whether non-graphiness was detected for some node.
Definition: seymour_internal.h:357
DecompositionTask * head
Next task to be processed.
Definition: seymour_internal.h:355
bool foundIrregularity
Whether irregularity was detected for some node.
Definition: seymour_internal.h:356
bool foundNoncographicness
Whether non-cographiness was detected for some node.
Definition: seymour_internal.h:358
Definition: seymour_internal.h:96
struct DecompositionTask * next
Next task in queue.
Definition: seymour_internal.h:98
CMR_SEYMOUR_STATS * stats
Statistics for the computation (may be NULL).
Definition: seymour_internal.h:100
clock_t startClock
Clock for the start time.
Definition: seymour_internal.h:101
CMR_SEYMOUR_NODE * node
Decomposition node that shall be processed.
Definition: seymour_internal.h:97
CMR_SEYMOUR_PARAMS * params
Parameters for the computation.
Definition: seymour_internal.h:99
double timeLimit
Time limit to impose.
Definition: seymour_internal.h:102
Dense matrix.
Definition: densematrix.h:17
Definition: seymour_internal.h:18
CMR_GRAPH * graph
Graph represented by this matrix.
Definition: seymour_internal.h:53
int8_t regularity
Matrix is (not) regular/totally unimodularity if positive (negative), or not determined if zero.
Definition: seymour_internal.h:23
CMR_GRAPH * cograph
Graph represented by the transpose of this matrix.
Definition: seymour_internal.h:58
CMR_ELEMENT * nestedMinorsColumnsOriginal
Maps columns of nestedMinorsDense to elements of matrix.
Definition: seymour_internal.h:88
size_t memMinors
Memory allocated for minors/submatrices.
Definition: seymour_internal.h:49
bool * cographArcsReversed
Array indicating which arcs of the cograph are reversed.
Definition: seymour_internal.h:61
CMR_SEYMOUR_THREESUM_FLAG threesumFlags
Type of 3-sum.
Definition: seymour_internal.h:31
CMR_CHRMAT * transpose
Tranpose of matrix representing this node.
Definition: seymour_internal.h:33
bool testedTwoConnected
Indicates that no 1-separation exists.
Definition: seymour_internal.h:22
size_t numPivots
Number of pivots.
Definition: seymour_internal.h:69
CMR_CHRMAT * nestedMinorsTranspose
Transpose of nestedMinorsMatrix.
Definition: seymour_internal.h:85
size_t numMinors
Number of minors/submatrices.
Definition: seymour_internal.h:50
size_t * columnsToChild
Array for mapping each column to a column of the child (if applicable).
Definition: seymour_internal.h:46
size_t numChildren
Number of child nodes.
Definition: seymour_internal.h:34
size_t nestedMinorsLength
Length of sequence of nested minors.
Definition: seymour_internal.h:79
int8_t cographicness
Matrix is (not) cographic/conetwork if positive (negative), or not determined if zero.
Definition: seymour_internal.h:27
CMR_ELEMENT * denseColumnsOriginal
Maps columns of denseMatrix to elements of matrix.
Definition: seymour_internal.h:74
bool * graphArcsReversed
Array indicating which arcs of the graph are reversed.
Definition: seymour_internal.h:56
size_t * nestedMinorsSequenceNumColumns
Number of columns of sequence of nested minors.
Definition: seymour_internal.h:81
bool testedR10
Matrix does not represent unless type indicates this.
Definition: seymour_internal.h:29
CMR_GRAPH_EDGE * cographForest
Array with edges of spanning forest of cograph.
Definition: seymour_internal.h:59
CMR_ELEMENT * denseRowsOriginal
Maps rows of denseMatrix to elements of matrix.
Definition: seymour_internal.h:73
CMR_MINOR ** minors
Array of minors/submatrices containing more information.
Definition: seymour_internal.h:51
size_t * nestedMinorsSequenceNumRows
Number of rows of sequence of nested minors.
Definition: seymour_internal.h:80
struct _CMR_SEYMOUR_NODE ** children
Array of child nodes.
Definition: seymour_internal.h:35
CMR_GRAPH_EDGE * graphForest
Array with edges of spanning forest of graph.
Definition: seymour_internal.h:54
int8_t graphicness
Matrix is (not) graphic/network if positive (negative), or not determined if zero.
Definition: seymour_internal.h:25
size_t * pivotRows
Rows of pivots.
Definition: seymour_internal.h:67
bool testedSeriesParallel
Already searched for series-parallel reductions.
Definition: seymour_internal.h:63
size_t numColumns
Length of columnsToChild.
Definition: seymour_internal.h:45
size_t * nestedMinorsRowsDense
Maps rows of nested minor sequence to rows of dense.
Definition: seymour_internal.h:75
size_t nestedMinorsLastGraphic
Last minor in sequence of nested minors that is graphic.
Definition: seymour_internal.h:91
size_t nestedMinorsLastCographic
Last minor in sequence of nested minors that is cographic.
Definition: seymour_internal.h:92
CMR_CHRMAT * nestedMinorsMatrix
Sparse support matrix that displays the sequence of nested minors. Rows and columns are permuted acco...
Definition: seymour_internal.h:83
CMR_ELEMENT ** childRowsToParent
Array for mapping a child index to array of child rows to elements of this node.
Definition: seymour_internal.h:36
CMR_SEYMOUR_NODE_TYPE type
Type of this node.
Definition: seymour_internal.h:20
CMR_ELEMENT ** childColumnsToParent
Array for mapping a child index to array of child columns to elements of this node.
Definition: seymour_internal.h:38
CMR_GRAPH_EDGE * cographCoforest
Array with edges of coforest of cograph.
Definition: seymour_internal.h:60
size_t numSeriesParallelReductions
Length of reductions.
Definition: seymour_internal.h:65
size_t used
Reference counter.
Definition: seymour_internal.h:19
DenseBinaryMatrix * denseMatrix
Dense support matrix for nested minors search. Rows and columns are not permuted, but pivots are appl...
Definition: seymour_internal.h:71
CMR_ELEMENT * nestedMinorsRowsOriginal
Maps rows of nestedMinorsMatrix to elements of matrix.
Definition: seymour_internal.h:86
size_t numRows
Length of rowsToChild.
Definition: seymour_internal.h:41
size_t * rowsToChild
Array for mapping each row to a row of the child (if applicable).
Definition: seymour_internal.h:42
size_t * nestedMinorsColumnsDense
Maps columns of nested minor sequence to columns of dense.
Definition: seymour_internal.h:76
bool isTernary
Indicates whether this node belongs to a ternary matrix.
Definition: seymour_internal.h:21
CMR_GRAPH_EDGE * graphCoforest
Array with edges of coforest of graph.
Definition: seymour_internal.h:55
CMR_CHRMAT * matrix
Matrix representing this node.
Definition: seymour_internal.h:32
CMR_SP_REDUCTION * seriesParallelReductions
Array of series-parallel reductions.
Definition: seymour_internal.h:64
size_t * pivotColumns
Columns of pivots.
Definition: seymour_internal.h:68