-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebPage.cpp
87 lines (69 loc) · 1.78 KB
/
WebPage.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
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
82
83
84
85
86
87
#include "WebPage.h"
WebPage::WebPage(){}
WebPage::WebPage(string hyperlink){
index++;
webPageIndex = index;
this->hyperLink = hyperlink;
this->clicks = 0;
this->impressions = 0;
this->outGoingLinks = 0;
}
WebPage::WebPage(const WebPage& W){
this->hyperLink = W.hyperLink;
this->impressions = W.impressions;
this->outGoingLinks = W.outGoingLinks;
this->index = W.index;
this->pageRank = W.pageRank;
this->pageScore = W.pageScore;
}
void WebPage::setHyperlink(string hyperlink){
this->hyperLink = hyperLink;
}
string WebPage::getHyperlink(){
return hyperLink;
}
void WebPage::setPageRank(float pageRank){
this->pageRank = pageRank;
updatePageScore();
}
float WebPage::getPageRank(){
return pageRank;
}
void WebPage::setClicks(int clicks){
this->clicks = clicks;
}
void WebPage::updateClicks(){
// Score should be instantly updated upon clicking on the web page
clicks++;
updatePageScore();
}
int WebPage::getClicks(){
return clicks;
}
void WebPage::setImpressions(int impressions){
this->impressions = impressions;
clickThroughRate = clicks/(impressions*1.0);
}
void WebPage::updateImpressions(){
// Score should be instantly updated upon clicking on the web page
impressions++;
updatePageScore();
}
int WebPage::getImpressions(){
return impressions;
}
void WebPage::updateOutGoingLinks(){
outGoingLinks++;
}
int WebPage::getOutGoingLinks(){
return outGoingLinks;
}
void WebPage::updatePageScore(){
clickThroughRate = clicks/(impressions*1.0);
float term = 1 - (0.1*impressions) / (1 + 0.1*impressions);
pageScore = 0.4 * pageRank + (term * pageRank + term * clickThroughRate)*0.6;
}
float WebPage::getPageScore(){
return pageScore;
}
int WebPage:: index = 0;