Modify Listing 29.3, TestWeightedGraph.java, to create a file for representing graph1. The file format is described in

Question:

Modify Listing 29.3, TestWeightedGraph.java, to create a file for representing graph1. The file format is described in Programming Exercise 29.9. Create the file from the array defined in lines 7–24 in Listing 29.3. The number of vertices for the graph is 12, which will be stored in the first line of the file. An edge (u, v) is stored if u < v. The contents of the file should be as follows:

Data from Listing 29.3,

Programming Exercise 29.9.

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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: