use of graph.GraphBuilder in project SimpleAsteroids by ljialin.
the class MazeModel method findShortestPath.
public List<Vertex> findShortestPath(Vertex from, Vertex to) {
this.from = from;
this.to = to;
ShortestPath shortestPath = new ShortestPath();
shortestPath.runShortestPath(new GraphBuilder().buildGraph(this), from, to);
path = shortestPath.getPath(from, to);
return path;
}
use of graph.GraphBuilder in project SimpleAsteroids by ljialin.
the class MazeView method main.
public static void main(String[] args) {
int n = 400;
int[] bits = new int[n];
Random random = new Random();
for (int i = 0; i < n; i++) {
bits[i] = random.nextInt(2);
}
MazeView mazeView = new MazeView(bits);
new JEasyFrame(mazeView, "Maze Test");
MazeModel mazeModel = new MazeModel(bits);
Graph graph = new GraphBuilder().buildGraph(mazeModel);
System.out.println(graph.getArcs());
System.out.println("Finding shortest path:");
Vertex from = new Vertex(0, 0);
Vertex to = new Vertex(2, 2);
System.out.println(new ShortestPath().runShortestPath(graph, from, to));
}
use of graph.GraphBuilder in project SimpleAsteroids by ljialin.
the class ShortestPathTest method findShortestPath.
public Integer findShortestPath(int[] bits) {
MazeModel mazeModel = new MazeModel(bits);
Graph graph = new GraphBuilder().buildGraph(mazeModel);
// System.out.println(graph.getArcs());
// System.out.println("Finding shortest path:");
// Vertex from = new Vertex(0, 0);
// Vertex to = new Vertex(5, 5);
ShortestPath shortestPath = new ShortestPath();
Integer result = shortestPath.runShortestPath(graph, from, to);
return result;
}
Aggregations