-
Notifications
You must be signed in to change notification settings - Fork 0
/
Graph.h
52 lines (36 loc) · 844 Bytes
/
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
//
// Created by ahmad on 12/27/16.
//
#ifndef GRAPHTRAVERSE_GRAPH_H
#define GRAPHTRAVERSE_GRAPH_H
#include <vector>
struct GraphVertex
{
bool isVisited;
char key;
GraphVertex();
};
struct GraphEdgeConnection
{
private:
public:
GraphVertex vertex1;
GraphVertex vertex2;
GraphEdgeConnection(char v1, char v2);
bool containVertex(char v);
};
class Graph {
private:
std::vector<GraphEdgeConnection> edgeTable;
std::vector<GraphVertex> vertexes;
std::vector<char> getAllNotVisitedVertexesConnectedTo(char v);
bool containVertex(char v);
bool isVisited(char v);
void visitVertex(char v);
void resetVisited();
public:
void addEdge(char v1, char v2);
std::vector<char> dfs(char startVertex);
std::vector<char> bfs(char startVertex);
};
#endif //GRAPHTRAVERSE_GRAPH_H