Chapter 29 Weighted Graphs and Applications
Section 29.2 Representing Weighted Graphs
1. True or False? The WeightedEdge class extends Edge.
a. True
b. False
#
2. A WeightedEdge object contains the public data fields .
a. u
b. v
c. weight
d. length
#
Section 29.3 The WeightedGraph Class
4. The WeightedGraph is a subtype of .
a. UnweightedGraph
b. AbstractGraph
c. Graph
d. WeightedEdge
#
3. The adjacent edge for each vertex in the WeightedGraph class is stored in .
a. an ArrayList
b. a LinkedList
c. a PriorityQueue
d. a Stack
#
5. The addEdge(u, v, w) method performs the following operations:
a. Invokes super.add(u, v) to add an edge.
b. Adds a weighed edge to the adjacent list for vertex u.
c. Adds a weighed edge to the adjacent list for vertex v.
#
Section 29.4 Minimum Spanning Trees
9. Suppose a weighted graph is created in the following code. What is total weight of a minimum spanning tree?
Integer[] vertices = {0, 1, 2, 3, 4};
int[][] edges = {
{0, 1, 9}, {0, 2, 5},
{1, 0, 9}, {1, 2, 6}, {1, 3, 4}, {1, 4, 7},
{2, 0, 5}, {2, 1, 6}, {2, 3, 3},
{3, 1, 4}, {3, 2, 3}, {3, 4, 1},
{4, 1, 7}, {4, 3, 1}
};