Java Reference
In-Depth Information
F IGURE 29.26
Programming Exercise 29.14 displays an MST.
F IGURE 29.27
The program can add vertices and edges and display a shortest path between
two specified vertices.
indices. You have to add the vertex indices 0 , 1 , . . ., and n , in this order. The user
can specify two vertices and let the program display their shortest path in red.
***29.16
( Display a dynamic MST ) Write a program that lets the user create a weighted
graph dynamically. The user can create a vertex by entering its name and loca-
tion, as shown in FigureĀ 29.28. The user can also create an edge to connect two
vertices. To simplify the program, assume that vertex names are the same as
those of vertex indices. You have to add the vertex indices 0 , 1 , . . ., and n , in
this order. The edges in the MST are displayed in red. As new edges are added,
the MST is redisplayed.
***29.17
( Weighted graph visualization tool ) Develop a GUI program as shown in
FigureĀ 29.2, with the following requirements: (1) The radius of each vertex is
20 pixels. (2) The user clicks the left mouse button to place a vertex centered
at the mouse point, provided that the mouse point is not inside or too close to
an existing vertex. (3) The user clicks the right mouse button inside an exist-
ing vertex to remove the vertex. (4) The user presses a mouse button inside
a vertex and drags to another vertex and then releases the button to create an
 
Search WWH ::




Custom Search