CMR  1.3.0
Functions
regular_graphic.c File Reference
#include "regular_internal.h"
#include <cmr/graphic.h>
#include <cmr/network.h>
#include "env_internal.h"
#include "hashtable.h"
#include <stdint.h>
#include <time.h>

Functions

static int dfsArticulationPoint (CMR_GRAPH *graph, bool *edgesEnabled, CMR_GRAPH_NODE node, bool *nodesVisited, int *nodesDiscoveryTime, int *ptime, CMR_GRAPH_NODE parentNode, size_t *nodesArticulationPoint)
 Recursive DFS for finding all articulation points of a graph. More...
 
static CMR_ERROR findArticulationPoints (CMR *cmr, CMR_GRAPH *graph, CMR_GRAPH_EDGE *columnEdges, size_t *nodesArticulationPoint, size_t *nonzeroColumns, size_t numNonzeroColumns)
 
static void dfsTree (CMR_GRAPH *graph, bool *edgesTree, bool *nodesVisited, CMR_GRAPH_NODE *nodesParent, CMR_GRAPH_NODE node)
 
static CMR_ERROR findTreeParents (CMR *cmr, CMR_GRAPH *graph, CMR_GRAPH_EDGE *rowEdges, size_t numRows, CMR_GRAPH_NODE *nodesParent)
 
static void dfsComponents (CMR_GRAPH *graph, bool *edgesEnabled, size_t *nodesComponent, CMR_GRAPH_NODE node, size_t component)
 
static CMR_ERROR findComponents (CMR *cmr, CMR_GRAPH *graph, CMR_GRAPH_EDGE *columnEdges, CMR_GRAPH_NODE removedNode, size_t *nodesComponent, size_t *pnumComponents, size_t *nonzeroColumns, size_t numNonzeroColumns)
 
static bool dfsBipartite (CMR_GRAPH *graph, bool *nodesVisited, int *bipartition, CMR_GRAPH_NODE node)
 DFS for searching for a bipartition. More...
 
static CMR_ERROR findBipartition (CMR *cmr, CMR_GRAPH *graph, int *bipartition, bool *pisBipartite)
 Finds a bipartition of a graph. More...
 
static CMR_ERROR addToGraph1Row (CMR *cmr, CMR_GRAPH *graph, CMR_GRAPH_EDGE *rowEdges, CMR_GRAPH_EDGE *columnEdges, size_t baseNumRows, size_t *nonzeroColumns, size_t numNonzeroColumns, bool *pisGraphic)
 Extends graph for a submatrix augmented by 1 row. More...
 
static CMR_ELEMENT findParallel (CMR_CHRMAT *matrix, size_t row, size_t numRows, size_t numColumns, long long *rowHashValues, long long *hashVector)
 Find element in submatrix parallel to vector. More...
 
static CMR_ERROR createHashVector (CMR *cmr, long long **phashVector, size_t size)
 Creates a hash vector to speed-up recognition of parallel vectors. More...
 
static CMR_ERROR updateHashValues (CMR_CHRMAT *matrix, long long *majorHashValues, long long *minorHashValues, long long *hashVector, size_t majorFirst, size_t majorBeyond, size_t minorSize)
 Update the hash values of rows/column of submatrix that is grown by a number of rows. More...
 
static bool checkEdgesAdjacent (CMR_GRAPH *graph, CMR_GRAPH_EDGE e, CMR_GRAPH_EDGE f, CMR_GRAPH_NODE *pcommon, CMR_GRAPH_NODE *peOther, CMR_GRAPH_NODE *pfOther)
 Returns true if two edges e and f are adjacent. More...
 
static CMR_ERROR addToGraph1Row1Column (CMR *cmr, CMR_GRAPH *graph, CMR_GRAPH_EDGE *rowEdges, CMR_GRAPH_EDGE *columnEdges, size_t baseNumRows, size_t baseNumColumns, CMR_ELEMENT rowParallel, CMR_ELEMENT columnParallel, bool *pisGraphic)
 Extends graph for a submatrix augmented by 1 row and 1 column. More...
 
static CMR_ERROR addToGraph2Rows1Column (CMR *cmr, CMR_GRAPH *graph, CMR_GRAPH_EDGE *rowEdges, CMR_GRAPH_EDGE *columnEdges, size_t baseNumRows, size_t baseNumColumns, CMR_ELEMENT row1Parallel, CMR_ELEMENT row2Parallel, bool *pisGraphic)
 Extends graph for a submatrix augmented by 2 rows and 1 column. More...
 
static CMR_ERROR addToGraph1Row2Columns (CMR *cmr, CMR_GRAPH *graph, CMR_GRAPH_EDGE *rowEdges, CMR_GRAPH_EDGE *columnEdges, size_t baseNumRows, size_t baseNumColumns, CMR_ELEMENT column1Parallel, CMR_ELEMENT column2Parallel, bool *pisGraphic)
 Extends graph for a submatrix augmented by 1 row and 2 columns. More...
 
static CMR_ERROR addToGraph1Column (CMR *cmr, CMR_GRAPH *graph, CMR_GRAPH_EDGE *rowEdges, CMR_GRAPH_EDGE *columnEdges, size_t baseNumColumns, size_t *nonzeroRows, size_t numNonzeroRows, bool *pisGraphic)
 Extends graph for a submatrix augmented by 1 column. More...
 
static CMR_ERROR createWheel (CMR *cmr, CMR_GRAPH *graph, CMR_CHRMAT *matrix, CMR_CHRMAT *transpose, size_t wheelSize, CMR_GRAPH_EDGE *rowEdges, CMR_GRAPH_EDGE *columnEdges)
 Creates the wheel graph for a wheel submatrix. More...
 
CMR_ERROR CMRregularSequenceGraphic (CMR *cmr, CMR_CHRMAT *matrix, CMR_CHRMAT *transpose, size_t lengthSequence, size_t *sequenceNumRows, size_t *sequenceNumColumns, size_t *plastGraphicMinor, CMR_GRAPH **pgraph, CMR_ELEMENT **pedgeElements, CMR_REGULAR_STATISTICS *stats, double timeLimit)
 Tests sequence of nested 3-connected minors for graphicness. More...
 
CMR_ERROR CMRregularTestGraphic (CMR *cmr, CMR_CHRMAT **pmatrix, CMR_CHRMAT **ptranspose, bool ternary, bool *pisGraphic, CMR_GRAPH **pgraph, CMR_GRAPH_EDGE **pforest, CMR_GRAPH_EDGE **pcoforest, bool **parcsReversed, CMR_SUBMAT **psubmatrix, CMR_REGULAR_STATISTICS *stats, double timeLimit)
 Tests matrix for graphicness. More...
 

Function Documentation

◆ addToGraph1Column()

static CMR_ERROR addToGraph1Column ( CMR cmr,
CMR_GRAPH graph,
CMR_GRAPH_EDGE rowEdges,
CMR_GRAPH_EDGE columnEdges,
size_t  baseNumColumns,
size_t *  nonzeroRows,
size_t  numNonzeroRows,
bool *  pisGraphic 
)
static

Extends graph for a submatrix augmented by 1 column.

Parameters
cmrCMR environment.
graphEmpty graph to be filled.
rowEdgesArray to be filled with map from rows to edges.
columnEdgesArray to be filled with map from columns to edges.
baseNumColumnsNumber of columns already processed.
nonzeroRowsArray with rows containing a nonzero.
numNonzeroRowsLength of nonzeroRows.
pisGraphicPointer for storing whether this extension was graphic.

◆ addToGraph1Row()

static CMR_ERROR addToGraph1Row ( CMR cmr,
CMR_GRAPH graph,
CMR_GRAPH_EDGE rowEdges,
CMR_GRAPH_EDGE columnEdges,
size_t  baseNumRows,
size_t *  nonzeroColumns,
size_t  numNonzeroColumns,
bool *  pisGraphic 
)
static

Extends graph for a submatrix augmented by 1 row.

Parameters
cmrCMR environment.
graphEmpty graph to be filled.
rowEdgesArray to be filled with map from rows to edges.
columnEdgesArray to be filled with map from columns to edges.
baseNumRowsNumber of rows already processed.
nonzeroColumnsArray with columns containing a nonzero.
numNonzeroColumnsLength of nonzeroColumns.
pisGraphicPointer for storing whether this extension was graphic.

◆ addToGraph1Row1Column()

static CMR_ERROR addToGraph1Row1Column ( CMR cmr,
CMR_GRAPH graph,
CMR_GRAPH_EDGE rowEdges,
CMR_GRAPH_EDGE columnEdges,
size_t  baseNumRows,
size_t  baseNumColumns,
CMR_ELEMENT  rowParallel,
CMR_ELEMENT  columnParallel,
bool *  pisGraphic 
)
static

Extends graph for a submatrix augmented by 1 row and 1 column.

Parameters
cmrCMR environment.
graphEmpty graph to be filled.
rowEdgesArray to be filled with map from rows to edges.
columnEdgesArray to be filled with map from columns to edges.
baseNumRowsNumber of rows already processed.
baseNumColumnsNumber of columns already processed.
rowParallelElement to which the row is parallel.
columnParallelElement to which the column is parallel.
pisGraphicPointer for storing whether this extension was graphic.

◆ addToGraph1Row2Columns()

static CMR_ERROR addToGraph1Row2Columns ( CMR cmr,
CMR_GRAPH graph,
CMR_GRAPH_EDGE rowEdges,
CMR_GRAPH_EDGE columnEdges,
size_t  baseNumRows,
size_t  baseNumColumns,
CMR_ELEMENT  column1Parallel,
CMR_ELEMENT  column2Parallel,
bool *  pisGraphic 
)
static

Extends graph for a submatrix augmented by 1 row and 2 columns.

Parameters
cmrCMR environment.
graphEmpty graph to be filled.
rowEdgesArray to be filled with map from rows to edges.
columnEdgesArray to be filled with map from columns to edges.
baseNumRowsNumber of rows already processed.
baseNumColumnsNumber of columns already processed.
column1ParallelElement to which column1 is parallel.
column2ParallelElement to which column2 is parallel.
pisGraphicPointer for storing whether this extension was graphic.

◆ addToGraph2Rows1Column()

static CMR_ERROR addToGraph2Rows1Column ( CMR cmr,
CMR_GRAPH graph,
CMR_GRAPH_EDGE rowEdges,
CMR_GRAPH_EDGE columnEdges,
size_t  baseNumRows,
size_t  baseNumColumns,
CMR_ELEMENT  row1Parallel,
CMR_ELEMENT  row2Parallel,
bool *  pisGraphic 
)
static

Extends graph for a submatrix augmented by 2 rows and 1 column.

Parameters
cmrCMR environment.
graphEmpty graph to be filled.
rowEdgesArray to be filled with map from rows to edges.
columnEdgesArray to be filled with map from columns to edges.
baseNumRowsNumber of rows already processed.
baseNumColumnsNumber of columns already processed.
row1ParallelElement to which row1 is parallel.
row2ParallelElement to which row2 is parallel.
pisGraphicPointer for storing whether this extension was graphic.

◆ checkEdgesAdjacent()

static bool checkEdgesAdjacent ( CMR_GRAPH graph,
CMR_GRAPH_EDGE  e,
CMR_GRAPH_EDGE  f,
CMR_GRAPH_NODE pcommon,
CMR_GRAPH_NODE peOther,
CMR_GRAPH_NODE pfOther 
)
static

Returns true if two edges e and f are adjacent.

Parameters
graphGraph.
eFirst edge.
fSecond edge.
pcommonPointer for storing the common endnode.
peOtherPointer for storing the endnode of e that is not common.
pfOtherPointer for storing the endnode of f that is not common.

◆ CMRregularSequenceGraphic()

CMR_ERROR CMRregularSequenceGraphic ( CMR cmr,
CMR_CHRMAT matrix,
CMR_CHRMAT transpose,
size_t  lengthSequence,
size_t *  sequenceNumRows,
size_t *  sequenceNumColumns,
size_t *  plastGraphicMinor,
CMR_GRAPH **  pgraph,
CMR_ELEMENT **  pedgeElements,
CMR_REGULAR_STATISTICS stats,
double  timeLimit 
)

Tests sequence of nested 3-connected minors for graphicness.

Parameters
cmrCMR environment.
matrixMatrix.
transposeTranspose.
lengthSequenceLength of the sequence of nested minors.
sequenceNumRowsArray with number of rows of each minor.
sequenceNumColumnsArray with number of columns of each minor.
plastGraphicMinorPointer for storing the last graphic minor.
pgraphPointer for storing the graph.
pedgeElementsPointer for storing the mapping of edges to elements.
statsStatistics for the computation (may be NULL).
timeLimitTime limit to impose.

◆ CMRregularTestGraphic()

CMR_ERROR CMRregularTestGraphic ( CMR cmr,
CMR_CHRMAT **  pmatrix,
CMR_CHRMAT **  ptranspose,
bool  ternary,
bool *  pisGraphic,
CMR_GRAPH **  pgraph,
CMR_GRAPH_EDGE **  pforest,
CMR_GRAPH_EDGE **  pcoforest,
bool **  parcsReversed,
CMR_SUBMAT **  psubmatrix,
CMR_REGULAR_STATISTICS stats,
double  timeLimit 
)

Tests matrix for graphicness.

Parameters
cmrCMR environment.
pmatrixPointer to matrix.
ptransposePointer to transpose.
ternaryWhether to also check the signs of the matrix.
pisGraphicPointer for storing the result.
pgraphPointer for storing the graph if the matrix is graph (may be NULL).
pforestPointer for storing the mapping of rows to forest edges.
pcoforestPointer for storing the mapping of rows to forest edges.
parcsReversedPointer for storing the array indicating which arcs are reversed.
psubmatrixPointer for storing a minimal non-graphic submatrix (may be NULL).
statsStatistics for the computation (may be NULL).
timeLimitTime limit to impose.

◆ createHashVector()

static CMR_ERROR createHashVector ( CMR cmr,
long long **  phashVector,
size_t  size 
)
static

Creates a hash vector to speed-up recognition of parallel vectors.

Parameters
cmrCMR environment.
phashVectorPointer for storing the hash vector.
sizeSize of hash vector.

◆ createWheel()

static CMR_ERROR createWheel ( CMR cmr,
CMR_GRAPH graph,
CMR_CHRMAT matrix,
CMR_CHRMAT transpose,
size_t  wheelSize,
CMR_GRAPH_EDGE rowEdges,
CMR_GRAPH_EDGE columnEdges 
)
static

Creates the wheel graph for a wheel submatrix.

Parameters
cmrCMR environment.
graphEmpty graph to be filled.
matrixMatrix.
transposeTranspose of matrix.
wheelSizeSize of wheel.
rowEdgesArray to be filled with map from rows to edges.
columnEdgesArray to be filled with map from columns to edges.

◆ dfsArticulationPoint()

static int dfsArticulationPoint ( CMR_GRAPH graph,
bool *  edgesEnabled,
CMR_GRAPH_NODE  node,
bool *  nodesVisited,
int *  nodesDiscoveryTime,
int *  ptime,
CMR_GRAPH_NODE  parentNode,
size_t *  nodesArticulationPoint 
)
static

Recursive DFS for finding all articulation points of a graph.

Parameters
graphGraph.
edgesEnabledEdge array indicating whether an edge is enabled.
nodeCurrent node.
nodesVisitedNode array indicating whether a node was already visited.
nodesDiscoveryTimeNode array indicating at which time a node was visited.
ptimePointer to current time.
parentNodeParent node in DFS arborescence.
nodesArticulationPointNode array indicating whether a node is an articulation point.

◆ dfsBipartite()

static bool dfsBipartite ( CMR_GRAPH graph,
bool *  nodesVisited,
int *  bipartition,
CMR_GRAPH_NODE  node 
)
static

DFS for searching for a bipartition.

Parameters
graphGraph.
nodesVisitedNode array indicating whether a node was visited already.
bipartitionNode array for storing the bipartition.
nodeCurrent node.

◆ dfsComponents()

static void dfsComponents ( CMR_GRAPH graph,
bool *  edgesEnabled,
size_t *  nodesComponent,
CMR_GRAPH_NODE  node,
size_t  component 
)
static

◆ dfsTree()

static void dfsTree ( CMR_GRAPH graph,
bool *  edgesTree,
bool *  nodesVisited,
CMR_GRAPH_NODE nodesParent,
CMR_GRAPH_NODE  node 
)
static
Parameters
graphGraph.
edgesTreeEdge array indicating whether an edge is enabled.
nodesVisitedNode array indicating whether a node was already visited.
nodesParentNode array indicating the parent node of each node.
nodeCurrent node.

◆ findArticulationPoints()

static CMR_ERROR findArticulationPoints ( CMR cmr,
CMR_GRAPH graph,
CMR_GRAPH_EDGE columnEdges,
size_t *  nodesArticulationPoint,
size_t *  nonzeroColumns,
size_t  numNonzeroColumns 
)
static
Parameters
cmrCMR environment.
graphGraph.
columnEdgesArray with with map from columns to edges.
nodesArticulationPointNode array indicating whether a node is an articulation point.
nonzeroColumnsArray with columns containing a nonzero.
numNonzeroColumnsLength of nonzeroColumns.

◆ findBipartition()

static CMR_ERROR findBipartition ( CMR cmr,
CMR_GRAPH graph,
int *  bipartition,
bool *  pisBipartite 
)
static

Finds a bipartition of a graph.

Parameters
cmrCMR environment.
graphGraph.
bipartitionNode array indicating color class.
pisBipartitePointer for storing whether is bipartite.

◆ findComponents()

static CMR_ERROR findComponents ( CMR cmr,
CMR_GRAPH graph,
CMR_GRAPH_EDGE columnEdges,
CMR_GRAPH_NODE  removedNode,
size_t *  nodesComponent,
size_t *  pnumComponents,
size_t *  nonzeroColumns,
size_t  numNonzeroColumns 
)
static
Parameters
cmrCMR environment.
graphGraph.
columnEdgesArray with with map from columns to edges.
removedNodeNode that shall be considered as removed.
nodesComponentNode array indicating the components.
pnumComponentsPointer for storing the number of connected components.
nonzeroColumnsArray with columns containing a nonzero.
numNonzeroColumnsLength of nonzeroColumns.

◆ findParallel()

static CMR_ELEMENT findParallel ( CMR_CHRMAT matrix,
size_t  row,
size_t  numRows,
size_t  numColumns,
long long *  rowHashValues,
long long *  hashVector 
)
static

Find element in submatrix parallel to vector.

◆ findTreeParents()

static CMR_ERROR findTreeParents ( CMR cmr,
CMR_GRAPH graph,
CMR_GRAPH_EDGE rowEdges,
size_t  numRows,
CMR_GRAPH_NODE nodesParent 
)
static
Parameters
cmrCMR environment.
graphGraph.
rowEdgesArray with with map from rows to edges.
numRowsNumber of rows.
nodesParentArray to be filled with map from nodes to parent nodes.

◆ updateHashValues()

static CMR_ERROR updateHashValues ( CMR_CHRMAT matrix,
long long *  majorHashValues,
long long *  minorHashValues,
long long *  hashVector,
size_t  majorFirst,
size_t  majorBeyond,
size_t  minorSize 
)
static

Update the hash values of rows/column of submatrix that is grown by a number of rows.

Parameters
matrixMatrix.
majorHashValuesMap for hash values of major indices.
minorHashValuesMap for hash values of minor indices.
hashVectorHash vector.
majorFirstFirst new major index.
majorBeyondLast new major index plus 1.
minorSizeNumber of minor indices in submatrix.