-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph.h
executable file
·104 lines (83 loc) · 3.42 KB
/
graph.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#define GRAPH_H
typedef class Graph* LPGraph;
class Graph
{
public:
//data members
myInt nVertices; myInt* d_nVertices; //number of vertices in the graph
myInt** Edge; int* d_EdgeField; //matrix containing the edges of the graph
myInt* Labels; myInt* d_Labels; //identifies the connected components of the graph
myInt nLabels; myInt* d_nLabels; //number of labels or connected components
myInt** Cliques; //storage for cliques
myInt* CliquesDimens; //number of vertices in each clique
myInt nCliques; myInt* d_nCliques; //number of cliques
public:
myInt* TreeEdgeA; //edges of the clique tree
myInt* TreeEdgeB;
myInt nTreeEdges; //number of edges in the generated clique tree
public:
myInt** Separators; //storage for separators
myInt* SeparatorsDimens;
myInt nSeparators;
//private:
myInt* localord;
//methods
public:
Graph(); //constructor
Graph(LPGraph InitialGraph); //constructor
~Graph(); //destructor
public:
myInt SearchVertex(); // identifies the next vertex to be eliminated
void FlipEdge(myInt which); // flips an edge on a graph which is a myInteger between 0 and the total number of edges
public:
//the MSS (Minimal Sufficient Statistics) are the maximal cliques for our graph
void InitGraph(myInt n);
void CopyGraph (LPGraph G);
void GenerateCliques(myInt label);
myInt CheckCliques(myInt start, myInt end); //checks whether each generated component is complete in the given graph
myInt IsClique(myInt* vect,myInt nvect); //checks if the vertices in vect form a clique in our graph
void GenerateSeparators();
void AttachLabel(myInt v, myInt label);
void GenerateLabels();
myInt GenerateAllCliques();
myInt IsDecomposable();
myInt IfDecomposable();
myInt CanDeleteEdge (myInt a, myInt b);
bool CanAddEdge (myInt a, myInt b);
Real ScoreDeleteEdge(myInt a, myInt b, myInt which_ab, Real* D_prior, Real* D_post, myInt delta, myInt n_sub, Real score, int nEdges);
Real ScoreAddEdge(myInt a, myInt b, Real* D_prior, Real* D_post, myInt delta, myInt n_sub, Real score, int nEdges);
};
//////////////////////////////////////////////////////////////////////
typedef class SectionGraph* LPSectionGraph;
class SectionGraph : public Graph
{
public:
myInt* Eliminated; //shows which vertices were eliminated from the initial graph
myInt nEliminated; //number of vertices we eliminated
//methods
public:
SectionGraph(LPGraph InitialGraph,myInt* velim); //constructor
~SectionGraph(); //destructor
public:
myInt IsChain(myInt u,myInt v); //see if there is a chain between u and v
//or, equivalently, checks if u and v are in the same connected component
};
////////////////////////////////////////////////////////////////////////
typedef class EliminationGraph* LPEliminationGraph;
class EliminationGraph : public Graph
{
public:
myInt* Eliminated; //shows which vertices were eliminated from the initial graph
myInt nEliminated; //number of vertices we eliminated
//methods
public:
EliminationGraph(LPGraph InitialGraph,myInt vertex); //constructor
~EliminationGraph(); //destructor
public:
myInt SearchVertex(); //identify a vertex to be eliminated
public:
void EliminateVertex(myInt x); //eliminates an extra vertex
};
//////////////////////////////////////////////////////////////////////////
//constructs the minimum fill-in graph for a nondecomposable graph
void TurnFillInGraph(LPGraph graph);