-
Notifications
You must be signed in to change notification settings - Fork 1
/
extension.cpp
36 lines (30 loc) · 877 Bytes
/
extension.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
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstring>
#include "ActorGraph.hpp"
using namespace std;
/**
* main method to read and write files and find the average dist to Kevin Bacon
*/
int main(int argc, char* argv[])
{
//make sure there are 2 arguments:program name, movie cast file,
//weight option, pair file, output file
if(argc < 2)
{
cout<<"number of arguments is incorrect, should be 2"<<endl;
return 0;
}
//load file, read pair file
ActorGraph graph;
//update the map
graph.loadFromFile(argv[1],false);
//get the actorStart name, Kevin Bacon in this case
string actorStart = "BACON, KEVIN (I)";
//obtain the average dist from extension method
double average = graph.extension(actorStart);
//print out the dist in terminal
cout<<"Average distance to Kevin Bacon is "<<average<<endl;
return 0;
}