Scippy

GCG

Branch-and-Price & Column Generation for Everyone

gcg::Graph< T > Class Template Reference

Detailed Description

template<class T>
class gcg::Graph< T >

Definition at line 53 of file graph.h.

#include <graph.h>

Public Member Functions

 Graph (SCIP *scip)
 
void swap (Graph &other)
 
Graphoperator= (Graph other)
 
virtual ~Graph ()
 
SCIP_RETCODE addNNodes (int _n_nodes)
 
SCIP_RETCODE addNNodes (int _n_nodes, std::vector< int > weights)
 
SCIP_RETCODE addNode (int i, int weight)
 
SCIP_RETCODE addNode ()
 
SCIP_RETCODE addEdge (int i, int j)
 
SCIP_RETCODE addEdge (int i, int j, double weight)
 
SCIP_RETCODE setEdge (int i, int j, double weight)
 
double getEdgeWeight (int i, int j)
 
std::vector< std::pair< int, double > > getNeighborWeights (int i)
 
int getNNodes ()
 
int getNEdges ()
 
SCIP_RETCODE getEdges (std::vector< void * > &edges)
 
virtual int edge (int i, int j)
 
virtual int getNNeighbors (int i)
 
virtual std::vector< int > getNeighbors (int i)
 
virtual void setPartition (int i, int ID)
 
virtual SCIP_RETCODE createFromMatrix (SCIP_CONS **conss, SCIP_VAR **vars, int nconss_, int nvars_)
 
virtual SCIP_RETCODE writeToFile (int fd, SCIP_Bool writeweights)
 
virtual SCIP_RETCODE readPartition (const char *filename)
 
int getNNonzeroes () const
 
virtual int getWeight (int i)
 
void setDummynodes (int dummynodes_)
 
int getDummynodes () const
 
SCIP_RETCODE flush ()
 
SCIP_RETCODE normalize ()
 
virtual double getEdgeWeightPercentile (double q)
 
- Public Member Functions inherited from gcg::GraphInterface
 GraphInterface ()
 
virtual ~GraphInterface ()
 
virtual std::vector< int > getPartition () const
 
virtual SCIP_RETCODE createDecompFromPartition (DEC_DECOMP **decomp)
 

Data Fields

std::string name
 

Protected Attributes

SCIP * scip_
 
Bridgegraph
 
int nconss
 
int nvars
 
int nnonzeroes
 
int dummynodes
 
- Protected Attributes inherited from gcg::GraphInterface
std::vector< int > partition
 

Constructor & Destructor Documentation

◆ Graph()

template<class T >
gcg::Graph< T >::Graph ( SCIP *  scip)

Constructor

Parameters
scipSCIP data structure

Definition at line 46 of file graph_def.h.

References gcg::Graph< T >::graph.

◆ ~Graph()

template<class T >
gcg::Graph< T >::~Graph
virtual

Destruktor

Definition at line 54 of file graph_def.h.

Member Function Documentation

◆ swap()

◆ operator=()

template<class T >
Graph& gcg::Graph< T >::operator= ( Graph< T >  other)
inline

Definition at line 82 of file graph.h.

References gcg::Graph< T >::swap().

◆ addNNodes() [1/2]

template<class T >
SCIP_RETCODE gcg::Graph< T >::addNNodes ( int  _n_nodes)

adds n nodes in the graph at the same time. it is much faster than to call addNode() many times

Definition at line 62 of file graph_def.h.

◆ addNNodes() [2/2]

template<class T >
SCIP_RETCODE gcg::Graph< T >::addNNodes ( int  _n_nodes,
std::vector< int >  weights 
)

adds n nodes in the graph at the same time. it is much faster than to call addNode() many times. weights represent node weights

Definition at line 68 of file graph_def.h.

◆ addNode() [1/2]

template<class T >
SCIP_RETCODE gcg::Graph< T >::addNode ( int  i,
int  weight 
)

adds the node with the given weight to the graph

Definition at line 90 of file graph_def.h.

◆ addNode() [2/2]

template<class T >
SCIP_RETCODE gcg::Graph< T >::addNode

adds the node with the 0 weight to the graph

Definition at line 97 of file graph_def.h.

◆ addEdge() [1/2]

template<class T >
SCIP_RETCODE gcg::Graph< T >::addEdge ( int  i,
int  j 
)

adds the edge to the graph

Definition at line 105 of file graph_def.h.

◆ addEdge() [2/2]

template<class T >
SCIP_RETCODE gcg::Graph< T >::addEdge ( int  i,
int  j,
double  weight 
)

adds the weighted edge to the graph

Definition at line 248 of file graph_def.h.

◆ setEdge()

template<class T >
SCIP_RETCODE gcg::Graph< T >::setEdge ( int  i,
int  j,
double  weight 
)

sets the weight of the edge in the graph

Definition at line 256 of file graph_def.h.

◆ getEdgeWeight()

template<class T >
double gcg::Graph< T >::getEdgeWeight ( int  i,
int  j 
)

returns the weight of the edge in the graph

Definition at line 264 of file graph_def.h.

◆ getNeighborWeights()

template<class T >
std::vector< std::pair< int, double > > gcg::Graph< T >::getNeighborWeights ( int  i)

◆ getNNodes()

template<class T >
int gcg::Graph< T >::getNNodes

return the number of nodes

Definition at line 74 of file graph_def.h.

Referenced by gcg::GraphAlgorithms< T >::dbscan(), gcg::GraphAlgorithms< T >::mst(), and gcg::Graph< T >::writeToFile().

◆ getNEdges()

template<class T >
int gcg::Graph< T >::getNEdges

return the number of edges (or hyperedges)

Definition at line 79 of file graph_def.h.

Referenced by gcg::GraphAlgorithms< T >::mst(), and gcg::Graph< T >::writeToFile().

◆ getEdges()

template<class T >
SCIP_RETCODE gcg::Graph< T >::getEdges ( std::vector< void * > &  edges)

get list of edges in the graph (not defined how edges are implemented)

Definition at line 84 of file graph_def.h.

Referenced by gcg::GraphAlgorithms< T >::mst().

◆ edge()

template<class T >
int gcg::Graph< T >::edge ( int  i,
int  j 
)
virtual

returns whether there is an edge between nodes i and j

Definition at line 126 of file graph_def.h.

◆ getNNeighbors()

template<class T >
int gcg::Graph< T >::getNNeighbors ( int  i)
virtual

return the number of neighbor nodes of given node

Parameters
ithe given node

Definition at line 146 of file graph_def.h.

Referenced by gcg::Graph< T >::writeToFile().

◆ getNeighbors()

template<class T >
std::vector< int > gcg::Graph< T >::getNeighbors ( int  i)
virtual

return the neighboring nodes of a given node

Parameters
ithe given node

Definition at line 152 of file graph_def.h.

Referenced by gcg::Graph< T >::writeToFile().

◆ setPartition()

template<class T >
void gcg::Graph< T >::setPartition ( int  i,
int  ID 
)
virtual

assigns partition to a given node

Implements gcg::GraphInterface.

Definition at line 159 of file graph_def.h.

References partition().

◆ createFromMatrix()

template<class T >
virtual SCIP_RETCODE gcg::Graph< T >::createFromMatrix ( SCIP_CONS **  conss,
SCIP_VAR **  vars,
int  nconss_,
int  nvars_ 
)
inlinevirtual

create graph from the matrix, to be overriden by the implementation

Parameters
conssconstraints for which graph should be created
varsvariables for which graph should be created
nconss_number of constraints
nvars_number of variables

Definition at line 145 of file graph.h.

◆ writeToFile()

template<class T >
SCIP_RETCODE gcg::Graph< T >::writeToFile ( int  fd,
SCIP_Bool  writeweights 
)
virtual

writes the graph to the given file. The format is graph dependent

write the graph to a file

Parameters
fdfilename where the graph should be written to
writeweightswhether to write weights

Implements gcg::GraphInterface.

Definition at line 166 of file graph_def.h.

References gcg::Graph< T >::getNEdges(), gcg::Graph< T >::getNeighbors(), gcg::Graph< T >::getNNeighbors(), and gcg::Graph< T >::getNNodes().

◆ readPartition()

template<class T >
SCIP_RETCODE gcg::Graph< T >::readPartition ( const char *  filename)
virtual

reads the partition from the given file. The format is graph dependent. The default is a file with one line for each node a

read in the partition from a file

Parameters
filenamefilename where the partition is stored

Implements gcg::GraphInterface.

Definition at line 210 of file graph_def.h.

References partition().

◆ getNNonzeroes()

template<class T >
int gcg::Graph< T >::getNNonzeroes ( ) const
inline

Definition at line 169 of file graph.h.

References gcg::Graph< T >::nnonzeroes.

◆ getWeight()

template<class T >
int gcg::Graph< T >::getWeight ( int  i)
virtual

return the weight of given node

Parameters
ithe given node

Definition at line 238 of file graph_def.h.

◆ setDummynodes()

template<class T >
void gcg::Graph< T >::setDummynodes ( int  dummynodes_)
inline

set the number of dummy nodes

Definition at line 180 of file graph.h.

References gcg::Graph< T >::dummynodes.

◆ getDummynodes()

template<class T >
int gcg::Graph< T >::getDummynodes ( ) const
inline

Definition at line 185 of file graph.h.

References gcg::Graph< T >::dummynodes.

◆ flush()

template<class T >
SCIP_RETCODE gcg::Graph< T >::flush
virtual

Implements gcg::GraphInterface.

Definition at line 112 of file graph_def.h.

◆ normalize()

template<class T >
SCIP_RETCODE gcg::Graph< T >::normalize

Definition at line 119 of file graph_def.h.

◆ getEdgeWeightPercentile()

template<class T >
double gcg::Graph< T >::getEdgeWeightPercentile ( double  q)
virtual

Definition at line 277 of file graph_def.h.

Field Documentation

◆ name

template<class T >
std::string gcg::Graph< T >::name

Definition at line 55 of file graph.h.

◆ scip_

template<class T >
SCIP* gcg::Graph< T >::scip_
protected

Definition at line 57 of file graph.h.

Referenced by gcg::Graph< T >::swap().

◆ graph

template<class T >
Bridge* gcg::Graph< T >::graph
protected

Definition at line 58 of file graph.h.

Referenced by gcg::Graph< T >::Graph(), and gcg::Graph< T >::swap().

◆ nconss

template<class T >
int gcg::Graph< T >::nconss
protected

Definition at line 59 of file graph.h.

Referenced by gcg::Graph< T >::swap().

◆ nvars

template<class T >
int gcg::Graph< T >::nvars
protected

Definition at line 60 of file graph.h.

Referenced by gcg::Graph< T >::swap().

◆ nnonzeroes

template<class T >
int gcg::Graph< T >::nnonzeroes
protected

Definition at line 61 of file graph.h.

Referenced by gcg::Graph< T >::getNNonzeroes(), and gcg::Graph< T >::swap().

◆ dummynodes

template<class T >
int gcg::Graph< T >::dummynodes
protected