CMR  1.3.0
matroid.h
Go to the documentation of this file.
1 #ifndef CMR_MATROID_H
2 #define CMR_MATROID_H
3 
12 #include <cmr/env.h>
13 #include <cmr/matrix.h>
14 #include <cmr/graph.h>
15 
16 #include <stdio.h>
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
34 CMR_EXPORT
36  CMR* cmr,
37  CMR_CHRMAT* matrix,
38  size_t pivotRow,
39  size_t pivotColumn,
40  CMR_CHRMAT** presult
41 );
42 
49 CMR_EXPORT
51  CMR* cmr,
52  CMR_CHRMAT* matrix,
53  size_t pivotRow,
54  size_t pivotColumn,
55  CMR_CHRMAT** presult
56 );
57 
64 CMR_EXPORT
66  CMR* cmr,
67  CMR_CHRMAT* matrix,
68  size_t numPivots,
69  size_t* pivotRows,
70  size_t* pivotColumns,
71  CMR_CHRMAT** presult
72 );
73 
80 CMR_EXPORT
82  CMR* cmr,
83  CMR_CHRMAT* matrix,
84  size_t numPivots,
85  size_t* pivotRows,
86  size_t* pivotColumns,
87  CMR_CHRMAT** presult
88 );
89 
96 typedef struct
97 {
98  size_t numPivots;
99  size_t* pivotRows;
100  size_t* pivotColumns;
102 } CMR_MINOR;
103 
108 CMR_EXPORT
110  CMR* cmr,
111  CMR_MINOR** pminor,
112  size_t numPivots,
113  CMR_SUBMAT* submatrix
114 );
115 
120 CMR_EXPORT
122  CMR* cmr,
123  CMR_MINOR** pminor
124 );
125 
131 CMR_EXPORT
133  CMR* cmr,
134  CMR_MINOR* minor,
135  size_t numRows,
136  size_t numColumns,
137  FILE* stream
138 );
139 
145 CMR_EXPORT
147  CMR* cmr,
148  CMR_MINOR* minor,
149  size_t numRows,
150  size_t numColumns,
151  const char* fileName
152 );
153 
154 
155 struct _CMR_MATROID_DEC;
156 
157 typedef struct _CMR_MATROID_DEC CMR_MATROID_DEC;
158 
159 typedef enum
160 {
204 
211 typedef enum
212 {
259 
264 CMR_EXPORT
266  CMR_MATROID_DEC* dec
267 );
268 
273 CMR_EXPORT
275  CMR_MATROID_DEC* dec
276 );
277 
282 CMR_EXPORT
284  CMR_MATROID_DEC* dec
285 );
286 
291 CMR_EXPORT
293  CMR_MATROID_DEC* dec
294 );
295 
300 CMR_EXPORT
302  CMR_MATROID_DEC* dec
303 );
304 
309 CMR_EXPORT
311  CMR_MATROID_DEC* dec
312 );
313 
318 CMR_EXPORT
320  CMR_MATROID_DEC* dec
321 );
322 
327 CMR_EXPORT
329  CMR_MATROID_DEC* dec,
330  size_t childIndex
331 );
332 
337 CMR_EXPORT
339  CMR_MATROID_DEC* dec
340 );
341 
349 CMR_EXPORT
351  CMR_MATROID_DEC* dec
352 );
353 
361 CMR_EXPORT
363  CMR_MATROID_DEC* dec
364 );
365 
373 CMR_EXPORT
375  CMR_MATROID_DEC* dec
376 );
377 
382 CMR_EXPORT
383 size_t CMRmatroiddecNumRows(
384  CMR_MATROID_DEC* dec
385 );
386 
391 CMR_EXPORT
393  CMR_MATROID_DEC* dec
394 );
395 
400 CMR_EXPORT
402  CMR_MATROID_DEC* dec,
403  size_t childIndex
404 );
405 
410 CMR_EXPORT
412  CMR_MATROID_DEC* dec,
413  size_t childIndex
414 );
415 
420 CMR_EXPORT
422  CMR_MATROID_DEC* dec
423 );
424 
429 CMR_EXPORT
431  CMR_MATROID_DEC* dec
432 );
433 
438 CMR_EXPORT
440  CMR_MATROID_DEC* dec
441 );
442 
447 CMR_EXPORT
449  CMR_MATROID_DEC* dec
450 );
451 
456 CMR_EXPORT
458  CMR_MATROID_DEC* dec
459 );
460 
465 CMR_EXPORT
467  CMR_MATROID_DEC* dec
468 );
469 
474 CMR_EXPORT
476  CMR_MATROID_DEC* dec
477 );
478 
483 CMR_EXPORT
485  CMR_MATROID_DEC* dec
486 );
487 
492 CMR_EXPORT
494  CMR_MATROID_DEC* dec
495 );
496 
501 CMR_EXPORT
503  CMR_MATROID_DEC* dec
504 );
505 
510 CMR_EXPORT
512  CMR_MATROID_DEC* dec
513 );
514 
519 CMR_EXPORT
521  CMR_MATROID_DEC* dec
522 );
523 
528 CMR_EXPORT
530  CMR_MATROID_DEC* dec
531 );
532 
537 CMR_EXPORT
538 size_t* CMRmatroiddecPivotRows(
539  CMR_MATROID_DEC* dec
540 );
541 
546 CMR_EXPORT
548  CMR_MATROID_DEC* dec
549 );
550 
555 CMR_EXPORT
557  CMR* cmr,
558  CMR_MATROID_DEC* dec,
559  FILE* stream,
560  bool printChildren,
561  bool printParentElements,
562  bool printMatrices,
563  bool printGraphs,
564  bool printReductions,
565  bool printPivots
566 );
567 
573 CMR_EXPORT
575  CMR* cmr,
576  CMR_MATROID_DEC* dec,
577  CMR_MATROID_DEC** pclone
578 );
579 
584 CMR_EXPORT
586  CMR* cmr,
587  CMR_MATROID_DEC* dec
588 );
589 
597 CMR_EXPORT
599  CMR* cmr,
600  CMR_MATROID_DEC** pdec
601 );
602 
610  CMR* cmr,
611  CMR_MATROID_DEC** pdec,
612  bool isTernary,
614 );
615 
618 #ifdef __cplusplus
619 }
620 #endif
621 
622 #endif /* CMR_MATROID_H */
int CMR_ELEMENT
Definition: element.h:20
Basic functionality of the software library.
CMR_ERROR
Type for return codes of library functions.
Definition: env.h:32
Functionality for graphs.
int CMR_GRAPH_EDGE
Reference to an edge of CMR_GRAPH.
Definition: graph.h:31
CMR_EXPORT size_t CMRmatroiddecGraphSizeCoforest(CMR_MATROID_DEC *dec)
Returns the number of edges of the graph's coforest (if available).
Definition: matroid.c:500
CMR_EXPORT CMR_ERROR CMRchrmatTernaryPivot(CMR *cmr, CMR_CHRMAT *matrix, size_t pivotRow, size_t pivotColumn, CMR_CHRMAT **presult)
Applies a sequence of pivots to matrix and returns the resulting matrix in *presult.
Definition: matroid.c:229
CMR_EXPORT size_t CMRmatroiddecCographSizeCoforest(CMR_MATROID_DEC *dec)
Returns the number of edges of the cograph's coforest (if available).
Definition: matroid.c:549
CMR_EXPORT CMR_ERROR CMRchrmatBinaryPivots(CMR *cmr, CMR_CHRMAT *matrix, size_t numPivots, size_t *pivotRows, size_t *pivotColumns, CMR_CHRMAT **presult)
Applies a sequence of pivots to matrix and returns the resulting matrix in *presult.
Definition: matroid.c:242
CMR_EXPORT bool CMRmatroiddecHasTranspose(CMR_MATROID_DEC *dec)
Returns true iff the transposed matrix of the decomposition node dec is stored.
Definition: matroid.c:373
CMR_EXPORT bool CMRmatroiddecThreeSumDistributedRanks(CMR_MATROID_DEC *dec)
Returns true iff the 3-sum decomposition node has -separation with two rank-1 matrices.
Definition: matroid.c:350
CMR_EXPORT CMR_ERROR CMRmatroiddecPrint(CMR *cmr, CMR_MATROID_DEC *dec, FILE *stream, bool printChildren, bool printParentElements, bool printMatrices, bool printGraphs, bool printReductions, bool printPivots)
Prints the decomposition dec to stream.
Definition: matroid.c:832
CMR_EXPORT bool CMRmatroiddecIsTernary(CMR_MATROID_DEC *dec)
Returns true iff the decomposition is over .
Definition: matroid.c:343
CMR_EXPORT CMR_ERROR CMRchrmatTernaryPivots(CMR *cmr, CMR_CHRMAT *matrix, size_t numPivots, size_t *pivotRows, size_t *pivotColumns, CMR_CHRMAT **presult)
Applies a sequence of pivots to matrix and returns the resulting matrix in *presult.
Definition: matroid.c:256
CMR_EXPORT int8_t CMRmatroiddecGraphicness(CMR_MATROID_DEC *dec)
Indicates graphicness/being network.
Definition: matroid.c:410
CMR_EXPORT size_t CMRmatroiddecCographSizeForest(CMR_MATROID_DEC *dec)
Returns the number of edges of the cograph's forest (if available).
Definition: matroid.c:528
CMR_EXPORT CMR_GRAPH * CMRmatroiddecCograph(CMR_MATROID_DEC *dec)
Returns the cograph (if available).
Definition: matroid.c:521
CMR_EXPORT size_t CMRmatroiddecNumColumns(CMR_MATROID_DEC *dec)
Returns the number of columns.
Definition: matroid.c:458
CMR_EXPORT int8_t CMRmatroiddecCographicness(CMR_MATROID_DEC *dec)
Indicates cographicness/being conetwork.
Definition: matroid.c:417
CMR_ERROR CMRmatroiddecCreateMatrixRoot(CMR *cmr, CMR_MATROID_DEC **pdec, bool isTernary, CMR_CHRMAT *matrix)
Creates an unknown decomposition node as a root.
Definition: matroid.c:1149
CMR_EXPORT CMR_ERROR CMRmatroiddecRelease(CMR *cmr, CMR_MATROID_DEC **pdec)
Releases a decomposition node, freeing it if this was the last reference.
Definition: matroid.c:854
CMR_EXPORT CMR_ELEMENT * CMRmatroiddecChildColumnsToParent(CMR_MATROID_DEC *dec, size_t childIndex)
Returns the mapping of columns of child childIndex to this node's elements.
Definition: matroid.c:448
CMR_EXPORT int8_t CMRmatroiddecRegularity(CMR_MATROID_DEC *dec)
Indicates regularity/total unimodularity.
Definition: matroid.c:424
CMR_MATROID_DEC_TYPE
Definition: matroid.h:160
CMR_EXPORT CMR_ERROR CMRchrmatBinaryPivot(CMR *cmr, CMR_CHRMAT *matrix, size_t pivotRow, size_t pivotColumn, CMR_CHRMAT **presult)
Applie a pivot to matrix and returns the resulting matrix in *presult.
Definition: matroid.c:218
CMR_EXPORT CMR_GRAPH_EDGE * CMRmatroiddecGraphForest(CMR_MATROID_DEC *dec)
Returns the forest of the graph (if available).
Definition: matroid.c:472
CMR_EXPORT CMR_ERROR CMRminorPrint(CMR *cmr, CMR_MINOR *minor, size_t numRows, size_t numColumns, FILE *stream)
Writes the minor minor to the file \fileName by means of lists of row and column indices as well as p...
Definition: matroid.c:306
CMR_EXPORT CMR_CHRMAT * CMRmatroiddecGetMatrix(CMR_MATROID_DEC *dec)
Returns the matrix of the decomposition node dec (or NULL if it is not stored).
Definition: matroid.c:366
CMR_MATROID_DEC_THREESUM_FLAG
Flags that indicate the type of -separation.
Definition: matroid.h:212
CMR_EXPORT CMR_ELEMENT * CMRmatroiddecChildRowsToParent(CMR_MATROID_DEC *dec, size_t childIndex)
Returns the mapping of rows of child childIndex to this node's elements.
Definition: matroid.c:438
CMR_EXPORT CMR_ERROR CMRminorWriteToFile(CMR *cmr, CMR_MINOR *minor, size_t numRows, size_t numColumns, const char *fileName)
Writes the minor minor to the file \fileName by means of lists of row and column indices as well as p...
Definition: matroid.c:318
CMR_EXPORT CMR_ERROR CMRminorCreate(CMR *cmr, CMR_MINOR **pminor, size_t numPivots, CMR_SUBMAT *submatrix)
Creates a minor, allocating space for numPivots pivots and a remaining submatrix.
Definition: matroid.c:273
CMR_EXPORT size_t CMRmatroiddecNumPivots(CMR_MATROID_DEC *dec)
Returns the number of pivots (if available).
Definition: matroid.c:577
CMR_EXPORT bool * CMRmatroiddecCographArcsReversed(CMR_MATROID_DEC *dec)
Returns an array that indicates for the cograph's edges whether they must be reversed (if available).
Definition: matroid.c:570
CMR_EXPORT bool * CMRmatroiddecGraphArcsReversed(CMR_MATROID_DEC *dec)
Returns an array that indicates for the graph's edges whether they must be reversed (if available).
Definition: matroid.c:514
CMR_EXPORT CMR_ERROR CMRminorFree(CMR *cmr, CMR_MINOR **pminor)
Frees the minor *pminor (if pminor is not NULL).
Definition: matroid.c:289
CMR_EXPORT size_t CMRmatroiddecGraphSizeForest(CMR_MATROID_DEC *dec)
Returns the number of edges of the graph's forest (if available).
Definition: matroid.c:479
CMR_EXPORT size_t CMRmatroiddecNumChildren(CMR_MATROID_DEC *dec)
Returns the number of children of the decomposition node dec.
Definition: matroid.c:388
CMR_EXPORT size_t CMRmatroiddecNumRows(CMR_MATROID_DEC *dec)
Returns the number of rows.
Definition: matroid.c:431
CMR_EXPORT CMR_MATROID_DEC_TYPE CMRmatroiddecType(CMR_MATROID_DEC *dec)
Returns the type of a decomposition node dec.
Definition: matroid.c:403
CMR_EXPORT CMR_ERROR CMRmatroiddecCloneUnknown(CMR *cmr, CMR_MATROID_DEC *dec, CMR_MATROID_DEC **pclone)
Clones a decomposition node dec into *pclone which represents the same matrix but has type CMR_MATROI...
Definition: matroid.c:1013
CMR_EXPORT CMR_GRAPH_EDGE * CMRmatroiddecCographForest(CMR_MATROID_DEC *dec)
Returns the forest of the cograph (if available).
Definition: matroid.c:542
CMR_EXPORT size_t * CMRmatroiddecPivotColumns(CMR_MATROID_DEC *dec)
Returns the array with the pivot columns (if available).
Definition: matroid.c:591
CMR_EXPORT CMR_GRAPH * CMRmatroiddecGraph(CMR_MATROID_DEC *dec)
Returns the graph (if available).
Definition: matroid.c:465
CMR_EXPORT CMR_GRAPH_EDGE * CMRmatroiddecCographCoforest(CMR_MATROID_DEC *dec)
Returns the coforest of the cograph (if available).
Definition: matroid.c:563
CMR_EXPORT CMR_MATROID_DEC * CMRmatroiddecChild(CMR_MATROID_DEC *dec, size_t childIndex)
Returns a child of the decomposition node dec.
Definition: matroid.c:395
CMR_EXPORT size_t * CMRmatroiddecPivotRows(CMR_MATROID_DEC *dec)
Returns the array with the pivot rows (if available).
Definition: matroid.c:584
CMR_EXPORT CMR_ERROR CMRmatroiddecCapture(CMR *cmr, CMR_MATROID_DEC *dec)
Increases the reference counter by 1.
Definition: matroid.c:844
CMR_EXPORT CMR_GRAPH_EDGE * CMRmatroiddecGraphCoforest(CMR_MATROID_DEC *dec)
Returns the coforest of the graph (if available).
Definition: matroid.c:493
CMR_EXPORT bool CMRmatroiddecThreeSumConcentratedRank(CMR_MATROID_DEC *dec)
Returns true iff the 3-sum decomposition node has -separation with one rank-2 matrix.
Definition: matroid.c:358
CMR_EXPORT CMR_CHRMAT * CMRmatroiddecGetTranspose(CMR_MATROID_DEC *dec)
Returns the transposed matrix of the decomposition node dec (or NULL if it is not stored).
Definition: matroid.c:380
@ CMR_MATROID_DEC_TYPE_K5_DUAL
Definition: matroid.h:195
@ CMR_MATROID_DEC_TYPE_FANO_DUAL
Definition: matroid.h:191
@ CMR_MATROID_DEC_TYPE_COGRAPH
Definition: matroid.h:182
@ CMR_MATROID_DEC_TYPE_SERIES_PARALLEL
Definition: matroid.h:173
@ CMR_MATROID_DEC_TYPE_R10
Definition: matroid.h:187
@ CMR_MATROID_DEC_TYPE_K5
Definition: matroid.h:193
@ CMR_MATROID_DEC_TYPE_SUBMATRIX
Definition: matroid.h:177
@ CMR_MATROID_DEC_TYPE_IRREGULAR
Definition: matroid.h:161
@ CMR_MATROID_DEC_TYPE_K33
Definition: matroid.h:197
@ CMR_MATROID_DEC_TYPE_ONE_SUM
Definition: matroid.h:165
@ CMR_MATROID_DEC_TYPE_UNKNOWN
Definition: matroid.h:163
@ CMR_MATROID_DEC_TYPE_K33_DUAL
Definition: matroid.h:199
@ CMR_MATROID_DEC_TYPE_GRAPH
Definition: matroid.h:180
@ CMR_MATROID_DEC_TYPE_FANO
Definition: matroid.h:189
@ CMR_MATROID_DEC_TYPE_TWO_SUM
Definition: matroid.h:169
@ CMR_MATROID_DEC_TYPE_PIVOTS
Definition: matroid.h:175
@ CMR_MATROID_DEC_TYPE_DETERMINANT
Definition: matroid.h:201
@ CMR_MATROID_DEC_TYPE_THREE_SUM
Definition: matroid.h:171
@ CMR_MATROID_DEC_TYPE_PLANAR
Definition: matroid.h:184
@ CMR_MATROID_DEC_THREESUM_FLAG_SECOND_TALL
Definition: matroid.h:240
@ CMR_MATROID_DEC_THREESUM_FLAG_FIRST_ALLREPR
Definition: matroid.h:233
@ CMR_MATROID_DEC_THREESUM_FLAG_FIRST_MIXED
Definition: matroid.h:230
@ CMR_MATROID_DEC_THREESUM_FLAG_SECOND_MIXED
Definition: matroid.h:243
@ CMR_MATROID_DEC_THREESUM_FLAG_TRUEMPER
Definition: matroid.h:254
@ CMR_MATROID_DEC_THREESUM_FLAG_FIRST_TALL
Definition: matroid.h:227
@ CMR_MATROID_DEC_THREESUM_FLAG_DISTRIBUTED_RANKS
Definition: matroid.h:217
@ CMR_MATROID_DEC_THREESUM_FLAG_CONCENTRATED_RANK
Definition: matroid.h:220
@ CMR_MATROID_DEC_THREESUM_FLAG_FIRST_WIDE
Definition: matroid.h:224
@ CMR_MATROID_DEC_THREESUM_FLAG_SECOND_ALLREPR
Definition: matroid.h:246
@ CMR_MATROID_DEC_THREESUM_FLAG_SECOND_WIDE
Definition: matroid.h:237
@ CMR_MATROID_DEC_THREESUM_FLAG_NO_PIVOTS
Definition: matroid.h:213
@ CMR_MATROID_DEC_THREESUM_FLAG_SEYMOUR
Definition: matroid.h:250
Functionality for sparse matrices.
Row-wise representation of sparse char matrix.
Definition: matrix.h:204
Definition: env_internal.h:45
Definition: graph.h:49
A minor of a matroid.
Definition: matroid.h:97
size_t * pivotColumns
Definition: matroid.h:100
size_t numPivots
Definition: matroid.h:98
CMR_SUBMAT * remainingSubmatrix
Definition: matroid.h:101
size_t * pivotRows
Definition: matroid.h:99
Row and column indices for a submatrix.
Definition: matrix.h:28
Definition: matroid_internal.h:16
CMR_CHRMAT * matrix
Matrix representing this node.
Definition: matroid_internal.h:30
bool isTernary
Indicates whether this node belongs to a ternary matrix.
Definition: matroid_internal.h:19