Question
The goal of this assignment is to reinforce graph concepts and algorithms. Specifically, the assignment is to do problem 7 on page 780 of the
The goal of this assignment is to reinforce graph concepts and algorithms. Specifically, the assignment is to do problem 7 on page 780 of the textbook (Pictured below).
Example code for reading data from a file has been provided (reading_from_a_file.txt) (Listed below)
You should implement the following functions in your program:
1. list all the friends of a specified person set friends (const graph& network const string& name);
2. list all the friends that 2 specified people have in common set common_friends (const graph& network, const string& name1, const string& name2);
3. list all the friends of the friends of a specified person set friends_of_friends ( const graph& network const string& my_name);
4. adding a friend void add_friend (graph& network, const string& my_name, const string& new_friend);
5. removing a friend void remove_friend (graph& network, const string& my_name, const string& ex_friend);
6. determine whether someone is a friend bool is_friend (const graph& network, const string& my_name, const string& maybe_friend);
---------------------------------------------------------------------------------
reading_from_a_file.txt
---------------------------------------------------------------------------------
The following code will allow you to read from a text file. This code assumes that the text file is of the following format. Note you should use a larger amount of data in your code.
4 Bob Sally Barbara Steve Bob Sally Barbara Sally Sally Bob Steve Bob Bob Steve
void tokenize (const string& s, string& first, string& second) { stringstream ss (s); ss >> first; ss >> second; }
size_t get_index (const graph graph ---------------------------------------------------------------------------------------- graph.h ---------------------------------------------------------------------------------------- #ifndef MAIN_SAVITCH_GRAPH_H #define MAIN_SAVITCH_GRAPH_H #include namespace main_savitch_15 { template -------------------------------------------------------------------------------- graph.template --------------------------------------------------------------------------------// FILE: graph.template (part of the namespace main_savitch_15) // TEMPLATE CLASS IMPLEMENTED: graph
Write a program to help you make better social connections. The program should read a file of data containing a list of people in your community and a list of who knows who. Al- low the user to enter various queries about which people know each other, such as "How many people does Harry know?" or "Is there anvone that both Harry and Cathy know? Write a program to help you make better social connections. The program should read a file of data containing a list of people in your community and a list of who knows who. Al- low the user to enter various queries about which people know each other, such as "How many people does Harry know?" or "Is there anvone that both Harry and Cathy know
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started