GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
gcg::Graph< T > Class Template Reference

Detailed Description

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

Definition at line 54 of file graph.h.

#include <graph.h>

Public Member Functions

 Graph (GCG *gcgstruct)
void swap (Graph &other)
Graph & operator= (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 (GCG_DECOMP **decomp)

Data Fields

std::string name

Protected Attributes

GCG * gcg
Bridge * graph
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>
Graph::Graph ( GCG * gcgstruct)

Constructor

Parameters
gcgstructGCG data structure

Definition at line 47 of file graph_def.h.

References dummynodes, graph, name, nconss, nnonzeroes, and nvars.

Referenced by operator=(), and swap().

◆ ~Graph()

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

Destruktor

Definition at line 55 of file graph_def.h.

References graph.

Member Function Documentation

◆ swap()

template<class T>
void gcg::Graph< T >::swap ( Graph< T > & other)
inline

Definition at line 71 of file graph.h.

References dummynodes, gcg, Graph(), graph, nconss, nnonzeroes, nvars, and gcg::GraphInterface::partition.

Referenced by operator=().

◆ operator=()

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

Definition at line 83 of file graph.h.

References Graph(), and swap().

◆ addNNodes() [1/2]

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 63 of file graph_def.h.

References graph.

◆ addNNodes() [2/2]

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 69 of file graph_def.h.

References graph.

◆ addNode() [1/2]

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

adds the node with the given weight to the graph

Definition at line 91 of file graph_def.h.

References graph, i, and SCIP_CALL().

◆ addNode() [2/2]

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

adds the node with the 0 weight to the graph

Definition at line 98 of file graph_def.h.

References graph, and SCIP_CALL().

◆ addEdge() [1/2]

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

adds the edge to the graph

Definition at line 106 of file graph_def.h.

References graph, i, j, and SCIP_CALL().

◆ addEdge() [2/2]

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

adds the weighted edge to the graph

Definition at line 251 of file graph_def.h.

References graph, i, j, and SCIP_CALL().

◆ setEdge()

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 259 of file graph_def.h.

References graph, i, j, and SCIP_CALL().

◆ getEdgeWeight()

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

returns the weight of the edge in the graph

Definition at line 267 of file graph_def.h.

References graph, i, and j.

◆ getNeighborWeights()

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

Definition at line 273 of file graph_def.h.

References graph, and i.

Referenced by gcg::GraphAlgorithms< T >::dbscan(), and gcg::GraphAlgorithms< T >::expandCluster().

◆ getNNodes()

template<class T>
int Graph::getNNodes ( )

return the number of nodes

Definition at line 75 of file graph_def.h.

References graph.

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

◆ getNEdges()

template<class T>
int Graph::getNEdges ( )

return the number of edges (or hyperedges)

Definition at line 80 of file graph_def.h.

References graph.

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

◆ getEdges()

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 85 of file graph_def.h.

References graph.

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

◆ edge()

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 127 of file graph_def.h.

References assert(), getNeighbors(), i, and j.

◆ getNNeighbors()

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 147 of file graph_def.h.

References assert(), graph, and i.

Referenced by writeToFile().

◆ getNeighbors()

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 153 of file graph_def.h.

References assert(), graph, and i.

Referenced by edge(), and writeToFile().

◆ setPartition()

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

assigns partition to a given node

Implements gcg::GraphInterface.

Definition at line 160 of file graph_def.h.

References getNNodes(), i, and gcg::GraphInterface::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 146 of file graph.h.

References vars.

◆ writeToFile()

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 167 of file graph_def.h.

References dummynodes, GCGgetOrigprob(), getNEdges(), getNeighbors(), getNNeighbors(), getNNodes(), getWeight(), i, j, and nnodes.

◆ readPartition()

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

read in the partition from a file

Parameters
filenamefilename where the partition is stored

Implements gcg::GraphInterface.

Definition at line 213 of file graph_def.h.

References getNNodes(), i, and gcg::GraphInterface::partition.

◆ getNNonzeroes()

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

Definition at line 170 of file graph.h.

References nnonzeroes.

◆ getWeight()

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

return the weight of given node

Parameters
ithe given node

Definition at line 241 of file graph_def.h.

References graph, and i.

Referenced by writeToFile().

◆ setDummynodes()

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

set the number of dummy nodes

Definition at line 181 of file graph.h.

References dummynodes.

◆ getDummynodes()

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

Definition at line 186 of file graph.h.

References dummynodes.

◆ flush()

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

Implements gcg::GraphInterface.

Definition at line 113 of file graph_def.h.

References graph, and SCIP_CALL().

◆ normalize()

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

Definition at line 120 of file graph_def.h.

References graph, and SCIP_CALL().

◆ getEdgeWeightPercentile()

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

Definition at line 280 of file graph_def.h.

References graph.

Field Documentation

◆ name

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

Definition at line 56 of file graph.h.

Referenced by Graph().

◆ gcg

template<class T>
GCG* gcg::Graph< T >::gcg
protected

Definition at line 58 of file graph.h.

Referenced by swap().

◆ graph

◆ nconss

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

Definition at line 60 of file graph.h.

Referenced by Graph(), and swap().

◆ nvars

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

Definition at line 61 of file graph.h.

Referenced by Graph(), and swap().

◆ nnonzeroes

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

Definition at line 62 of file graph.h.

Referenced by getNNonzeroes(), Graph(), and swap().

◆ dummynodes

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

Definition at line 63 of file graph.h.

Referenced by getDummynodes(), Graph(), setDummynodes(), swap(), and writeToFile().