-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction.h
81 lines (59 loc) · 1.38 KB
/
function.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
#ifndef FUNCTION_H
#define FUNCTION_H
#include <string>
#include <iostream>
#include <vector>
class Neighbor
{
public:
int label;
int weight;
Neighbor(){};
Neighbor(int label){
this->label = label;
};
Neighbor(int label , int weight){
this->label = label;
this->weight = weight;
}
~Neighbor(){};
bool operator ==(const Neighbor &N){
return (this->label == N.label) && (this->weight == N.weight);
}
};
class Vertex
{
public:
int label;
std::vector<Neighbor> neighbors;
Vertex(){};
Vertex(int label){
this->label = label;
}
~Vertex(){};
};
class Graph_operations
{
public:
std::vector<Vertex> VertexArr;
virtual void Allocate_vertexMem(int n) = 0;
virtual void addEdge(const int label_1, const int label_2 , const int weight) = 0;
virtual int shortest_path(const int label_1 , const int label_2) = 0;
virtual int mst_weight() = 0;
virtual bool two_colorable() = 0;
};
class Implement : public Graph_operations
{
public:
void Allocate_vertexMem(int n)
{
VertexArr.resize(n);
for(int i = 0 ; i < n ; i++)
VertexArr[i].label = i;
}
void addEdge(const int label_1, const int label_2 , const int weight);
int shortest_path(const int label_1 , const int label_2);
int mst_weight();
bool two_colorable();
};
#endif // FUNCTION_H