hypergraph.h
Go to the documentation of this file.
30 * A <em>hypergraph</em> \f$ G \f$ is a pair \f$ (V,E) \f$ of <em>vertices</em> \f$ v \in V \f$ and
31 * <em>(hyper-)edges</em> \f$ e \in E \f$ such that \f$ e \subseteq V \f$ holds. We say that a vertex \f$ v \f$ and an
33 * A subset \f$ U \subseteq V \f$ is called an <em>overlap set</em> if it is a nontrivial intersection of two distinct
34 * edges, i.e., if \f$ U = e \cap f \f$ for \f$ e,f \in E \f$ and \f$ |U| \geq 2 \f$. In this case, we say that
35 * \f$ U \f$ and \f$ e \f$ are <em>incident</em> (same for \f$ f \f$. We denote the set of overlap sets by
38 * A \ref SCIP_HYPERGRAPH struct defines such a hypergraph \f$ G = (V,E) \f$, potentially with the set
39 * \f$ \mathcal{U} \f$ of overlaps. Efficient access for retrieving elements is provided, e.g., the vertices incident
43/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
87 SCIP_HYPERGRAPH_VERTEXDATA** pvertexdata /**< Pointer for returning the vertex's data (may be \c NULL). */
100 SCIP_HYPERGRAPH_EDGEDATA** pedgedata /**< Pointer for returning the edge's data (may be \c NULL). */
116 SCIP_DECL_HYPERGRAPH_OVERLAP((*handler)), /**< Function to be called once the overlap is found. */
121 * @brief finds the overlap corresponding to vertex set \p vertices; returns -1 if it is not found
123 * Requires \ref SCIPhypergraphHasOverlaps to be \c TRUE which results from \ref SCIPhypergraphComputeOverlaps.
133 * @brief finds the overlap or singleton vertex corresponding to the intersection of edges \p first and \p second
135 * Requires \ref SCIPhypergraphHasOverlaps to be \c TRUE which results from \ref SCIPhypergraphComputeOverlaps.
148 * Requires \ref SCIPhypergraphHasOverlaps to be \c TRUE which results from \ref SCIPhypergraphComputeOverlaps.
191 * \p findoverlaps indicates whether the overlap corresponding to each edge intersection shall be determined. This
224/** @brief returns the minimum vertex in the intersection of the base and the current adjacent edge */
232 * If the intersection of the two edges has only one element, then -1 is returned, and if overlap information was not
345 * See \ref SCIPhypergraphVertexEdgesFirst and \ref SCIPhypergraphVertexEdgesBeyond to obtain such indices for a vertex.
361 * Requires \ref SCIPhypergraphHasOverlaps to be \c TRUE which results from \ref SCIPhypergraphComputeOverlaps.
372 * Requires \ref SCIPhypergraphHasOverlaps to be \c TRUE which results from \ref SCIPhypergraphComputeOverlaps.
394 * See \ref SCIPhypergraphEdgesOverlapsFirst and \ref SCIPhypergraphEdgesOverlapsBeyond to obtain such indices for an
417 * See \ref SCIPhypergraphOverlapsEdgesFirst and \ref SCIPhypergraphOverlapsEdgesBeyond to obtain such indices for an
440 * See \ref SCIPhypergraphVertexOverlapsFirst and \ref SCIPhypergraphVertexOverlapsBeyond to obtain such indices for a
451/* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and speed up
459#define SCIPhypergraphGetNIncidences(hypergraph) ((hypergraph)->edgesverticesbeg[(hypergraph)->nedges])
461 ((SCIP_HYPERGRAPH_VERTEXDATA*)((hypergraph)->verticesdata + ((vertex) * ((hypergraph)->sizevertexdata) / sizeof(*((hypergraph)->verticesdata)) )))
463 ((SCIP_HYPERGRAPH_EDGEDATA*)((hypergraph)->edgesdata + ((edge) * (hypergraph)->sizeedgedata / sizeof(*((hypergraph)->edgesdata)) )))
464#define SCIPhypergraphOverlapData(hypergraph,overlap) ((SCIP_HYPERGRAPH_OVERLAPDATA*)((hypergraph)->overlapsdata \
468#define SCIPhypergraphEdgeVertices(hypergraph, edge) (&(hypergraph)->edgesvertices[(hypergraph)->edgesverticesbeg[edge]])
470#define SCIPhypergraphVertexEdgesFirst(hypergraph,vertex) ((hypergraph)->verticesedgesbeg[vertex])
471#define SCIPhypergraphVertexEdgesBeyond(hypergraph,vertex) ((hypergraph)->verticesedgesbeg[(vertex) + 1])
472#define SCIPhypergraphVertexEdgesGetAtIndex(hypergraph,index) ((hypergraph)->verticesedges[index])
474#define SCIPhypergraphOverlapSize(hypergraph,overlap) ((hypergraph)->overlapsverticesbeg[(overlap) + 1] \
479#define SCIPhypergraphEdgesOverlapsBeyond(hypergraph,edge) ((hypergraph)->edgesoverlapsbeg[(edge) + 1])
480#define SCIPhypergraphEdgesOverlapsGetAtIndex(hypergraph,index) ((hypergraph)->edgesoverlaps[index])
482#define SCIPhypergraphOverlapsEdgesFirst(hypergraph,overlap) ((hypergraph)->overlapsedgesbeg[overlap])
483#define SCIPhypergraphOverlapsEdgesBeyond(hypergraph,overlap) ((hypergraph)->overlapsedgesbeg[(overlap) + 1])
484#define SCIPhypergraphOverlapsEdgesGetAtIndex(hypergraph,index) ((hypergraph)->overlapsedges[index])
486#define SCIPhypergraphVertexOverlapsFirst(hypergraph,vertex) ((hypergraph)->verticesoverlapsbeg[vertex])
487#define SCIPhypergraphVertexOverlapsBeyond(hypergraph,vertex) ((hypergraph)->verticesoverlapsbeg[(vertex) + 1])
488#define SCIPhypergraphVertexOverlapsGet(hypergraph,index) ((hypergraph)->verticesoverlaps[index])
void SCIPhypergraphIterStart(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_ITER *iterator, SCIP_HYPERGRAPH_EDGE base, unsigned int minoverlapsize, SCIP_Bool onlylater, SCIP_Bool findoverlaps)
initializes the iterator to the first adjacent edge of base
Definition: hypergraph.c:1506
int SCIPhypergraphEdgesOverlapsBeyond(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_EDGE edge)
returns an index beyond the last overlap incident to edge
Definition: hypergraph.c:1995
void SCIPhypergraphIterNext(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_ITER *iterator)
initializes the iterator to the first adjacent edge of base
Definition: hypergraph.c:1547
SCIP_RETCODE SCIPhypergraphFree(SCIP_HYPERGRAPH **phypergraph)
frees a hypergraph
Definition: hypergraph.c:281
SCIP_HYPERGRAPH_EDGE SCIPhypergraphIterAdjacent(SCIP_HYPERGRAPH_ITER *iterator)
returns the current adjacent edge
Definition: hypergraph.c:1693
SCIP_HYPERGRAPH_EDGE SCIPhypergraphIterBase(SCIP_HYPERGRAPH_ITER *iterator)
returns the base edge
Definition: hypergraph.c:1685
SCIP_RETCODE SCIPhypergraphAddEdge(SCIP_HYPERGRAPH *hypergraph, int nvertices, SCIP_HYPERGRAPH_VERTEX *vertices, SCIP_HYPERGRAPH_EDGE *pedge, SCIP_HYPERGRAPH_EDGEDATA **pedgedata)
adds a new edge to the hypergraph
Definition: hypergraph.c:416
SCIP_HYPERGRAPH_OVERLAP SCIPhypergraphIterOverlap(SCIP_HYPERGRAPH_ITER *iterator)
returns the overlap for the intersection of the base and the current adjacent edge
Definition: hypergraph.c:1714
int SCIPhypergraphOverlapsEdgesBeyond(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_OVERLAP overlap)
returns an index beyond the last edge incident to overlap
Definition: hypergraph.c:2051
void SCIPhypergraphIterClear(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_ITER *iterator)
frees a hypergraph iterator's internal memory
Definition: hypergraph.c:1494
SCIP_HYPERGRAPH_EDGE SCIPhypergraphVertexEdgesGetAtIndex(SCIP_HYPERGRAPH *hypergraph, int idx)
returns the edge corresponding to index that is incident to a vertex
Definition: hypergraph.c:1921
int SCIPhypergraphVertexEdgesBeyond(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_VERTEX vertex)
returns an index beyond the last edge incident to vertex
Definition: hypergraph.c:1905
SCIP_RETCODE SCIPhypergraphIntersectEdges(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_EDGE first, SCIP_HYPERGRAPH_EDGE second, SCIP_HYPERGRAPH_OVERLAP *poverlap, SCIP_HYPERGRAPH_VERTEX *pvertex)
finds the overlap or singleton vertex corresponding to the intersection of edges first and second
Definition: hypergraph.c:929
SCIP_Bool SCIPhypergraphIterValid(SCIP_HYPERGRAPH_ITER *iterator)
returns whether the iterator is valid
Definition: hypergraph.c:1537
int SCIPhypergraphGetNEdges(SCIP_HYPERGRAPH *hypergraph)
returns the number of edges
Definition: hypergraph.c:1774
int SCIPhypergraphVertexOverlapsBeyond(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_VERTEX vertex)
returns an index beyond the last overlap incident to vertex
Definition: hypergraph.c:2107
SCIP_RETCODE SCIPhypergraphComputeVerticesEdges(SCIP_HYPERGRAPH *hypergraph)
computes each vertex' list of incident edges
Definition: hypergraph.c:811
SCIP_HYPERGRAPH_OVERLAPDATA * SCIPhypergraphOverlapData(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_OVERLAP overlap)
returns additional data of overlap
Definition: hypergraph.c:1838
SCIP_RETCODE SCIPhypergraphAddVertex(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_VERTEX *pvertex, SCIP_HYPERGRAPH_VERTEXDATA **pvertexdata)
adds a new vertex to the hypergraph
Definition: hypergraph.c:386
int SCIPhypergraphEdgeSize(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_EDGE edge)
returns the number of vertices of edge
Definition: hypergraph.c:1850
SCIP_Bool SCIPhypergraphHasOverlapsEdges(SCIP_HYPERGRAPH *hypergraph)
returns whether overlaps' incident edges are known.
Definition: hypergraph.c:2029
SCIP_Bool SCIPhypergraphOverlapsDisjoint(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_OVERLAP overlap1, SCIP_HYPERGRAPH_OVERLAP overlap2)
returns whether overlaps overlap1 and overlap2 are disjoint
Definition: hypergraph.c:1187
SCIP_Bool SCIPhypergraphIsValid(SCIP_HYPERGRAPH *hypergraph, FILE *file)
asserts that the hypergraph data structures are valid
Definition: hypergraph.c:1221
SCIP_RETCODE SCIPhypergraphOverlapFind(SCIP_HYPERGRAPH *hypergraph, int nvertices, SCIP_HYPERGRAPH_VERTEX *vertices, SCIP_HYPERGRAPH_OVERLAP *poverlap)
finds the overlap corresponding to vertex set vertices; returns -1 if it is not found
Definition: hypergraph.c:906
SCIP_RETCODE SCIPhypergraphClear(SCIP_HYPERGRAPH *hypergraph)
clears a hypergraph, deleting all vertices and edges
Definition: hypergraph.c:361
SCIP_Bool SCIPhypergraphHasOverlaps(SCIP_HYPERGRAPH *hypergraph)
returns whether edges' overlaps and overlaps' vertices are known.
Definition: hypergraph.c:1937
SCIP_Bool SCIPhypergraphHasVertexOverlaps(SCIP_HYPERGRAPH *hypergraph)
returns whether vertices' incident overlaps are known
Definition: hypergraph.c:2085
SCIP_HYPERGRAPH_VERTEX * SCIPhypergraphEdgeVertices(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_EDGE edge)
returns the array of vertices of edge
Definition: hypergraph.c:1867
int SCIPhypergraphEdgesOverlapsFirst(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_EDGE edge)
returns an index for the first overlap incident to edge
Definition: hypergraph.c:1982
int SCIPhypergraphOverlapsEdgesFirst(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_OVERLAP overlap)
returns an index for the first edge incident to overlap
Definition: hypergraph.c:2039
SCIP_HYPERGRAPH_VERTEX SCIPhypergraphIterMinVertex(SCIP_HYPERGRAPH_ITER *iterator)
returns the minimum vertex in the intersection of the base and the current adjacent edge
Definition: hypergraph.c:1701
SCIP_HYPERGRAPH_VERTEXDATA * SCIPhypergraphVertexData(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_VERTEX vertex)
returns additional data of vertex
Definition: hypergraph.c:1814
SCIP_HYPERGRAPH_OVERLAP SCIPhypergraphVertexOverlapsGetAtIndex(SCIP_HYPERGRAPH *hypergraph, int idx)
returns the overlap corresponding to index that is incident to a vertex
Definition: hypergraph.c:2124
int SCIPhypergraphVertexOverlapsFirst(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_VERTEX vertex)
returns an index for the first overlap containing vertex
Definition: hypergraph.c:2095
SCIP_RETCODE SCIPhypergraphComputeOverlapsEdges(SCIP_HYPERGRAPH *hypergraph)
computes all overlaps' lists of incident edges
Definition: hypergraph.c:990
SCIP_HYPERGRAPH_OVERLAP SCIPhypergraphOverlapsEdgesGetAtIndex(SCIP_HYPERGRAPH *hypergraph, int idx)
returns the edge corresponding to index that is incident to an overlap
Definition: hypergraph.c:2068
SCIP_RETCODE SCIPhypergraphComputeOverlaps(SCIP_HYPERGRAPH *hypergraph, SCIP_DECL_HYPERGRAPH_OVERLAP((*handler)), void *userdata)
computes all overlaps and stores overlaps' vertices and all edges' overlaps
Definition: hypergraph.c:587
SCIP_RETCODE SCIPhypergraphComputeVerticesOverlaps(SCIP_HYPERGRAPH *hypergraph)
computes all vertices' lists of incident overlaps
Definition: hypergraph.c:1091
int SCIPhypergraphGetNIncidences(SCIP_HYPERGRAPH *hypergraph)
returns the number of vertex-edge incidences.
Definition: hypergraph.c:1804
SCIP_Bool SCIPhypergraphHasVertexEdges(SCIP_HYPERGRAPH *hypergraph)
returns whether vertices' incident edges are known.
Definition: hypergraph.c:1883
int SCIPhypergraphGetNVertices(SCIP_HYPERGRAPH *hypergraph)
returns the number of vertices
Definition: hypergraph.c:1764
SCIP_HYPERGRAPH_OVERLAP SCIPhypergraphEdgesOverlapsGetAtIndex(SCIP_HYPERGRAPH *hypergraph, int idx)
returns the overlap corresponding to index that is incident to an edge
Definition: hypergraph.c:2013
SCIP_RETCODE SCIPhypergraphIterInit(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_ITER *iterator)
initializes a hypergraph iterator's internal memory
Definition: hypergraph.c:1469
int SCIPhypergraphVertexEdgesFirst(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_VERTEX vertex)
returns an index for the first edge incident to vertex
Definition: hypergraph.c:1893
SCIP_HYPERGRAPH_VERTEX * SCIPhypergraphOverlapVertices(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_OVERLAP overlap)
returns the array of sorted vertices of overlap
Definition: hypergraph.c:1969
int SCIPhypergraphOverlapSize(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_OVERLAP overlap)
returns the number of vertices of overlap
Definition: hypergraph.c:1951
int SCIPhypergraphGetNOverlaps(SCIP_HYPERGRAPH *hypergraph)
returns the number of overlaps
Definition: hypergraph.c:1794
SCIP_HYPERGRAPH_EDGEDATA * SCIPhypergraphEdgeData(SCIP_HYPERGRAPH *hypergraph, SCIP_HYPERGRAPH_EDGE edge)
returns additional data of edge
Definition: hypergraph.c:1826
BMS_BLKMEM * SCIPhypergraphBlkmem(SCIP_HYPERGRAPH *hypergraph)
returns the hypergraph's block memory structure
Definition: hypergraph.c:1784
SCIP_RETCODE SCIPhypergraphCreate(SCIP_HYPERGRAPH **phypergraph, BMS_BLKMEM *blkmem, int memvertices, int memedges, int memoverlaps, int memedgesvertices, size_t sizevertexdata, size_t sizeedgedata, size_t sizeoverlapdata)
creates a hypergraph
Definition: hypergraph.c:210
memory allocation routines
Definition: type_hypergraph.h:86
Definition: struct_hypergraph.h:46
datastructures hypergraphs
type definitions for hypergraphs
struct SCIP_Hypergraph_OverlapData SCIP_HYPERGRAPH_OVERLAPDATA
Definition: type_hypergraph.h:55
struct SCIP_Hypergraph_NodeData SCIP_HYPERGRAPH_VERTEXDATA
Definition: type_hypergraph.h:49
struct SCIP_Hypergraph_EdgeData SCIP_HYPERGRAPH_EDGEDATA
Definition: type_hypergraph.h:52
type definitions for return codes for SCIP methods