Question: This following program is written in python. It is a small part of a big program. Please help with question 1 listed above. Here are
This following program is written in python. It is a small part of a big program.

Please help with question 1 listed above.
Here are provided python file and 2D list in notepad ++


1 Social Networks: friends recommendations and more 100 points Have you ever wondered how social networks, such as Facebook, recommend friends to you? Most of the social networks use highly sophisticated algorithms for this, but for this assigume yo wl implement a fairly naive algorithto recommend the nost likely new friend to users of a social network. In particular, you will recoed the mt robable user to befrieud based upon the intersection of your common friends. In other words, the user that you will suggest to Person A is the person who has the most friends comon with Peon A, but who currently is not frieds with Person A Five text liles have beeu provided for you to run your program with Each represents a social network. Three are small test files containing a made-up set of users and their friendships (these files are net1.txt, net2.txt and net3.txt). The two are a subset of al Facebook dataset, which was obtained from: fhttps://snap.stanford.edu/data/egonets-Facebook.htal The format of all five files is the same: The first line of the file is an integer representing the number of users in the given network. The following lines re of the form: user-u user-v where user-u and user-v are the (non nesptive integer IDs of two users who are friends In addition user_u is always less than user_v For example, here is a very small file that has 5 users in the social network: 5 0 1 1 2 1 8 2 3 The above is a representation of a social network that contains 5 users. User ID-0 is friends with User IDs 1 User ID-1 is friends with User TDs 0, 2, 8 User ID 2 is friends with User IDs - 1, 3 User ID-3 is friends with User IDs = 2 User ID-8 is friends with User IDs 1 Spend time studying the above small example to understand the model For example, notice that since friendship isa symmetric relationship the social media networks in this assigument, if user u is friends with user_v, that means that user-v is also friends with user_u. Such "duplicate friendships are not present in the file. In particular each friendship is listed once in such way that user uuser v Also note that, while you can assume that ser IDs are sorted, you cannot assume that they are consecutive integers differing hy one. For example the liser lDs hove are: 0.1.2.3.8. You can al assu thaeah file the users are sorted fron smalest to largest (in the above example you see that users appear as: 0 1 1 2). Specifically, friendships of user-u appear before friendships of user-v if and only if user-u user-v And also for each user its friends appear sorted, for example for user l friendhip with friend 2 appears before friendship with riend 4. To complete the assignment you will have to code the following 9 functions. I strongly recommend you code the in the order given below and do not move onto coding a function until you complete all before. The function descriptions, including what they need to do, are given in a4 xxxxxx.py 1. create_network(file_name) (35 points) This is the portant (ad possibly the mos dillicul) functiou to solve. The function needs to read a file and return a list of tuples representing the social network from the file. In particular the function returns a st of tuples where each tuple has 2 elements: the first is an integer representing an ID of a user and the second is te ist of integers representing his her friends. In the a4_xxxxxx.py I refer the list that create_network function returns as a 2D-list for friendship network although one can argue that is is a 3D list). In addition the 2D-liat for friendship network that must create_network function returns must be sorted by the ID and a list of friends in each tuple also must be sorted So for the example above, this function should return the following 2D-list for 2D-list for friendship network: More examples: >>>net1-create_netvork"net1.txt) >> net1 >>net2-create netvork("net2.txt) > net2 >>> net3-create network"net3.txt*) (100, [1121), (112, [100, 114]),. (114, [112])1 >net4-createnetvork("big.txt") >>> net4500:5021 [(500, [348, 353, 354, 355, 361, 363, 368, 373, 374, 376, 378, 382, 388, 391, 392, 396, 400, 402, 404, 408, 409, 410
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
