Question: solve it in python. just answer the two functions You are given a piece of python code and a txt file named graph.txt. The input

 solve it in python. just answer the two functions You are

given a piece of python code and a txt file named graph.txt.

The input file contains the number of vertices in the first line,

n, followed by the number of connections, c. Then there are c

solve it in python. just answer the two functions

You are given a piece of python code and a txt file named graph.txt. The input file contains the number of vertices in the first line, n, followed by the number of connections, c. Then there are c numbers of lines mentioning the connection between a pair of vertices in the form a,ba is connected to b. The graph given is a directed graph. If you look at the python file you will see that the methods readFile() and buildGraphusingDictionary() have been done for you. Not only that, comments have been added for you to understand how each line is working and why it has been used. Read the comments very carefully and study the code and of course run the code to match your input with the output. Your job is to complete the buildGraphUsinglistoflists() method and the printGraph() method. Google "list of lists in python" to aid you complete the tasks. \# we want to build an adjacency list like the following #AB,C \# One vertex can be connected to multiple vertices \# which means multiple values are associated with one vertex \# one data structure that can be used is a dictionary of lists #{A:[B,C]} def buildGraphUsingDictionary (c,f) : \# creating a dictionary graph ={} \# the following lines of the file contain the connections \# creating a directed graph ( a,b means a is connected to b)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!