My homework was to design and implement a simple social network program in Java. I should use an adjacency matrix data structure in my implementation. Write a social network program in Java. The default information for this network is stored in two files: index.txt and friend.txt. The file index.txt stores the names of the people in the network – you may assume that we only store the given names and these names are unique; and friend.txt stores who knows whom. The program must read these two files. The following section describes the format of these two files. The friend.txt takes the following format. The first line is the number of pairs of friends. Each subsequent line has two integer numbers. The first two numbers are the indices of the names. The following is an example of friend.txt: 5 0 3 1 3 0 1 2 4 1 5 The index.txt stores the names of the people in the network. The first line is the number of people in the file; for example: 6 0 Gromit 1 Gwendolyn 2 Le-Spiderman 3 Wallace 4 Batman 5 Superman The second line “Gromit” is the label for vertex 0, the third line "Gwendolyn" is for vertex 1. For this system, we will only record the given names (without spaces). By looking at the content of these two files, we know that Gromit is a friend of Wallace and Wallace is a friend of Gromit. We also know that Gwendolyn knows Wallace and Wallace knows Gwendolyn, and so on. Unknown to Wallace and Gromit, Gwendolyn is a friend of Superman! To build the social network, the program reads both files. It uses friend.txt to build the vertices and edges of the social network, and use index.txt to label the vertices. If it fails to read the files (such as file not found), then it must also print appropriate error messages using System.err. The program must also check that the number of relations or indices read is the same as the number of relations or indices specified at the start of each file. The two files above are kept short to simplify the explanation and can be used when you first start developing the program. Eventually, the program will be tested with larger datasets of about 20 friends and 30 pairs of friends.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

My homework was to design and implement a simple social network program in Java. I should use an adjacency matrix data structure in my implementation.

Write a social network program in Java. The default information for this network is stored in two files: index.txt and friend.txt. The file index.txt stores the names of the people in the network – you may assume that we only store the given names and these names are unique; and friend.txt stores who knows whom. The program must read these two files. The following section describes the format of these two files.

The friend.txt takes the following format. The first line is the number of pairs of friends. Each subsequent line has two integer numbers. The first two numbers are the indices of the names. The following is an example of friend.txt:
5
0 3
1 3
0 1
2 4
1 5

The index.txt stores the names of the people in the network. The first line is the number of people in the file; for example:
6
0 Gromit
1 Gwendolyn
2 Le-Spiderman
3 Wallace
4 Batman
5 Superman

The second line “Gromit” is the label for vertex 0, the third line "Gwendolyn" is for vertex 1. For this system, we will only record the given names (without spaces). By looking at the content of these two files, we know that Gromit is a friend of Wallace and Wallace is a friend of Gromit. We also know that Gwendolyn knows Wallace and Wallace knows Gwendolyn, and so on. Unknown to Wallace and Gromit, Gwendolyn is a friend of Superman!

To build the social network, the program reads both files. It uses friend.txt to build the vertices and edges of the social network, and use index.txt to label the vertices. If it fails to read the files (such as file not found), then it must also print appropriate error messages using System.err.

The program must also check that the number of relations or indices read is the same as the number of relations or indices specified at the start of each file. The two files above are kept short to simplify the explanation and can be used when you first start developing the program. Eventually, the program will be tested with larger datasets of about 20 friends and 30 pairs of friends.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY