Problem 1 [60 pts] Write code to visualize the different strongly connected components of a graph....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Problem 1 [60 pts] Write code to visualize the different strongly connected components of a graph. Your code should be implemented in a file called visualize-scc.py. The function should be called by the same name. The function should take the name of a file. This file will contain the definition of a directed graph. The definition will be specified as follows. The first line will contain the total number of vertices n and the vertex names will be 1,2,...,n. The next few lines will contain edges specified by start vertex and end vertex. So, here is an example file: 3 4 4 5 5 1 The graph above has 5 vertices and is really a cycle graph, with the edges (1, 2), (2, 3), (3, 4), (4, 5), (5, 1). So I can store this file as input.txt for example and call your code as visualize-scc ('input.txt') in the interactive python interpreter. What should it do? It should first compute all the strongly connected components. Then, it should color each scc differently, i.e., vertices in the same scc get the same color - vertices in different scc's get different colors. If the number of scc's is more than say 6 (i.e., you run out of the usual colors), you can color the first few in one color and all the rest in one color. The final output is on the terminal, where you list out the scc's as "SCC1 : x y z .." and also draw the graph using (possibly suitable modifications of the) visualization functions uploaded earlier as python code. Problem 1 [60 pts] Write code to visualize the different strongly connected components of a graph. Your code should be implemented in a file called visualize-scc.py. The function should be called by the same name. The function should take the name of a file. This file will contain the definition of a directed graph. The definition will be specified as follows. The first line will contain the total number of vertices n and the vertex names will be 1,2,...,n. The next few lines will contain edges specified by start vertex and end vertex. So, here is an example file: 3 4 4 5 5 1 The graph above has 5 vertices and is really a cycle graph, with the edges (1, 2), (2, 3), (3, 4), (4, 5), (5, 1). So I can store this file as input.txt for example and call your code as visualize-scc ('input.txt') in the interactive python interpreter. What should it do? It should first compute all the strongly connected components. Then, it should color each scc differently, i.e., vertices in the same scc get the same color - vertices in different scc's get different colors. If the number of scc's is more than say 6 (i.e., you run out of the usual colors), you can color the first few in one color and all the rest in one color. The final output is on the terminal, where you list out the scc's as "SCC1 : x y z .." and also draw the graph using (possibly suitable modifications of the) visualization functions uploaded earlier as python code.
Expert Answer:
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date:
Students also viewed these computer network questions
-
Here is an example of a transaction just took place in a store where hi-fi equipment is sold. A customer purchased a stereo system that cost him $1,000 on the following credit plan. No down payment,...
-
Here is an example of a Smiley Face Questionnaire. Notice how the questions are constructed in a positive statement, and how the responses are structure so that responses can be categorized and...
-
Here is an example of the Battle of the Sexes game discussed in the text. Two people, let us call them Michelle and Roger, although they greatly enjoy each others company, have very different tastes...
-
Solutions to which of the following categories of modeling techniques indicate a course of action to the decision maker? Group of answer choices Preventive models Predictive models Descriptive models...
-
The 2012 financial statements of the Internal Revenue Service are available at: http://www.gao.gov/assets/650/649881.pdf. Use these to answer the following questions. a. Statement of Net Costs 1....
-
A DC motor delivers mechanical power to a rotating stainless steel shaft (k = 15.1 W/m·K) with a length of 25 cm and a diameter of 25 mm. In a surrounding with ambient air temperature of...
-
5 percent interest per month. The sterilizer was delivered on August 23, 1996. The last payment was received on April 21, 1998. At the time of the last payment, the defendant still owed the plaintiff...
-
Periodic versus Perpetual Entries Chippewas Company sells one product. Presented below is information for January for Chippewas Company. Jan. 1 Inventory 100 units at $6 each 4 Sale 80 units at $8...
-
A swimmer wants to cross a river, from point A to point B, as shown in the figure. The distance di (from A to C) is 200 m, the distance d (from C to B) is 150 m, and the speed vr of the current in...
-
Based on the information presented in the minicase, and the discussion in both Chapter 2 and this chapter, to what extent does Elon Musk fit the general charac- teristics of an entrepreneur and a...
-
Company XYZ know that replacement times for the DVD players it produces are normally distributed with a mean of 10.4 years and a standard deviation of 1.4 years. If the company wants to provide a...
-
A helicopter flies with an airspeed of 42.5 m/s [W]. If the wind is traveling with a velocity of 25.0 m/s [E 30 S] relative to the ground then determine the velocity of the helicopter relative to the...
-
start a male underwear brand 1. name the underwear brand and tagline 2. what are your brand colors? 3. how would you sell your underwear? 4. ways to promote your underwear brand? 5. pricing? high-end...
-
An object moves in one dimensional motion with constant acceleration a = 7.9 m/s. At time t = Os, the object is at x0 = 4.7 m and has an initial velocity of vo = 4.6 m/s. How far will the object move...
-
There are three different levels of burden of proof for different matters. In criminal cases, the burden is beyond a reasonable doubt. In most civil cases, the burden is a preponderance of the...
-
Business: Meals in a Jar Location: Daet, Cam Norte On your own words create the ff: Marketing Plan in terms of: Present Market Situation Competitors Target Market (in terms of demographic,...
-
15. Answer the questions that follow based on the output below (note: times are in weeks). Project Management (Triple Time Estimate) Project Completion Time= StdDev of Completion Time- 24.00 2.21...
-
Use the method of Example 4.29 to compute the indicated power of the matrix. 1 0 1
-
a. Show the result of inserting 3, 1, 4, 6, 9, 2, 5, 7 into an initially empty binary search tree. b. Show the result of deleting the root.
-
Using Stirling's formula, N! (N/e)N 2N, give a precise estimate for log(N!).
-
One form of the knapsack problem is as follows: We are given a set of integers A = a1, a2, . . . , aN and an integer K. Is there a subset of A whose sum is exactly K? a. Give an algorithm that solves...
-
Mega Tech, Inc. designs and manufactures automotive components. For years, the company enjoyed a stable marketplace, a small but loyal group of customers, and a relatively predictable environment....
-
Describe the features of a project. How do they differ from day-to-day processes within an organization?
-
In 2003, the Department of Health and Human Services in Victoria, Australia, initiated a AU$323 million project to develop HealthSMART, an integrated IT system that would deliver resource management,...
Study smarter with the SolutionInn App