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)
 

Public Attributes

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

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

Constructor

Parameters
scipSCIP data structure

Definition at line 46 of file graph_def.h.

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

template<class T >
Graph::~Graph ( )
virtual

Destruktor

Definition at line 54 of file graph_def.h.

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

Referenced by gcg::Graph< T >::operator=().

Member Function Documentation

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

adds the edge to the graph

Definition at line 105 of file graph_def.h.

References gcg::Bridge::addEdge(), and gcg::Graph< T >::graph.

Referenced by gcg::Graph< T >::operator=().

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

adds the weighted edge to the graph

Definition at line 290 of file graph_def.h.

References gcg::Bridge::addEdge(), and gcg::Graph< T >::graph.

template<class T >
SCIP_RETCODE Graph::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.

References gcg::Bridge::addNNodes(), and gcg::Graph< T >::graph.

Referenced by gcg::Graph< T >::operator=().

template<class T >
SCIP_RETCODE Graph::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.

References gcg::Bridge::addNNodes(), and gcg::Graph< T >::graph.

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

adds the node with the given weight to the graph

Definition at line 90 of file graph_def.h.

References gcg::Bridge::addNode(), and gcg::Graph< T >::graph.

template<class T >
SCIP_RETCODE Graph::addNode ( )

adds the node with the 0 weight to the graph

Definition at line 97 of file graph_def.h.

References gcg::Bridge::addNode(), and gcg::Graph< T >::graph.

Referenced by gcg::Graph< T >::operator=().

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.

References gcg::Graph< T >::readPartition(), and gcg::Graph< T >::writeToFile().

template<class T >
int Graph::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.

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

Referenced by gcg::Graph< T >::operator=().

template<class T >
SCIP_RETCODE Graph::flush ( )
virtual

Implements gcg::GraphInterface.

Definition at line 112 of file graph_def.h.

References gcg::Bridge::flush(), and gcg::Graph< T >::graph.

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

template<class T>
int gcg::Graph< T >::getDummynodes ( ) const
inline
template<class T >
SCIP_RETCODE Graph::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.

References gcg::Bridge::getEdges(), and gcg::Graph< T >::graph.

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

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

returns the weight of the edge in the graph

Definition at line 306 of file graph_def.h.

References gcg::Bridge::getEdgeWeight(), and gcg::Graph< T >::graph.

Referenced by gcg::Graph< T >::operator=().

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

return the number of edges (or hyperedges)

Definition at line 79 of file graph_def.h.

References gcg::Bridge::getNEdges(), and gcg::Graph< T >::graph.

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

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

return the neighboring nodes of a given node

Parameters
ithe given node

Definition at line 156 of file graph_def.h.

References gcg::Bridge::getNeighbors(), and gcg::Graph< T >::graph.

Referenced by gcg::Graph< T >::edge(), gcg::Graph< T >::operator=(), and gcg::Graph< T >::writeToFile().

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

return the number of neighbor nodes of given node

Parameters
ithe given node

Definition at line 150 of file graph_def.h.

References gcg::Bridge::getNNeighbors(), and gcg::Graph< T >::graph.

Referenced by gcg::Graph< T >::operator=(), and gcg::Graph< T >::writeToFile().

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

Definition at line 169 of file graph.h.

References gcg::Graph< T >::getWeight(), and gcg::Graph< T >::nnonzeroes.

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

return the weight of given node

Parameters
ithe given node

Definition at line 280 of file graph_def.h.

References gcg::Graph< T >::graph, and gcg::Bridge::graphGetWeights().

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

template<class T >
SCIP_RETCODE Graph::normalize ( )

Definition at line 119 of file graph_def.h.

References gcg::Graph< T >::graph, and gcg::Bridge::normalize().

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

template<class T >
SCIP_RETCODE Graph::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

write the graph to a file read in the partition from a file

Parameters
filenamefilename where the partition is stored

Implements gcg::GraphInterface.

Definition at line 252 of file graph_def.h.

References gcg::Graph< T >::getNNodes(), and gcg::GraphInterface::partition.

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

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.

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

sets the weight of the edge in the graph

Definition at line 298 of file graph_def.h.

References gcg::Graph< T >::graph, and gcg::Bridge::setEdge().

Referenced by gcg::Graph< T >::operator=().

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

assigns partition to a given node

Implements gcg::GraphInterface.

Definition at line 163 of file graph_def.h.

References gcg::Graph< T >::getNNodes(), and gcg::GraphInterface::partition.

Referenced by gcg::Graph< T >::operator=().

template<class T >
SCIP_RETCODE Graph::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 170 of file graph_def.h.

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

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

Member Data Documentation

template<class T>
int gcg::Graph< T >::dummynodes
protected
template<class T>
std::string gcg::Graph< T >::name

Definition at line 55 of file graph.h.

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

Definition at line 59 of file graph.h.

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

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().

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

Definition at line 60 of file graph.h.

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

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

Definition at line 57 of file graph.h.

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