本文整理汇总了C++中WebURL::getOldPageRank方法的典型用法代码示例。如果您正苦于以下问题:C++ WebURL::getOldPageRank方法的具体用法?C++ WebURL::getOldPageRank怎么用?C++ WebURL::getOldPageRank使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebURL
的用法示例。
在下文中一共展示了WebURL::getOldPageRank方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculatePageRank
void calculatePageRank(int& iterationNumber, long& totalURLs, unordered_map<long,WebURL>& webURLs,float& dampingFactor)
{
#ifdef _TRACE
cout<<"\nIteration : "<<iterationNumber - 1<<" Dangling Factor = "<<danglingFactor<<endl;
#endif
double tmpDanglingFactor = 0;
unordered_map<long,WebURL>::iterator it;
// Iterating through each Key (Representing Page) in the Map and calculating the Page Rank of the pages associated with it.
for(it = webURLs.begin(); it != webURLs.end(); it++)
{
WebURL *masterURL = &(it->second);
list<WebURL *> listofOutboundURLs = masterURL->getOutboundWebURLs();
list<WebURL *>::iterator listite;
double val;
// First time call the evaluate function for the master url to change the iteration number and
// calculate the pagerank of the previous iteration
masterURL->evaluate(iterationNumber,dampingFactor,totalURLs);
#ifdef _TRACE
cout<<"src_url: "<<masterURL->getId()<<" cur_val:["<<masterURL->getOldPageRank()<<"]"<<endl;
#endif
if(!listofOutboundURLs.empty())
{
for(listite = listofOutboundURLs.begin(); listite != listofOutboundURLs.end(); listite++)
{
WebURL *url = *listite;
url->evaluate(iterationNumber,dampingFactor,totalURLs);
val = (masterURL->getOldPageRank() / (double)(listofOutboundURLs.size()));
url->setNewPageRank(val + url->getNewPageRank());
#ifdef _TRACE
cout<<" ->tar_url:"<<url->getId()<<" cur_val:"<<url->getOldPageRank()<<" added_val:"<<val<<endl;
#endif
}
}
else
{
tmpDanglingFactor += masterURL->getOldPageRank();
}
}
// Saving the dangling factor to use it in the next cycle
danglingFactor = tmpDanglingFactor;
}