Scippy

SCIP

Solving Constraint Integer Programs

completegraph.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2022 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file completegraph.h
17  * @brief includes complete graph methods, in particular for MST calculation
18  * @author Daniel Rehfeldt
19  *
20  *
21  */
22 
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
24 
25 
26 #ifndef APPLICATIONS_STP_SRC_COMPLETEGRAPH_H_
27 #define APPLICATIONS_STP_SRC_COMPLETEGRAPH_H_
28 
29 
30 #include "scip/scip.h"
31 #include "graph.h"
32 
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 
39 #define CGRAPH_EDGECOST_UNDEFINED_VALUE -1.0
40 
41 
42 /** complete, undirected graph storage */
43 typedef struct complete_graph
44 {
45  SCIP_Real* edgecosts; /**< edge cost array; of size nnodes_max * (nnodes_max - 1) */
46  SCIP_Real* adjedgecosts; /**< adjacency cost array of size nnodes_max + 1, to be filled in by user */
47  int* nodeids; /**< node ids; of size nnodes_max */
48  SCIP_Bool* node_has_adjcosts; /**< does node have adjacency costs? */
49  int nnodes_max; /**< maximum number of nodes */
50  int nnodes_curr; /**< current number of nodes */
51  int nnodes_active; /**< current number of nodes for which adjacency costs have been added */
52 } CGRAPH;
53 
54 
55 /** buffer that allows to (partially) restore a complete graph node
56  * todo need something more special here that takes dfs depth and a node identifier (which) as input applies corresponding
57  * part to graph...
58  * maybe whenever you store something you get an identifier back??? */
60 {
61  SCIP_Real* adjedgecosts; /**< adjacency cost array for nodes */
62  int* nodeids; /**< corresponding node ids (only needed for debugging) */
63  int nnodes; /**< number of nodes that are currently stored */
64  int dfsdepth; /**< current number of nodes */
65 } CNBUFF;
66 
67 
68 /** complete, undirected graph MST storage; for computing an MST on a CGRAPH */
69 typedef struct complete_mst
70 {
71  DHEAP* heap; /**< heap needed for MST computation */
72  SCIP_Real* dist; /**< distance array of size nnodes_max */
73  int* predecessors; /**< predecessor array of size nnodes_max */
74  SCIP_Real mstobj; /**< objective of current MST */
75  int nnodes_max; /**< maximum number of nodes */
76 } CMST;
77 
78 
79 /* methods for the complete graph */
82 SCIP_Bool cgraph_idsInSync(const CGRAPH*, const int*, int);
85 void cgraph_free(SCIP*, CGRAPH**);
86 void cgraph_clean(CGRAPH*);
88 void cgraph_node_append(CGRAPH*, int);
89 void cgraph_node_applyMinAdjCosts(CGRAPH*, int, int);
92 void cgraph_node_delete(CGRAPH*, int);
93 int cgraph_node_getTopId(const CGRAPH*);
94 SCIP_Real cgraph_edge_getCost(const CGRAPH*, int, int);
95 
96 /* methods for the corresponding MST structure */
97 SCIP_Bool cmst_isSync(const CGRAPH*, const CMST*);
99 void cmst_free(SCIP*, CMST**);
100 void cmst_computeMst(const CGRAPH*, int, CMST*);
101 
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 
108 #endif /* APPLICATIONS_STP_SRC_COMPLETEGRAPH_H_ */
void cgraph_free(SCIP *, CGRAPH **)
struct complete_graph_node_buffer CNBUFF
SCIP_Bool cgraph_idsInSync(const CGRAPH *, const int *, int)
SCIP_Bool * node_has_adjcosts
Definition: completegraph.h:48
SCIP_RETCODE cmst_init(SCIP *, CMST **, int)
void cgraph_node_delete(CGRAPH *, int)
int cgraph_node_getTopId(const CGRAPH *)
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
includes various files containing graph methods used for Steiner tree problems
void cgraph_node_deleteTop(CGRAPH *)
SCIP_Bool cmst_isSync(const CGRAPH *, const CMST *)
DHEAP * heap
Definition: completegraph.h:71
void cgraph_node_applyMinAdjCosts(CGRAPH *, int, int)
struct complete_graph CGRAPH
SCIP_Real * dist
Definition: completegraph.h:72
SCIP_Bool cgraph_idIsContained(const CGRAPH *, int)
SCIP_Bool cgraph_node_hasAdjCosts(const CGRAPH *, int)
struct complete_mst CMST
#define SCIP_Bool
Definition: def.h:84
void cgraph_clean(CGRAPH *)
SCIP_Bool cgraph_isEmpty(const CGRAPH *)
void cgraph_node_repositionTop(CGRAPH *, int)
SCIP_Real cgraph_edge_getCost(const CGRAPH *, int, int)
SCIP_Real * adjedgecosts
Definition: completegraph.h:46
void cmst_computeMst(const CGRAPH *, int, CMST *)
SCIP_Real mstobj
Definition: completegraph.h:74
#define SCIP_Real
Definition: def.h:177
SCIP_Real * edgecosts
Definition: completegraph.h:45
int * predecessors
Definition: completegraph.h:73
SCIP_Bool cgraph_valid(const CGRAPH *)
SCIP callable library.
void cmst_free(SCIP *, CMST **)
SCIP_RETCODE cgraph_init(SCIP *, CGRAPH **, int)
void cgraph_node_append(CGRAPH *, int)