-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphSearch.java
More file actions
51 lines (44 loc) · 1.56 KB
/
GraphSearch.java
File metadata and controls
51 lines (44 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.HashMap;
import java.util.PriorityQueue;
/**
* File: GraphSearch.java
*
* Author: Jason W Gould
*
* Desc: This class serves as the "Main" program for searching graphs
*/
public class GraphSearch {
public static void main(String[] args)
{
if (args.length == 5)
{
// Get the user-input file name
String fileName = args[0];
try
{
// Get the start and goal node, x and y vals
int start_x = Integer.parseInt(args[1]);
int start_y = Integer.parseInt(args[2]);
int goal_x = Integer.parseInt(args[3]);
int goal_y = Integer.parseInt(args[4]);
GreedyGraphSearch search = new GreedyGraphSearch( goal_x,
goal_y,
start_x,
start_y);
// Process the nodes from the input file
HashMap<Integer, Node> graphList
= search.parseGraph(fileName);
// Uncomment next line to print the input nodes/edges
// graphList.values().forEach(System.out::println);
search.start();
} catch (NumberFormatException e)
{
e.printStackTrace();
}
}
else
{
System.out.println("Incorrect number of input values.");
}
}
}