In “social networking” websites people link to their friends to form a social network. Write a program that uses HashMaps to store the data for such a network. Your program should read from a file that specifies the network connections for different user names. The file should have the following format to specify a link:
source_usernamefriencLusername
There should be an entry for each link, one per line. Here is a sample file for five usernames:
iba | java_guru |
iba | crisha |
iba | ducky |
crisha | java_guru |
crisha | iba |
ducky | java_guru |
ducky | iba |
java_guru | iba |
java_guru | crisha |
java_guru | ducky |
wittless | java_guru |
In this network everyone links to java_guru as a friend, iba is friends with java_guru, crisha, and ducky. Note that links are not bidirectional; wittless links with java_guru but java_guru does not link with wittless.
First, create a User class that has an instance variable to store the user’s name and another instance variable that is of type HashSet
•Upon startup read the data file and populate the HashMap and HashSet data structures according to the links specified in the file.
•Allow the user to enter a name.
•If the name exists in the map then output all usernames that are one link away from the user entered.
•If the name exists in the map then output all usernames that are two links away from the user entered. To accomplish this in a general way you might consider writing a recursive subroutine.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.