-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource.cpp
More file actions
60 lines (56 loc) · 1.53 KB
/
source.cpp
File metadata and controls
60 lines (56 loc) · 1.53 KB
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
#include<iostream>
#include<vector>
#include"Graph.h"
#include"Website.h"
using namespace std;
double **matrixPR;
int countWebsites()
{
int counter = 0;
string temp;
ifstream file;
file.open("keywords.csv");
while(!file.eof())
{
getline(file,temp);
counter++;
}
file.close();
return counter;
}
int main()
{
char n;
int choice;
double counter;
int counterOfSites = countWebsites();
matrixPR = new double*[counterOfSites];
for(int i=0; i<counterOfSites;i++)
{
matrixPR[i] = new double[counterOfSites];
}
for(int i=0; i<counterOfSites; i++)
{
for(int j=0; j<counterOfSites; j++)
{
matrixPR[i][j]=0;
}
}
website *allSites = new website[counterOfSites];
allSites->setData(allSites);
allSites->setInitialPRForall(allSites,counterOfSites);
Graph webGraph(counterOfSites); //creates a graph with no. of available nodes
webGraph.addEdge(allSites,counterOfSites); //creates the directed edges between the nodes
for(int i=0; i<counterOfSites; i++)
{
int to[100];
counter = webGraph.outgoing(i, to,(double)counterOfSites); //to get number of elements and their indexes
for(int j=0; j<counter; j++)
{
matrixPR[to[j]][i]=1/counter;
}
}
allSites->setPRSpecific(allSites,matrixPR, counterOfSites);
allSites->setScores(allSites,counterOfSites);
allSites->menu1(allSites, counterOfSites);
}