-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEdgeList.cpp
47 lines (39 loc) · 899 Bytes
/
EdgeList.cpp
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
#include "EdgeList.h"
EdgeList::EdgeList()
{
}
EdgeList::EdgeList(const char* fileName):
GraphRepresentation(fileName)
{
if (!fin.fail()) {
// Ïåðâàÿ ñòðîêà ôàéëà ñîäåðæèò ÷èñëî n,
// îáîçíà÷àþùåå êîëè÷åñòâî ð¸áåð ãðàôà:
fin >> edgesCnt;
edgesList = new int*[edgesCnt];
// Ïîñëåäóþùèå n ñòðîê ñîäåðæàò ïàðû ÷èñåë,
// îáîçíà÷àþùèõ ð¸áðà äëÿ îðèåíòèðîâàííîãî è äóãè äëÿ íåîðèåíòèðîâàííîãî ãðàôîâ:
for (int i = 0; i < edgesCnt; ++i) {
edgesList[i] = new int[2];
for (int j = 0; j < 2; ++j) {
fin >> edgesList[i][j];
}
}
}
}
EdgeList::~EdgeList()
{
if (edgesList) {
for (int i = 0; i < edgesCnt; ++i) {
delete [] edgesList[i];
}
delete [] edgesList;
}
}
int EdgeList::isEdgeBetween(int vertex1, int vertex2)
{
return 0;
}
int EdgeList::getEdgeWeightBetween(int vertex1, int vertex2)
{
return 1;
}