#ifndef GCG_GRAPH_H_
#define GCG_GRAPH_H_
#include "objscip/objscip.h"
#include "tclique/tclique.h"
#include "weights.h"
#include "pub_decomp.h"
#include "bridge.h"
#include "graph_interface.h"
#include <exception>
#include <vector>
#include <string>
namespace gcg {
template <class T>
class Graph : public GraphInterface {
public:
std::string name;
protected:
SCIP* scip_;
Bridge* graph;
int nconss;
int nvars;
int nnonzeroes;
int dummynodes;
public:
Graph(
SCIP* scip
);
void swap(Graph & other) {
std::swap(partition, other.partition);
std::swap(scip_ , other.scip_);
std::swap(graph , other.graph);
std::swap(nconss , other.nconss);
std::swap(nvars , other.nvars);
std::swap(nnonzeroes , other.nnonzeroes);
std::swap(dummynodes, other.dummynodes);
}
Graph& operator=(Graph other) {
swap(other);
return *this;
}
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_
) { return SCIP_ERROR; }
virtual SCIP_RETCODE writeToFile(
int fd,
SCIP_Bool writeweights
);
virtual SCIP_RETCODE readPartition(
const char* filename
);
int getNNonzeroes() const
{
return nnonzeroes;
}
virtual int getWeight(
int i
);
void setDummynodes(int dummynodes_)
{
dummynodes = dummynodes_;
}
int getDummynodes() const
{
return dummynodes;
}
SCIP_RETCODE flush();
SCIP_RETCODE normalize();
virtual double getEdgeWeightPercentile(double q);
#ifdef WITH_GSL
virtual void expand(int factor);
virtual void inflate(double factor);
virtual void colL1Norm();
virtual void prune();
virtual bool stopMCL(int iter);
virtual std::vector<int> getClustersMCL();
virtual void initMCL();
virtual void clearMCL();
#endif
};
}
#endif