-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNodeGraph.h
54 lines (46 loc) · 930 Bytes
/
NodeGraph.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
/*
* Header file that contains Node, Edge, and other global variables
*/
// --------------
// Graph Classes
// --------------
#include <iostream>
#include <vector>
#include <pthread.h>
using namespace std;
class Node;
class Edge{
public:
Node* source;
Node* destination;
int weight;
public:
Edge(Node* s, Node* d, int w) : source(s), destination(d), weight(w) {};
};
class Node{
public:
vector<Edge*> input;
int cost;
public:
Node(int c) : cost(c) {};
void addEdge(Edge* e){
input.push_back(e);
};
};
class threadObject{
public:
pthread_t tid;
vector<Node*> inputNodes;
bool threadComplete = true;
int threadID;
};
// -----------------
// Global Variables
// -----------------
bool threadCheck();
static vector<Node*> allNodes;
static vector<threadObject> threads;
static pthread_barrier_t barrier;
static pthread_barrier_t barrierCheck;
static pthread_barrier_t barrierCheck2;
static pthread_mutex_t mutex;