Question: The data file posted in this module - facebook.csv Download facebook.csv - contains a data set that describes the Facebook network of a group of
The data file posted in this module facebook.csv Download facebook.csv contains a data set that describes the Facebook network of a group of friends. It comes from the data competition site KaggleLinks to an external site., and the names are "anonymized".
The format of the file is commaseparated values CSV but this time there are more fields in each row. Overall, the file forms an adjacency matrix for people. Each row contains:
The name in the first field.
Then, a series of or indicating whether that person is a friend of the person in that column.
If there is a in a column, the two people are friends they are connected to each other in the graph otherwise they are not. The graph is not connected there are some disconnected "islands" of people in the file.
Starting C File
Start with the supplied file fbgraph.cpp Download fbgraph.cpp This file builds a graph using an adjacency list. See the video for an overview of how friends are read from the file and stored in the list.
Assignment
Write a program that prompts the user for the names of two people, and output whether or not there is a path between them in the graph. You can output only a yesno answer no printing of the exact path is required Continue looping for more input until the user enters a blank line.
Use depthfirst search DFS or breadthfirst search BFS either recursive or iterative, and stop the search when you reach the target node.
Notes and Hints
The "friend test" is not simply a test for a direct connection edge If that were true, your code wouldn't need to do a search, it could use a loop to check each friend for a direct connection. A path between two people can be a direct connection, but it might not be a path from A to B might traverse C D and E for example.
Use the 'visited' array to keep track of friends who have been "visited" in a search so far.
Note that the first column names can be either a first name, or a first and last name.
You should be able to complete your DFS or BFS code with only the data structures and syntax we've covered so far in the class. Do not add additional structuressyntax such as maps or additional data structures that are not already present in the file, or additional class definitions or otherwise change how friends are stored. please add your csv also!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
