-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathredund.h
70 lines (53 loc) · 2.91 KB
/
redund.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
// Copyright 2021 András Mihálykó MIT License
#pragma once
#include <vector>
#include <memory>
#include "graph.h"
#include "M-comp.h"
class RedundHyperGraph : public M_compHyperGraph {
/*
class of an already M-component directed hypergraph.
Can be used to find a transversal of the MCT sets, or
even an optimal redund augmenting edge set.
*/
private:
std::vector<bool> marked;
std::vector<bool> usedForStar;
std::shared_ptr<Vertex> findMinDegreeVertex();
void markOneTight(std::shared_ptr<Vertex> head, std::shared_ptr<Vertex> j);
bool isWholeSized(const std::vector<std::shared_ptr<Vertex> >& V) const {return V.size() == size;}
std::vector<std::shared_ptr<Vertex> > StarSearch(
std::shared_ptr<Vertex> i, std::vector<std::shared_ptr<Vertex> > L);
// Dissertation, Algorithm 8.7
std::vector<std::shared_ptr<Vertex> > getNeighbors(std::shared_ptr<Vertex> i, std::vector<std::shared_ptr<Vertex> > L);
bool threeInTwo(const std::vector<std::shared_ptr<Vertex> >& T1,
const std::vector<std::shared_ptr<Vertex> >& T2, const std::vector<std::shared_ptr<Vertex> >& T3,
const std::vector<std::shared_ptr<Vertex> >& L1, const std::vector<std::shared_ptr<Vertex> >& L2) const;
// utility function for Dissertation, Algorithm 8.17
inline bool isMarked(int id) {return marked[id];}
inline bool isMarked(const Vertex& v) {return isMarked(v.getId());}
inline bool isMarked(const std::shared_ptr<Vertex> v) {return isMarked(v->getId());}
inline void setMark(int id, bool flag) {marked[id] = flag;}
inline void setMark(const std::shared_ptr<Vertex> v, bool flag) {setMark(v->getId(), flag);}
inline void setMark(const Vertex& v, bool flag) {setMark(v.getId(), flag);}
inline bool isUsedForStar(int id) {return usedForStar[id];}
inline bool isUsedForStar(const Vertex& v) {return isUsedForStar(v.getId());}
inline bool isUsedForStar(const std::shared_ptr<Vertex> v) {return isUsedForStar(v->getId());}
inline void setUsedForStar(int id, bool used) {usedForStar[id] = used;}
inline void setUsedForStar(const std::shared_ptr<Vertex> v, bool used) {setUsedForStar(v->getId(), used);}
inline void setUsedForStar(const Vertex& v, bool used) {setUsedForStar(v.getId(), used);}
public:
RedundHyperGraph(const RedundHyperGraph& R) : M_compHyperGraph(R) {
marked = R.marked;
usedForStar = R.usedForStar;
}
explicit RedundHyperGraph(const M_compHyperGraph& HG) : M_compHyperGraph(HG) {
marked = std::vector<bool>(HG.getNumberOfVertices(), false);
usedForStar = std::vector<bool>(HG.getNumberOfVertices(), false);
}
~RedundHyperGraph() {}
std::vector<std::shared_ptr<Vertex> > findTransversal(
std::vector<std::shared_ptr<Vertex> > L = std::vector<std::shared_ptr<Vertex> >());
// Dissertation, Algorithm 8.15
std::vector<Edge> toRedund(); // Dissertation, Algorithm 8.17
};