Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 29, Problem 29.9PE

(Find a minimum spanning tree) Write a program that reads a connected graph from a file and displays its minimum spanning tree. The first line in the file contains a number that indicates the number of vertices (n). The vertices are labeled as 0,1,..., n-1. Each subsequent line describes the edges in the form of u1, v1  w1 | u2, v2, w2 |…. Each triplet in this form describes an edge and its weight. Figure 29.23 shows an example of the file for the corresponding graph. Note we assume the graph is undirected. If the graph has an edge (u, v), it also has an edge (v, u). Only one edge is represented in the file. When you construct a graph, both edges need to be added.

FIGURE 29.23 The vertices and edges of a weighted graph can be stored in a file.

Chapter 29, Problem 29.9PE, (Find a minimum spanning tree) Write a program that reads a connected graph from a file and displays , example  1

Your program should prompt the user to enter a URL for the file, read data from the file, create an instance g of WeightedGraph, invoke g.printWeightedEdges() to display all edges, invoke getMinimumSpanningTree() to obtain an instance tree of WeightedGraph.MST, invoke tree.getTotalWeight() to display the weight of the minimum spanning tree, and invoke tree.printTree() to display the tree. Here is a sample run of the program:

Enter a URL:

  https://liveexample.pearsoncmg.com/test/WeightedGraphSample.txt  Chapter 29, Problem 29.9PE, (Find a minimum spanning tree) Write a program that reads a connected graph from a file and displays , example  2

The number of vertices is 6

Vertex 0: (0, 2, 3) (0, 1, 100)

Vertex 1: (1, 3, 20) (1, 0, 100)

Vertex 2: (2, 4, 2) (2, 3, 40) (2, 0, 3)

Vertex 3: (3, 4, 5) (3, 5, 5) (3, 1, 20) (3, 2, 40)

Vertex 4: (4, 2, 2) (4, 3, 5) (4, 5, 9)

Vertex 5: (5, 3, 5) (5, 4, 9)

Total weight in MST is 35

Root is: 0

Edges: (3, 1) (0, 2) (4, 3) (2, 4) (3, 5)

Blurred answer
Students have asked these similar questions
C++ Coding: Arrays Implement a 4x4 two-dimensional array of integers. Use a nested loop to populate the array with random values 0 to 100 inclusive. Use a nested loop to output the array as a grid. Use a single loop to output all elements in the third row. Use a single loop to output all elements in the first column. Use a single loop to output all elements in the first diagonal (r==c). Use a single loop to output all elements in the opposing diagonal. Example Output: 10 75 67 8820 66 55 4831 57 93 3943 76 81 71Row 3: 31 57 93 39Col 1: 10 20 31 43Diagonal 1: 10 66 93 71Diagonal 2: 88 55 57 43
please code in python Forbidden concepts: arrays/lists (data structures), recursion, custom classes You have been asked to take a small icon that appears on the screen of a smart telephone and scale it up so it looks bigger on a regular computer screen.The icon will be encoded as characters (x and *) in a 3 x 3 grid as follows: (refer image1 ) Write a program that accepts a positive integer scaling factor and outputs the scaled icon. A scaling factor of k means that each character is replaced by a k X k grid consisting only of that character. Input Specification:The input will be an integer such that 0 < k ≤ 10. Output Specification:The output will be 3k lines, which represent each individual line scaled by a factor of k and repeated k times. A line is scaled by a factor of k by replacing each character in the line with k copies of the character. [refer image2]
a) Write a program that asks user to enter number of vertices in an undirected graph and then the adjacency matrix representing the undirected graph. The program, then, must display whether the given graph is connected or not. You will find two sample runs of the program below. Sample 1 Sample 2 Enter number of vertices: 3 Enter number of vertices: 3 Enter adjacency matrix: 0 1 1 1 0 0 1 0 0 Enter adjacency matrix: 0 1 0 1 0 0 0 0 0 The graph is connected. The graph is not connected.

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Program to find HCF & LCM of two numbers in C | #6 Coding Bytes; Author: FACE Prep;https://www.youtube.com/watch?v=mZA3cdalYN4;License: Standard YouTube License, CC-BY