Scippy

SCIP

Solving Constraint Integer Programs

completegraph.c File Reference

Detailed Description

includes complete graph methods, in particular for MST calculation

Author
Daniel Rehfeldt

Complete graph methods, in particular for MST calculation. Assumes a maximum size of the graph. Only sensible for small maximum sizes.

Definition in file completegraph.c.

#include "completegraph.h"
#include "portab.h"

Go to the source code of this file.

Macros

#define NODE_ID_UNDEFINED   -2
 

Functions

static int getNnodesCurr (const CGRAPH *cgraph)
 
static int getNnodesMax (const CGRAPH *cgraph)
 
static int getEdgeStart (int nodepos, int nnodes_max)
 
static int getEdgeEnd (int nodepos, int nnodes_curr, int nnodes_max)
 
static int getPositionFromId (const CGRAPH *cgraph, int nodeid)
 
SCIP_Bool cgraph_valid (const CGRAPH *cgraph)
 
SCIP_Bool cgraph_idsInSync (const CGRAPH *cgraph, const int *ids, int nids)
 
SCIP_Bool cgraph_idIsContained (const CGRAPH *cgraph, int id)
 
SCIP_RETCODE cgraph_init (SCIP *scip, CGRAPH **cgraph, int maxnnodes)
 
void cgraph_free (SCIP *scip, CGRAPH **cgraph)
 
void cgraph_clean (CGRAPH *cgraph)
 
SCIP_Bool cgraph_isEmpty (const CGRAPH *cgraph)
 
SCIP_Bool cgraph_node_hasAdjCosts (const CGRAPH *cgraph, int nodepos)
 
void cgraph_node_applyMinAdjCosts (CGRAPH *cgraph, int nodepos, int nodeid)
 
void cgraph_node_append (CGRAPH *cgraph, int nodeid)
 
void cgraph_node_repositionTop (CGRAPH *cgraph, int nodeid_new)
 
void cgraph_node_deleteTop (CGRAPH *cgraph)
 
void cgraph_node_delete (CGRAPH *cgraph, int nodeid)
 
int cgraph_node_getTopId (const CGRAPH *cgraph)
 
SCIP_Real cgraph_edge_getCost (const CGRAPH *cgraph, int nodeid_tail, int nodeid_head)
 
SCIP_Bool cmst_isSync (const CGRAPH *cgraph, const CMST *cmst)
 
SCIP_RETCODE cmst_init (SCIP *scip, CMST **cmst, int maxnnodes)
 
void cmst_free (SCIP *scip, CMST **cmst)
 
void cmst_computeMst (const CGRAPH *cgraph, int mstroot, CMST *cmst)
 

Macro Definition Documentation

◆ NODE_ID_UNDEFINED

#define NODE_ID_UNDEFINED   -2

Function Documentation

◆ getNnodesCurr()

static int getNnodesCurr ( const CGRAPH cgraph)
inlinestatic

◆ getNnodesMax()

static int getNnodesMax ( const CGRAPH cgraph)
inlinestatic

gets maximum number of nodes

Parameters
cgraphthe graph

Definition at line 53 of file completegraph.c.

References complete_graph::nnodes_max.

Referenced by cgraph_node_applyMinAdjCosts(), cgraph_node_repositionTop(), cgraph_valid(), cmst_computeMst(), and cmst_isSync().

◆ getEdgeStart()

static int getEdgeStart ( int  nodepos,
int  nnodes_max 
)
inlinestatic

gets start position in edge cost array

Parameters
nodeposnode position
nnodes_maxmaximum number of nodes

Definition at line 66 of file completegraph.c.

Referenced by cgraph_node_append(), cgraph_node_applyMinAdjCosts(), cgraph_node_deleteTop(), cgraph_node_repositionTop(), cgraph_valid(), cmst_computeMst(), and cmst_isSync().

◆ getEdgeEnd()

static int getEdgeEnd ( int  nodepos,
int  nnodes_curr,
int  nnodes_max 
)
inlinestatic

gets end position in edge cost array; NOT included!

Parameters
nodeposnode position
nnodes_currcurrent number of nodes
nnodes_maxmaximum number of nodes

Definition at line 80 of file completegraph.c.

Referenced by cgraph_node_append(), cgraph_node_deleteTop(), and cgraph_valid().

◆ getPositionFromId()

static int getPositionFromId ( const CGRAPH cgraph,
int  nodeid 
)
inlinestatic

gets position of node with specified id

Parameters
cgraphnew graph
nodeidthe node id

Definition at line 97 of file completegraph.c.

References cgraph_valid(), complete_graph::nnodes_curr, and complete_graph::nodeids.

Referenced by cgraph_node_repositionTop().

◆ cgraph_valid()

◆ cgraph_idsInSync()

SCIP_Bool cgraph_idsInSync ( const CGRAPH cgraph,
const int *  ids,
int  nids 
)

is the graph in sync with given node id list?

Parameters
cgraphthe graph
idsnode ids
nidsnumber of ids

Definition at line 214 of file completegraph.c.

References FALSE, complete_graph::nnodes_curr, complete_graph::nodeids, SCIPdebugMessage, and TRUE.

◆ cgraph_idIsContained()

SCIP_Bool cgraph_idIsContained ( const CGRAPH cgraph,
int  id 
)

is node with given id in the graph??

Parameters
cgraphthe graph
idthe id

Definition at line 243 of file completegraph.c.

References FALSE, getNnodesCurr(), nnodes, complete_graph::nodeids, and TRUE.

Referenced by cgraph_node_append().

◆ cgraph_init()

◆ cgraph_free()

void cgraph_free ( SCIP scip,
CGRAPH **  cgraph 
)

◆ cgraph_clean()

void cgraph_clean ( CGRAPH cgraph)

cleans, i.e. resets, graph

Parameters
cgraphnew graph

Definition at line 331 of file completegraph.c.

References cgraph_isEmpty(), cgraph_node_deleteTop(), cgraph_valid(), and getNnodesCurr().

◆ cgraph_isEmpty()

SCIP_Bool cgraph_isEmpty ( const CGRAPH cgraph)

is the graph empty?

Parameters
cgraphnew graph

Definition at line 347 of file completegraph.c.

References cgraph_valid(), and complete_graph::nnodes_curr.

Referenced by cgraph_clean().

◆ cgraph_node_hasAdjCosts()

SCIP_Bool cgraph_node_hasAdjCosts ( const CGRAPH cgraph,
int  nodepos 
)

has the given node adjacency costs?

Parameters
cgraphthe complete graph
nodeposthe node position

Definition at line 358 of file completegraph.c.

References cgraph_valid(), getNnodesCurr(), and complete_graph::node_has_adjcosts.

Referenced by cmst_computeMst().

◆ cgraph_node_applyMinAdjCosts()

void cgraph_node_applyMinAdjCosts ( CGRAPH cgraph,
int  nodepos,
int  nodeid 
)

applies adjacency costs to node, but only use if smaller than existing ones.

Parameters
cgraphthe complete graph
nodeposthe node position
nodeidthe node id (for debugging only)

Definition at line 371 of file completegraph.c.

References complete_graph::adjedgecosts, CGRAPH_EDGECOST_UNDEFINED_VALUE, cgraph_valid(), complete_graph::edgecosts, EQ, GE, getEdgeStart(), getNnodesCurr(), getNnodesMax(), complete_graph::node_has_adjcosts, complete_graph::nodeids, SCIP_Real, and TRUE.

Referenced by completemst1(), completemst2(), completemst3(), completemst4(), completemst5(), and sdmstGetWeight().

◆ cgraph_node_append()

void cgraph_node_append ( CGRAPH cgraph,
int  nodeid 
)

◆ cgraph_node_repositionTop()

void cgraph_node_repositionTop ( CGRAPH cgraph,
int  nodeid_new 
)

replaces node with id 'nodeid_new' by top node

Parameters
cgraphnew graph
nodeid_newthe new node id

Definition at line 463 of file completegraph.c.

References BMScopyMemoryArray, cgraph_node_deleteTop(), cgraph_valid(), complete_graph::edgecosts, EQ, FARAWAY, getEdgeStart(), getNnodesCurr(), getNnodesMax(), getPositionFromId(), complete_graph::nodeids, and SCIP_Real.

Referenced by completemst1().

◆ cgraph_node_deleteTop()

◆ cgraph_node_delete()

void cgraph_node_delete ( CGRAPH cgraph,
int  nodeid 
)

deletes node

Parameters
cgraphnew graph
nodeidthe node id

Definition at line 558 of file completegraph.c.

References cgraph_valid(), complete_graph::nnodes_curr, and complete_graph::nodeids.

◆ cgraph_node_getTopId()

int cgraph_node_getTopId ( const CGRAPH cgraph)

gets id of node at the top

Parameters
cgraphnew graph

Definition at line 581 of file completegraph.c.

References cgraph_valid(), complete_graph::nnodes_curr, and complete_graph::nodeids.

◆ cgraph_edge_getCost()

SCIP_Real cgraph_edge_getCost ( const CGRAPH cgraph,
int  nodeid_tail,
int  nodeid_head 
)

Get edge cost. Note: quite slow, only use for debugging!

Parameters
cgraphnew graph
nodeid_tailthe node id
nodeid_headthe node id

Definition at line 595 of file completegraph.c.

References cgraph_valid().

◆ cmst_isSync()

SCIP_Bool cmst_isSync ( const CGRAPH cgraph,
const CMST cmst 
)

is the MST struct valid?

Parameters
cgraphnew graph
cmstthe MST

Definition at line 610 of file completegraph.c.

References complete_graph::edgecosts, EQ, FALSE, getEdgeStart(), getNnodesCurr(), getNnodesMax(), complete_mst::mstobj, nnodes, complete_mst::nnodes_max, complete_mst::predecessors, SCIP_Real, SCIPdebugMessage, and TRUE.

Referenced by cmst_computeMst().

◆ cmst_init()

SCIP_RETCODE cmst_init ( SCIP scip,
CMST **  cmst,
int  maxnnodes 
)

◆ cmst_free()

void cmst_free ( SCIP scip,
CMST **  cmst 
)

◆ cmst_computeMst()