It seems we can’t find what you’re looking for. Perhaps searching can help.
It seems we can’t find what you’re looking for. Perhaps searching can help.
In this assignment, you will apply Prim's algorithm and the concept of a minimum spanning tree to a real-world network optimization problem.
Note: Prim's Algorithm is discussed in detail in Section 23.2 (pg. 634) of the text.
As such, the tree will contain all vertices of its corresponding graph, and must visit each vertex in a specific order. The minimum spanning tree of a graph is one that is:
As you visit new vertices, be sure to map the new vertex to the edge you took to reach it in the toEdge map. This map will be used to calculate the total distance traveled and will become your minimum spanning tree.
Note that telephone service can travel to any city connected to the network you install. As such, every city does not need a wire to every other city; there only needs to be one common wire which connects every city.With the layout of the country in hand, you must now figure out how to connect every city while minimizing your firm's costs and therefore maximizing their profits. You quickly identify that you'll need to construct a minimum spanning tree of the cities and their distances to determine along which paths you'll need to install wire. Luckily, you're familiar with Prim's algorithm so you fire up Eclipse and begin writing a solution in your favorite programming language, Java.
The unit tests work by constructing a graph with a preconfigured minimum spanning tree. While it is true that in general, graphs will often have more than one MST (though all with the same total weight), the graph generated by the unit tests will have only one. Therefore, by following all of the steps in Prim's algorithm you will find and return the same MST known to the test.