|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Tests for A* shortest path algorithm. More...
#include <gtest/gtest.h>#include <tpl_graph.H>#include <AStar.H>#include <Dijkstra.H>#include <tpl_graph_utils.H>#include <random>#include <cmath>#include <functional>#include <stdexcept>#include <vector>Go to the source code of this file.
Classes | |
| struct | BinHeapTag |
| struct | FibHeapTag |
| struct | SimpleNode |
| struct | SimpleArc |
| struct | GridNode |
| struct | GridArc |
| struct | DoubleDistance |
| struct | GridEuclideanHeuristic |
| struct | GridManhattanHeuristic |
| class | AStarBasicTest |
| class | AStarGridTest |
| class | AStarDijkstraModeTest |
| class | AStarHeapTest< HeapTag > |
| struct | Scaled_Distance |
| struct | Array_Heuristic |
| struct | Factor_Only_Distance |
| struct | Call_Failure |
| struct | Failing_Distance |
| struct | Failing_Heuristic |
Typedefs | |
| using | SimpleGraph = List_Graph< SimpleNode, SimpleArc > |
| using | GridGraph = List_Graph< GridNode, GridArc > |
| using | HeapTypes = ::testing::Types< BinHeapTag, FibHeapTag > |
| using | IntGraph = List_Graph< Graph_Node< int >, Graph_Arc< int > > |
| using | IntDigraph = List_Digraph< Graph_Node< int >, Graph_Arc< int > > |
Functions | |
| TEST_F (AStarBasicTest, ZeroHeuristicMatchesDijkstra) | |
| TEST_F (AStarBasicTest, FindsShortestPath) | |
| TEST_F (AStarBasicTest, PaintPathWorks) | |
| TEST_F (AStarBasicTest, ComputePathBuildsTree) | |
| TEST_F (AStarBasicTest, NoPathReturnsMax) | |
| TEST_F (AStarBasicTest, StartEqualsEnd) | |
| TEST_F (AStarGridTest, EuclideanHeuristicFindsShortest) | |
| TEST_F (AStarGridTest, ManhattanHeuristicFindsShortest) | |
| TEST_F (AStarGridTest, GoodHeuristicReducesExploration) | |
| TEST_F (AStarBasicTest, OperatorInterface) | |
| TEST (AStarEdgeCases, SingleNodeGraph) | |
| TEST (AStarEdgeCases, NullParametersThrow) | |
| TEST (AStarEdgeCases, EmptyGraphThrows) | |
| TEST (AStarComparison, RandomGraphMatchesDijkstra) | |
| TEST_F (AStarDijkstraModeTest, ComputeMinPathsTreeBuildsCompleteTree) | |
| TEST_F (AStarDijkstraModeTest, PaintMinPathsTreePaintsAll) | |
| TEST_F (AStarDijkstraModeTest, FindMinPathMatchesDijkstra) | |
| TEST_F (AStarDijkstraModeTest, ComputePartialMinPathsTree) | |
| TEST_F (AStarDijkstraModeTest, PaintPartialMinPathsTree) | |
| TEST_F (AStarDijkstraModeTest, GetDistanceAfterPainting) | |
| TEST_F (AStarDijkstraModeTest, CopyPaintedMinPathsTree) | |
| TEST_F (AStarDijkstraModeTest, OperatorTreeVersion) | |
| TEST (AStarErrorCases, GetDistanceThrowsIfNotPainted) | |
| TEST (AStarErrorCases, CopyPaintedThrowsIfNotPainted) | |
| TEST_F (AStarDijkstraModeTest, TreesMatchDijkstra) | |
| TEST (AStarDijkstraMode, DisconnectedGraph) | |
| TEST_F (AStarDijkstraModeTest, StateGetters) | |
| TYPED_TEST_SUITE (AStarHeapTest, HeapTypes) | |
| TYPED_TEST (AStarHeapTest, FindPathWithHeuristic) | |
| TYPED_TEST (AStarHeapTest, ComputeMinPathsTree) | |
| TYPED_TEST (AStarHeapTest, PaintAndGetDistance) | |
| TYPED_TEST (AStarHeapTest, MatchesDijkstra) | |
| TEST (AStarEdgeCaseTest, SelfLoop) | |
| TEST (AStarEdgeCaseTest, MultipleArcsBetweenNodes) | |
| TEST (AStarEdgeCaseTest, UniformWeights) | |
| TEST (AStarEdgeCaseTest, LargeWeights) | |
| TEST (AStarEdgeCaseTest, Reusability) | |
| TEST (AStarEdgeCaseTest, ZeroWeightArcs) | |
| TEST (AStarEdgeCaseTest, InadmissibleHeuristic) | |
| TEST (AStarPolicyTest, UsesTheDistanceItWasGiven) | |
| TEST (AStarPolicyTest, FindsAPathOfMaxThroughAPriorityThatDoesNotFit) | |
| TEST (AStarPolicyTest, TakesADistanceWithoutADefaultConstructor) | |
| TEST (AStarPolicyTest, DistanceOrHeuristicThatThrowsLeavesTheGraphReusable) | |
| int | main (int argc, char **argv) |
Tests for A* shortest path algorithm.
Tests cover:
Definition in file astar_test.cc.
| using GridGraph = List_Graph<GridNode, GridArc> |
Definition at line 103 of file astar_test.cc.
| using HeapTypes = ::testing::Types<BinHeapTag, FibHeapTag> |
Definition at line 716 of file astar_test.cc.
| using IntDigraph = List_Digraph<Graph_Node<int>, Graph_Arc<int> > |
Definition at line 1038 of file astar_test.cc.
| using IntGraph = List_Graph<Graph_Node<int>, Graph_Arc<int> > |
Definition at line 986 of file astar_test.cc.
| using SimpleGraph = List_Graph<SimpleNode, SimpleArc> |
Definition at line 85 of file astar_test.cc.
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Definition at line 1256 of file astar_test.cc.
| TEST | ( | AStarComparison | , |
| RandomGraphMatchesDijkstra | |||
| ) |
Definition at line 411 of file astar_test.cc.
References Aleph::Dijkstra_Min_Paths< GT, Distance, Itor, SA, HeapT >::find_min_path(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::find_path(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), nodes, rng, and w.
| TEST | ( | AStarDijkstraMode | , |
| DisconnectedGraph | |||
| ) |
Definition at line 654 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::compute_min_paths_tree(), GraphCommon< GT, Node, Arc >::get_num_nodes(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), and Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node().
| TEST | ( | AStarEdgeCases | , |
| EmptyGraphThrows | |||
| ) |
Definition at line 398 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::find_path(), and Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node().
| TEST | ( | AStarEdgeCases | , |
| NullParametersThrow | |||
| ) |
Definition at line 385 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::find_path(), and Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node().
| TEST | ( | AStarEdgeCases | , |
| SingleNodeGraph | |||
| ) |
Definition at line 372 of file astar_test.cc.
References Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), and Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::paint_path().
| TEST | ( | AStarEdgeCaseTest | , |
| InadmissibleHeuristic | |||
| ) |
Definition at line 944 of file astar_test.cc.
References Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), Aleph::Path< GT >::is_empty(), GridNode::x, and GridNode::y.
| TEST | ( | AStarEdgeCaseTest | , |
| LargeWeights | |||
| ) |
Definition at line 862 of file astar_test.cc.
References Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), and Aleph::Path< GT >::is_empty().
| TEST | ( | AStarEdgeCaseTest | , |
| MultipleArcsBetweenNodes | |||
| ) |
Definition at line 817 of file astar_test.cc.
References Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), and Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node().
| TEST | ( | AStarEdgeCaseTest | , |
| Reusability | |||
| ) |
Definition at line 884 of file astar_test.cc.
References Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), and nodes.
| TEST | ( | AStarEdgeCaseTest | , |
| SelfLoop | |||
| ) |
Definition at line 797 of file astar_test.cc.
References Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), and Aleph::Path< GT >::size().
| TEST | ( | AStarEdgeCaseTest | , |
| UniformWeights | |||
| ) |
Definition at line 837 of file astar_test.cc.
References Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), nodes, and Aleph::Path< GT >::size().
| TEST | ( | AStarEdgeCaseTest | , |
| ZeroWeightArcs | |||
| ) |
Definition at line 923 of file astar_test.cc.
References Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), and Aleph::Path< GT >::size().
| TEST | ( | AStarErrorCases | , |
| CopyPaintedThrowsIfNotPainted | |||
| ) |
Definition at line 626 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::copy_painted_min_paths_tree(), and Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node().
| TEST | ( | AStarErrorCases | , |
| GetDistanceThrowsIfNotPainted | |||
| ) |
Definition at line 615 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::get_distance(), and Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node().
| TEST | ( | AStarPolicyTest | , |
| DistanceOrHeuristicThatThrowsLeavesTheGraphReusable | |||
| ) |
Definition at line 1173 of file astar_test.cc.
References Aleph::Dijkstra_Min_Paths< GT, Distance, Itor, SA, HeapT >::find_min_path(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), k, m, r, and OhashCommon< HashTbl, Key >::size().
| TEST | ( | AStarPolicyTest | , |
| FindsAPathOfMaxThroughAPriorityThatDoesNotFit | |||
| ) |
Definition at line 1057 of file astar_test.cc.
References h.
| TEST | ( | AStarPolicyTest | , |
| TakesADistanceWithoutADefaultConstructor | |||
| ) |
Definition at line 1099 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::compute_min_paths_tree(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::compute_partial_path(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::copy_painted_min_paths_tree(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::find_min_path(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::find_path(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::get_distance(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::get_min_path(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node(), and Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::paint_min_paths_tree().
| TEST | ( | AStarPolicyTest | , |
| UsesTheDistanceItWasGiven | |||
| ) |
Definition at line 1000 of file astar_test.cc.
References Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_arc(), and Aleph::List_Graph< _Graph_Node, _Graph_Arc >::insert_node().
| TEST_F | ( | AStarBasicTest | , |
| ComputePathBuildsTree | |||
| ) |
Definition at line 276 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::compute_path(), GraphCommon< GT, Node, Arc >::get_num_nodes(), and nodes.
| TEST_F | ( | AStarBasicTest | , |
| FindsShortestPath | |||
| ) |
Definition at line 249 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::find_path(), nodes, and Aleph::Path< GT >::size().
| TEST_F | ( | AStarBasicTest | , |
| NoPathReturnsMax | |||
| ) |
Definition at line 288 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::find_path(), Aleph::Path< GT >::is_empty(), and nodes.
| TEST_F | ( | AStarBasicTest | , |
| OperatorInterface | |||
| ) |
Definition at line 361 of file astar_test.cc.
References nodes.
| TEST_F | ( | AStarBasicTest | , |
| PaintPathWorks | |||
| ) |
Definition at line 262 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::get_min_path(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::is_painted(), nodes, and Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::paint_path().
| TEST_F | ( | AStarBasicTest | , |
| StartEqualsEnd | |||
| ) |
Definition at line 303 of file astar_test.cc.
References nodes, and Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::paint_path().
| TEST_F | ( | AStarBasicTest | , |
| ZeroHeuristicMatchesDijkstra | |||
| ) |
Definition at line 233 of file astar_test.cc.
References Aleph::Dijkstra_Min_Paths< GT, Distance, Itor, SA, HeapT >::find_min_path(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::find_path(), nodes, and Aleph::Path< GT >::size().
| TEST_F | ( | AStarDijkstraModeTest | , |
| ComputeMinPathsTreeBuildsCompleteTree | |||
| ) |
Definition at line 486 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::compute_min_paths_tree(), GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), nodes, and root().
| TEST_F | ( | AStarDijkstraModeTest | , |
| ComputePartialMinPathsTree | |||
| ) |
Definition at line 537 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::compute_partial_min_paths_tree(), GraphCommon< GT, Node, Arc >::get_num_nodes(), and nodes.
| TEST_F | ( | AStarDijkstraModeTest | , |
| CopyPaintedMinPathsTree | |||
| ) |
Definition at line 587 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::copy_painted_min_paths_tree(), GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), nodes, and Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::paint_min_paths_tree().
| TEST_F | ( | AStarDijkstraModeTest | , |
| FindMinPathMatchesDijkstra | |||
| ) |
Definition at line 521 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::find_min_path(), Aleph::Dijkstra_Min_Paths< GT, Distance, Itor, SA, HeapT >::find_min_path(), nodes, and Aleph::Path< GT >::size().
| TEST_F | ( | AStarDijkstraModeTest | , |
| GetDistanceAfterPainting | |||
| ) |
Definition at line 567 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::get_distance(), nodes, and Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::paint_min_paths_tree().
| TEST_F | ( | AStarDijkstraModeTest | , |
| OperatorTreeVersion | |||
| ) |
Definition at line 604 of file astar_test.cc.
References GraphCommon< GT, Node, Arc >::get_num_nodes(), and nodes.
| TEST_F | ( | AStarDijkstraModeTest | , |
| PaintMinPathsTreePaintsAll | |||
| ) |
Definition at line 501 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::get_min_path(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::get_start_node(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::has_computation(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::is_painted(), nodes, and Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::paint_min_paths_tree().
| TEST_F | ( | AStarDijkstraModeTest | , |
| PaintPartialMinPathsTree | |||
| ) |
Definition at line 551 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::get_min_path(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::is_painted(), nodes, and Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::paint_partial_min_paths_tree().
| TEST_F | ( | AStarDijkstraModeTest | , |
| StateGetters | |||
| ) |
Definition at line 673 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::get_graph(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::get_start_node(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::has_computation(), Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::is_painted(), nodes, and Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::paint_min_paths_tree().
| TEST_F | ( | AStarDijkstraModeTest | , |
| TreesMatchDijkstra | |||
| ) |
Definition at line 638 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::compute_min_paths_tree(), Aleph::Dijkstra_Min_Paths< GT, Distance, Itor, SA, HeapT >::compute_min_paths_tree(), GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), and nodes.
| TEST_F | ( | AStarGridTest | , |
| EuclideanHeuristicFindsShortest | |||
| ) |
Definition at line 314 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::find_path().
| TEST_F | ( | AStarGridTest | , |
| GoodHeuristicReducesExploration | |||
| ) |
Definition at line 345 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::find_path(), and Aleph::Path< GT >::is_empty().
| TEST_F | ( | AStarGridTest | , |
| ManhattanHeuristicFindsShortest | |||
| ) |
Definition at line 330 of file astar_test.cc.
References Aleph::AStar_Min_Path< GT, Distance, Heuristic, Itor, SA, HeapT >::find_path().
| TYPED_TEST | ( | AStarHeapTest | , |
| ComputeMinPathsTree | |||
| ) |
Definition at line 736 of file astar_test.cc.
References GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), nodes, and root().
| TYPED_TEST | ( | AStarHeapTest | , |
| FindPathWithHeuristic | |||
| ) |
Definition at line 720 of file astar_test.cc.
References Aleph::Path< GT >::is_empty(), and nodes.
| TYPED_TEST | ( | AStarHeapTest | , |
| MatchesDijkstra | |||
| ) |
Definition at line 771 of file astar_test.cc.
References Aleph::Dijkstra_Min_Paths< GT, Distance, Itor, SA, HeapT >::find_min_path(), nodes, and Aleph::Path< GT >::size().
| TYPED_TEST | ( | AStarHeapTest | , |
| PaintAndGetDistance | |||
| ) |
Definition at line 753 of file astar_test.cc.
References nodes.
| TYPED_TEST_SUITE | ( | AStarHeapTest | , |
| HeapTypes | |||
| ) |