Question: #include #include #include AdjacencyList.h using namespace std; / / prints the PageRank of all pages after p powerIterations in ascending / / alphabetical order

#include
#include
#include "AdjacencyList.h"
using namespace std;
// prints the PageRank of all pages after p powerIterations in ascending
// alphabetical order of webpages and rounding rank to two decimal places
void AdjacencyList::PageRank(int n){
// optionally, store your output in a string/stringstream and then return it from this function after printing so that it is easier to test with Catch
for (auto& page: In_Degree)
Ranking[page.first]=(1.0f /(float)In_Degree.size());
// Creates a new map to hold old page ranks
mapNew_Ranking;
//find the page rank for the iterations
for(int i =1; isecond)* Ranking[connection];
New_Ranking[page.first]= result;
}
Ranking = New_Ranking;
}
map::iterator Rank_Iterator;
for(Rank_Iterator = Ranking.begin(); Rank_Iterator != Ranking.end(); Rank_Iterator++){
cout << setprecision(2)<< fixed << Rank_Iterator->first <<""<< Rank_Iterator->second;
cout <<"
";
}
}
void AdjacencyList::Edges(string from, string to){
Out_Degree[from]+=1;
In_Degree[to].push_back(from);
if(Out_Degree.find(to)== Out_Degree.end())
Out_Degree[to]=0;
if(In_Degree.find(from)== In_Degree.end())
In_Degree[from]={};
} ;
--------------------------------------------
#pragma once
#include
#include
#include
#include
using namespace std;
class AdjacencyList {
private:
// To store sites based on rank
map Ranking;
// To store Out Degree
map Out_Degree;
// To store In Degree
map> In_Degree;
public:
//Think about what helper functions you will need in the algorithm
void PageRank(int n);
void Edges(string from, string to);
};
---------------------------------------------------------
Main.c
#include
#include "AdjacencyList.h"
using namespace std;
int main(){
AdjacencyList Created_Graph;
int no_of_lines, power_iterations;
string from, to;
cin >> no_of_lines;
cin >> power_iterations;
for (int i =0; i < no_of_lines; i++){
cin >> from;
cin >> to;
Created_Graph.Edges(from, to);
}
//Create a graph object
Created_Graph.PageRank(power_iterations);
-----------------------------------------------------------
}Describe the data structure you used to implement the graph and why.
What is the computational complexity of each method in your implementation in the worst case in terms of Big O notation?
What is the computational complexity of your main method in your implementation in the worst case in terms of Big O notation?
What did you learn from this assignment, and what would you do differently if you had to start over?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!