1   /**
2    * @author Nick Peters
3    * COMP 469 - Search
4    * Creates a randomly generated graph and finds the shortest path between two 
5    * random vertices.
6    */
7   
8   package search;
9   import java.util.Random;
10  
11  public class SearchClient {
12       
13       public static void main(String[] args) {
14              Random rand = new Random();
15              // The constructor of this object will create our graph for us
16              Search search = new Search();
17              
18              // Random select a source and destination vertex
19              MyVertex [] vertices = new MyVertex[search.g.getVertexCount()];
20              search.g.getVertices().toArray(vertices);
21              MyVertex source = vertices[rand.nextInt(vertices.length)];
22              MyVertex dest = vertices[rand.nextInt(vertices.length)];
23              // Make sure the source and destination are not the same
24              while(dest == source) dest = vertices[rand.nextInt(vertices.length)];
25              
26              // Determine the shortest path between the soruce and destination vertices.
27              search.findShortestPath(source, dest);
28              
29              // Draw the GUI with the results
30              SearchGUI sgui = new SearchGUI(search.g, source.getValue(), dest.getValue());          
31          }
32  }