MCPcopy Create free account
hub / github.com/MolinDeng/Princeton-algs4 / Node

Class Node

LabEnv/04Lab/Solver.java:19–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17 private final Node goal;
18
19 private class Node implements Comparable<Node> {
20 final Board board;
21 final Node prev;
22 final int moves;
23 final int manhattanScore;
24
25 Node(Board b, Node p, int m) {
26 board = b;
27 prev = p;
28 moves = m;
29 manhattanScore = m + b.manhattan();
30 }
31
32 public int compareTo(Node that) {
33 return Integer.compare(this.manhattanScore, that.manhattanScore);
34 }
35 }
36
37 // find a solution to the initial board (using the A* algorithm)
38 public Solver(Board initial) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected