-
Notifications
You must be signed in to change notification settings - Fork 0
/
Graph.h
68 lines (52 loc) · 1.14 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
#pragma once
#include <queue>
#include <stdio.h>
enum VertexColor { VCWhite, VCGray, VCBlack };
class Vertex
{
public:
Vertex(int _id) :
m_Id(_id)
{
m_Color = VCWhite;
}
int getId() { return m_Id; }
VertexColor getColor() { return m_Color; }
void setColor(VertexColor _c) { m_Color = _c; }
private:
int m_Id;
VertexColor m_Color;
};
class Graph
{
public:
Graph(){ m_nVertices = 0; }
void addEdge(Vertex* _v1, Vertex* _v2);
void clean();
void BFS(Vertex* _s);
void DFS(Vertex* _s);
int findRowNumber(int _id);
Vertex* getVertexById(int _id);
private:
static const int MAX_VERTICES = 100;
static const int MAX_ADJACENT_VERTICES = 100;
Vertex* m_AdjacencyList[MAX_VERTICES][MAX_ADJACENT_VERTICES];
int m_Vertices[MAX_VERTICES];
int m_nVertices;
std::queue<Vertex*> m_Queue;
};
/*
class AdjacencyList
{
public:
AdjacencyList()
{
}
private:
static const int MAX_VERTICES = 100;
static const int MAX_ADJACENT_VERTICES = 100;
Vertex* m_AdjacencyList[MAX_VERTICES][MAX_ADJACENT_VERTICES];
int m_Vertices[MAX_VERTICES];
int m_nVertices;
};
*/