-
Notifications
You must be signed in to change notification settings - Fork 0
/
Graph.h
125 lines (104 loc) · 2.03 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Author: Christopher Lee Jackson
// Course: CMPMSC 463 - Spring 10
#ifndef __GRAPH_H_INCLUDED__
#define __GRAPH_H_INCLUDED__
#include <limits>
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <cmath>
//#include "mersenne.cxx"
using namespace std;
class Vertex;
class Edge;
class Hub;
class Hub {
public:
unsigned int vertId;
vector<Edge*> edges;
Vertex* vert;
bool inTree;
int lenPath;
~Hub(){edges.~vector();}
};
/*
*
* VERTEX CLASS
*
*/
class Vertex {
public:
Vertex *pNextVert;
vector<Edge*> edges;
int data;
int degree;
int treeDegree;
int visited;
int depth;
bool inTree;
bool isConn;
Hub* pHub;
double x_coord, y_coord;
double sum;
void updateVerticeWeight();
~Vertex(){}
}; // END VERTEX
/*
*
* EDGE CLASS
*
*/
class Edge {
public:
Vertex *a;
Vertex *b;
int id;
double pUpdatesNeeded;
bool inTree;
bool usable;
double weight;
double pLevel;
void setSource(Vertex* s);
void setDestination(Vertex* d);
Vertex* getSource(Vertex* loc);
Vertex* getDestination(Vertex* loc);
Vertex* getOtherSide(Vertex* loc);
};
/*
*
* GRAPH CLASS
*
*/
class Graph{
public:
unsigned int numNodes;
int root;
int oddRoot;
int height;
int eCount;
Vertex *first;
Edge* *eList;
Vertex* nodes[1001];
vector<Vertex*> **vDepths;
Graph();
~Graph();
int insertVertex(int dataIn, Hub* hub = NULL);
int deleteVertex(int dltKey);
int insertEdge (int fromKey, int toKey, double weight, double pLevel = 0);
void removeEdge(int a, int b);
double insertEdge(int fromKey, int toKey);
int insertVertex(int dataIn, double x, double y);
bool emptyGraph();
unsigned int getNumNodes();
void print();
void print_search(Vertex *vertPtr);
Vertex* getFirst();
Vertex* getRand();
int BFS(Vertex* pVert);
Vertex* BFS_2(Vertex* pVert);
int testDiameter();
bool isConnected();
void setEList(int);
};
#endif