Work with the Facebook friends network provided in file Files/a3/3980.edges and the template Java files provided under the same folder. This is a network of people that are friends with each other. This is an undirected network, since Facebook friend connections are undirected. Each line in the "3980.edges" file is an edge "A B". The opposite edge "BA" also appears somewhere in the file. Therefore, the edges in the "3980.edges" file include a connection from A to B and from B to A to represent undirected edges (friend connections). All people in the "3980.edges" file have some relation with a Facebook user with id 3980 (obviously the real name has been obscured). The Facebook network originated from SNAP. Read this entire connectivity network into an adjacency list. You can use your code from assignment 1 for reading in text files. You can use the Node class provided for assignment 2 with a data type of int, then the adjacency list would be of type Node[]. //initialize array Node adjacencyList = new Node[max_num_vertices]; //initialize array elements(objects of LinkedList) for (int i=0; i, then the adjacency list would be of type LinkedList[]. For example: //initialize array LinkedList [] adjacencyList = 7 new LinkedList[max_num_vertices]; //initialize array elements(objects of LinkedList) for (int j=0; j(); Implement the function areFriends, which checks if 2 Facebook users with ids A and B are friends (this is like the hasEdge function in undirected graphs): boolean areFriends (int A, int B) { ... }

icon
Related questions
Question

please answer 

Work with the Facebook friends network provided in file Files/a3/3980.edges and the template Java files
provided under the same folder. This is a network of people that are friends with each other. This is an
undirected network, since Facebook friend connections are undirected. Each line in the "3980.edges" file is an
edge "A B". The opposite edge "BA" also appears somewhere in the file. Therefore, the edges in the
"3980.edges" file include a connection from A to B and from B to A to represent undirected edges (friend
connections).
All people in the "3980.edges" file have some relation with a Facebook user with id 3980 (obviously the real
name has been obscured). The Facebook network originated from SNAP.
Read this entire connectivity network into an adjacency list. You can use your code from assignment 1 for
reading in text files. You can use the Node class provided for assignment 2 with a data type of int, then the
adjacency list would be of type Node[].
//initialize array
Node adjacencyList = new Node[max_num_vertices];
//initialize array elements(objects of LinkedList)
for (int i=0; i<max_num_vertices; i++)
adjacencyList[i] =
= new Node(i);
Alternatively, you could use java.util.LinkedList<Integer>, then the adjacency list would be of type
LinkedList<Integer>[]. For example:
//initialize array
LinkedList<Integer> [] adjacencyList
=
7
new LinkedList[max_num_vertices];
//initialize array elements(objects of LinkedList)
for (int j=0; j<max_num_vertices; j++)
adjacencyList[j] =
= new LinkedList<Integer>();
Implement the function areFriends, which checks if 2 Facebook users with ids A and B are friends (this is like the
hasEdge function in undirected graphs):
boolean areFriends (int A, int B) {
...
}
Transcribed Image Text:Work with the Facebook friends network provided in file Files/a3/3980.edges and the template Java files provided under the same folder. This is a network of people that are friends with each other. This is an undirected network, since Facebook friend connections are undirected. Each line in the "3980.edges" file is an edge "A B". The opposite edge "BA" also appears somewhere in the file. Therefore, the edges in the "3980.edges" file include a connection from A to B and from B to A to represent undirected edges (friend connections). All people in the "3980.edges" file have some relation with a Facebook user with id 3980 (obviously the real name has been obscured). The Facebook network originated from SNAP. Read this entire connectivity network into an adjacency list. You can use your code from assignment 1 for reading in text files. You can use the Node class provided for assignment 2 with a data type of int, then the adjacency list would be of type Node[]. //initialize array Node adjacencyList = new Node[max_num_vertices]; //initialize array elements(objects of LinkedList) for (int i=0; i<max_num_vertices; i++) adjacencyList[i] = = new Node(i); Alternatively, you could use java.util.LinkedList<Integer>, then the adjacency list would be of type LinkedList<Integer>[]. For example: //initialize array LinkedList<Integer> [] adjacencyList = 7 new LinkedList[max_num_vertices]; //initialize array elements(objects of LinkedList) for (int j=0; j<max_num_vertices; j++) adjacencyList[j] = = new LinkedList<Integer>(); Implement the function areFriends, which checks if 2 Facebook users with ids A and B are friends (this is like the hasEdge function in undirected graphs): boolean areFriends (int A, int B) { ... }
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer