2019-03-27 19:59:28 +01:00
|
|
|
package search;
|
|
|
|
|
|
|
|
public class SearchTestUtils
|
|
|
|
{
|
2019-04-02 20:34:15 +02:00
|
|
|
public static <T> void printSolution(final Node<T> targetNode)
|
2019-03-27 19:59:28 +01:00
|
|
|
{
|
|
|
|
var node = targetNode;
|
|
|
|
|
|
|
|
System.out.println("Read from down to top!");
|
|
|
|
System.out.println("END");
|
|
|
|
|
|
|
|
while (node != null)
|
|
|
|
{
|
|
|
|
System.out.println(node);
|
|
|
|
node = node.getParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println("START");
|
|
|
|
}
|
2023-06-12 18:04:22 +02:00
|
|
|
|
|
|
|
public static <T> int countNodes(final Node<T> targetNode)
|
|
|
|
{
|
|
|
|
var node = targetNode;
|
|
|
|
|
|
|
|
int nodeCount = 0;
|
|
|
|
while (node != null)
|
|
|
|
{
|
|
|
|
nodeCount++;
|
|
|
|
node = node.getParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
return nodeCount;
|
|
|
|
}
|
2019-03-27 19:59:28 +01:00
|
|
|
}
|