Overview | Schedule | Resources | Assignments | Home |
/home/libs/dataStr/students/
. You may either put
all of the functions (including main and the class definition) in a single
source file, or you may split them up for separate compilation using a
Makefile as discussed in class.numUnique
;Final Project and Take-Home Exam: For the project, write a "Six Degrees of Separation" program. The input will be a file listing groups of mutual acquaintances (described below). The output will be the following pieces of information:
The format of the input is that it consists of a series of lines, with at most one name per line. Blank lines terminate groups of mutual acquaintances. For example, in the following:
Dave Berque Doug Harms Brian Howard Adebayo Olowoyeye Khadija Stewart Scott Thede Gloria Townsend Paul Bender Jon Dellett Brian Howard Verne Leininger John White Lee Williams
Each of the first seven people knows the other six, and each of the six people in the second group knows the other five. The only name in common is Brian Howard (gee, I wonder why that is...), therefore the output should be something like this:
Diameter: 2 Dave Berque knows Brian Howard Brian Howard knows Lee Williams Center: Brian Howard, with average distance 1.0
Here is a data file derived from IMDB, so that you can test the "Kevin Bacon" hypothesis. Note that in this case, "acquainted with" means "appeared in a movie with"; it may well be that some of these people know each other in other ways, but we don't count that.
Here is a simple program which shows one way to read in the input:
#include <iostream> #include <fstream> #include <string> using namespace std; int main() { fstream fin("/home/libs/dataStr/final/imdb.txt"); string name; int n = 0; while (getline(fin, name)) { if (name == "") { cout << "Found a group of " << n << " names" << endl; n = 0; } else { // Got another name for the current group n++; } } return 0; }
You may rely on the last line of the input file being blank. You may also assume that the acquaintance graph is connected -- that is, everyone is connected to everyone else by a chain of finite length.
Both the project and the rest of the exam should be completed individually. You may consult with others only on general information about C++, the STL, and the book's classes. There are two additional written parts to the exam:
The written parts should be turned in to me, either in my office or by email, by 5 pm on Tuesday, May 13. The project should be completed by that time as well — send me email as usual, telling me where it is saved.
Overview | Schedule | Resources | Assignments | Home |
DePauw University,
Computer Science Department,
Spring 2008
Maintained by Brian Howard
(bhoward@depauw.edu
).
Last updated