Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please solve by python 3 1. create_network(file_name) (35 points) This is the most important (and possibly the most difficult) function to solve. The function needs

image text in transcribed

please solve by python 3

1. create_network(file_name) (35 points) This is the most important (and possibly the most difficult) function 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 list of tuples where each tuple has 2 elements: the first is an integer representing an ID of a user and the second is the list 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-list 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_network("net1.txt") >>> net1 ECo, 1, 2, 3]), (1, [0, 4, 6, 7, 91), (2, [0, 3, 6, 8, 9]), (3, [0, 2, 8, 91), (4. [1, 6, 7, 81) >>>net2-create_netuork("net2.txt") >>> net2 [(0, [1, 2, 3, 4, 5, 6, 7,8,9]), (1, to, 4, 6, 7, 91), (2, to, 3, 6,8, 91, 3, to, 2,8,9]), (4, to, i, 6, 7, 81. >>> net3-create netuork("net3.txt") (100, [112]), (112, [100, 114]), (114, [112])) >>net4-create_netuork("big.txt") >>> net4 [500:502] [(500, [348, 353, 354, 355, 361, 363, 368, 373, 374, 376, 378, 382, 388, 39, 392, 396, 400 402.40. go,409. 41

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

978-0764535376

More Books

Students also viewed these Databases questions