logo Hurry, Grab up to 30% discount on the entire course
Order Now logo
1082 Times Downloaded

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
George BlackbridgeeCriminology
(5/5)

942 Answers

Hire Me
expert
Ivor CutlerLaw
(5/5)

993 Answers

Hire Me
expert
Caden ButlerEngineering
(5/5)

852 Answers

Hire Me
expert
Manal ChiguerMarketing
(5/5)

556 Answers

Hire Me
Others
(5/5)

Sample code, sample output and instruction are given below. You must write the required functions

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Objective: We want to construct the cities graph and connect cities using shortest roads between them. For example, if there are 4 cities, (co, c1, c2, and c3) then we will make a road between co and the one which has minimum distance to co, and so on.

Sample code: Sample code, sample output and instruction are given below. You must write the required functions (read below) to achieve the objective.

Details: We have a class Graphxy, which has 5 private data fields, namely x, y, n, s, and t. This class is used to construct graph for cities. We construct cities graph by passing the list of x-axis and y-axis for each city (see initializer function). Data fields are:

x stores the x-coordinates of cities

y stores the y-coordinates of cities

n stores number of cities on the graph

s is the screen object for that graph

t is the turtle object for that graph

The class has 4 methods, namely init() initializer function, printpoints(), distances(), and makeroads(), and two other functions (not part of the class). Initializer function makes the graph by taking the list of x-points and y-points, printpoints() makes a graph using turtle and prints the cities at their (x,y) coordinates, the function distances() should calculate distance between all cities (If there are 7 cities, then it will return 7x7 matrix), and makeroads() will connect cities with shortest roads between them.

Structure of the class is shown here:

class Graphxy:

def init (self, xlist = None, ylist = None):

def printpoints (self):

def finddistances (self):

def makeroads (self, d, m):

Testing code is also provided:

It essentially creates an object of class GraphXY using xpoints and ypoints. It is shown below with example results.

(5/5)
Attachments:

Expert's Answer

1082 Times Downloaded

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme