11template <
typename Node>
class Graph {
13 std::map<Node *, std::set<Node *>> GraphBase;
16 using GraphType = std::map<Node *, std::set<Node *>>;
20 void insert(Node *, Node *,
int,
int);
21 bool insert(Node *, Node *);
22 void insert(Node *, std::set<Node *>);
31 template <
typename GraphNode>
38template <
typename Node>
40 if (GraphBase.find(Src) == GraphBase.end())
42 auto Pointee = this->getPointee(Src);
43 return (Pointee.find(Dest) != Pointee.end());
50template <
typename Node>
52 if (Left == 1 && Right == 1) {
53 for (
auto P : this->getPointee(Dest)) {
56 }
else if (Left == 2 && Right == 1) {
57 for (
auto S : this->getPointee(Src)) {
58 for (
auto D : this->getPointee(Dest)) {
62 }
else if (Left == 1 && Right == 0) {
63 this->insert(Src, Dest);
64 }
else if (Left == 1 && Right == 2) {
65 for (
auto D : this->getPointee(Dest)) {
66 for (
auto DestDest : this->getPointee(D)) {
67 this->insert(Src, DestDest);
76 if (this->hasEdgeBetween(Src, Dest))
78 this->GraphBase[Src].insert(Dest);
83template <
typename Node>
85 if (this->GraphBase.find(N) == this->GraphBase.end()) {
86 this->GraphBase[N] = Pointee;
88 this->GraphBase[N].insert(Pointee.begin(), Pointee.end());
95 std::set<Node *> PointeeSet;
96 if (this->GraphBase.find(N) != this->GraphBase.end())
97 PointeeSet = this->GraphBase[N];
104 Node *Pointee =
nullptr;
105 if (this->GraphBase.find(N) != this->GraphBase.end())
106 if (this->GraphBase[N].size() == 1)
107 Pointee = *((this->GraphBase[N]).begin());
111template <
typename Node>
113 return this->GraphBase.size() == TheGraph.GraphBase.size() &&
114 std::equal(this->GraphBase.begin(), this->GraphBase.end(),
115 TheGraph.GraphBase.begin());
118template <
typename Node>
120 return this->GraphBase.size() < TheGraph.GraphBase.size();
123template <
typename Node>
125 for (
auto X : G.GraphBase) {
126 OS << *(X.first) <<
" -> {";
127 for (
auto Y : X.second) {
137 this->GraphBase[N].clear();
141template <
typename Node>
143 for (
auto Map : Maps) {
144 for (
auto N : Map.GraphBase) {
145 if (this->GraphBase.find(N.first) == this->GraphBase.end()) {
146 this->GraphBase[N.first] = N.second;
148 this->GraphBase[N.first].insert(N.second.begin(), N.second.end());
Node * getUniquePointee(Node *)
Definition: Graph.h:103
typename GraphType::iterator iterator
Definition: Graph.h:17
void merge(std::vector< Graph< Node > > Graphs)
merge - Merges the Graphs from Graphs
Definition: Graph.h:142
friend std::ostream & operator<<(std::ostream &OS, const Graph< GraphNode > &G)
bool operator==(const Graph< Node > &TheGarph) const
Definition: Graph.h:112
void erase(Node *)
erase - Erases the node Node
Definition: Graph.h:136
std::set< Node * > getPointee(Node *)
Definition: Graph.h:94
bool operator<(const Graph< Node > &TheGarph) const
Definition: Graph.h:119
void insert(Node *, Node *, int, int)
Definition: Graph.h:51
iterator end()
Definition: Graph.h:28
iterator begin()
Definition: Graph.h:27
std::map< Node *, std::set< Node * > > GraphType
Definition: Graph.h:16
bool hasEdgeBetween(Node *, Node *)
hasEdgeBetween - Returns true if there is a edge between Src and Dest
Definition: Graph.h:39
Definition: PointsToBenchmark.cpp:19
std::ostream & operator<<(std::ostream &OS, const PointsToBenchmarkRunner &B)
Definition: PointsToBenchmark.cpp:49