-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHypergraph.h
87 lines (75 loc) · 3.62 KB
/
Hypergraph.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#pragma once
#include <vector>
#include <QString>
#include <armadillo>
#include "ColorTable.h"
#include "common.h"
using namespace std;
using namespace arma;
typedef vector<int> HyperEdge;
class Hypergraph
{
public:
Hypergraph(void);
~Hypergraph(void);
private:
int _nVertices;
vector<HyperEdge> _edges;
vector<fvec> _layout;
int _layoutDim;
//ColorTable * _colorTable;
vector<bool> _selectedBuf;
vector<int> _linkageBuf;
vector<int> _clusters;
ColorTable * _clusterColorer;
vector<float> _pinWeights;
vector<int> _partitions;
public:
void setNumOfVertices (int nVertices);
void clearEdges () {_edges.clear();}
void addEdge (const HyperEdge & e) {_edges.push_back(e);}
void saveHypergraph (const QString &fileName);
void loadHypergraph (const QString &fileName);
void layoutGraph (int boundary [], int dim=2, float c=1.0);
void layoutFast (int boundary [], int dim=2, float c=1.0, int Vmax=5, int Smax=10, int nIteration=1000);
void layoutClustered (int boundary [], int nIteration, int dim=2, float c=1.0);
void findSampleSets (int vertexIdx, int nTotal, float &maxDist, const vector<float> &distMat, vector<int> &VBuf, vector<int> &SBuf, int Vmax, int Smax);
void findSampleSets (int vertexIdx, float &maxDist, const vector<float> &distMat, list<int> &sampleBuf, int &Vsize, int Vmax, int Smax);
void saveLayout (const QString &fileName);
void loadLayout (const QString &fileName);
void drawHypergraph ();
void drawPinWeights ();
void drawPartitions ();
const vector<bool>& getSelectionBuf () {return _selectedBuf;}
void setSelectionBuf (const vector<bool> selectionBuf);
bool * selectVertices (const vector<int> &selectedIdx, int mode);
bool * selectLinkage ();
void renewSelection (const bool *selectionBuf, SelectionMode mode);
void addLinkageEdge (const vector<int> idxBuf);
void setLinkageEdge (const vector<int> idxBuf);
void resetLinkageBuf () {_linkageBuf.clear();}
bool assignSelectedToCluster ();
void setClusters (const vector<int> &clusters);
const vector<int>& getClusters () {return _clusters;}
void setClusterColorer (ColorTable *colorer) {_clusterColorer = colorer;}
vector<unsigned> computeGraphDistMat ();
vector<unsigned> computeEdgeDistMat ();
vector<int> getGraphDifference (const Hypergraph *newGraph);
void updateLayout (const vector<int> &changedSet, int boundary [], int dim=2, float c=1.0);
void setEdges (const Hypergraph *newGraph);
void updateLayoutUnpinned (int boundary [], int dim=2, float c=1.0);
void updateLayoutPinned (int boundary [], int dim=2, float c=1.0);
void layoutPartitioned (int boundary [], bool bUpdate = false);
vector<unsigned> getDistToModification (const vector<int> &modifySet);
void getPinnedWeights (const vector<unsigned> &distToModification);
fvec getRepulsiveForce (fvec &pt1, fvec &pt2, float edgeLength);
fvec getAttractiveForce (fvec &pt1, fvec &pt2, float edgeLength);
void getPartitionsByCluster (int &nPartitions, vector<int> &partitionSizes, vector<int> &partitions);
void getPartitionsByEdge (int &nPartitions, vector<int> &partitionSizes, vector<int> &partitions);
void getPartitionsByKDTree (int &nPartitions, vector<int> &partitionSizes, vector<int> &partitions);
void kdPartition (int depth, int targetDepth, vector<fvec>::iterator &firstPt, vector<fvec>::iterator &lastPt,
vector<float> &divisions, int divisionIdx);
int kdCoord (const fvec &pt, int depth, vector<float> &divisions);
vector<int> getSelectedIdx ();
int getLinkage ();
};