Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tpl_graph_test.cc File Reference

Exhaustive tests for tpl_graph.H (List_Graph, List_Digraph, Path) More...

#include <gtest/gtest.h>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <tpl_graph.H>
Include dependency graph for tpl_graph_test.cc:

Go to the source code of this file.

Classes

class  GraphBasicTest
 
class  GraphNodeRemovalTest
 
class  GraphArcRemovalTest
 
class  GraphIteratorTest
 
struct  EvenNodeFilter
 
struct  HighWeightArcFilter
 
class  GraphMoveTest
 
class  PathTest
 
class  DirectedPathTest
 
class  GraphExceptionTest
 
class  DigraphTest
 
class  GraphFunctionalTest
 
class  GraphStressTest
 

Typedefs

using Graph = List_Graph< Graph_Node< int >, Graph_Arc< double > >
 
using TestDigraph = List_Digraph< Graph_Node< int >, Graph_Arc< double > >
 
using StringGraph = List_Graph< Graph_Node< string >, Graph_Arc< string > >
 

Functions

 TEST (GraphNodeTest, DefaultConstruction)
 
 TEST (GraphNodeTest, ConstructionWithInfo)
 
 TEST (GraphNodeTest, CopyConstruction)
 
 TEST (GraphNodeTest, MoveConstruction)
 
 TEST (GraphNodeTest, CopyAssignment)
 
 TEST (GraphNodeTest, SelfAssignment)
 
 TEST (GraphNodeTest, ConstructionFromPointer)
 
 TEST (GraphArcTest, DefaultConstruction)
 
 TEST (GraphArcTest, ConstructionWithInfo)
 
 TEST (GraphArcTest, CopyConstruction)
 
 TEST (GraphArcTest, CopyAssignment)
 
 TEST (GraphArcTest, SelfAssignment)
 
 TEST_F (GraphBasicTest, DefaultConstructorCreatesEmptyGraph)
 
 TEST_F (GraphBasicTest, DefaultConstructorCreatesEmptyDigraph)
 
 TEST_F (GraphBasicTest, InsertSingleNode)
 
 TEST_F (GraphBasicTest, InsertMultipleNodes)
 
 TEST_F (GraphBasicTest, InsertArcBetweenTwoNodes)
 
 TEST_F (GraphBasicTest, InsertSelfLoop)
 
 TEST_F (GraphNodeRemovalTest, RemoveSingleNode)
 
 TEST_F (GraphNodeRemovalTest, RemoveNodeWithArcs)
 
 TEST_F (GraphNodeRemovalTest, RemoveAllNodes)
 
 TEST_F (GraphArcRemovalTest, RemoveSingleArc)
 
 TEST_F (GraphArcRemovalTest, RemoveAllArcs)
 
 TEST_F (GraphArcRemovalTest, DisconnectAndReconnectArc)
 
 TEST_F (GraphIteratorTest, NodeIteratorTraversesAllNodes)
 
 TEST_F (GraphIteratorTest, ArcIteratorTraversesAllArcs)
 
 TEST_F (GraphIteratorTest, NodeArcIteratorTraversesAdjacentArcs)
 
 TEST_F (GraphIteratorTest, IteratorResetFirst)
 
 TEST_F (GraphIteratorTest, IteratorResetLast)
 
 TEST_F (GraphIteratorTest, FilteredNodeIterator)
 
 TEST_F (GraphIteratorTest, FilteredArcIterator)
 
 TEST_F (GraphIteratorTest, SearchArcBetweenNodes)
 
 TEST_F (GraphIteratorTest, SearchArcNotFound)
 
 TEST_F (GraphIteratorTest, SearchDirectedArc)
 
 TEST_F (GraphMoveTest, MoveConstructor)
 
 TEST_F (GraphMoveTest, MoveAssignment)
 
 TEST_F (GraphMoveTest, SwapGraphs)
 
 TEST_F (GraphMoveTest, SelfAssignment)
 
 TEST_F (GraphMoveTest, CopyConstruction)
 
 TEST_F (GraphMoveTest, CopyAssignment)
 
 TEST_F (GraphMoveTest, CopyToNonEmptyGraph)
 
 TEST_F (PathTest, EmptyPathConstruction)
 
 TEST_F (PathTest, PathWithSingleNode)
 
 TEST_F (PathTest, AppendArcToPath)
 
 TEST_F (PathTest, AppendNodeToPath)
 
 TEST_F (PathTest, InsertArcToPath)
 
 TEST_F (PathTest, InsertNodeToPath)
 
 TEST_F (PathTest, BuildFullPath)
 
 TEST_F (PathTest, PathContainsNode)
 
 TEST_F (PathTest, PathContainsArc)
 
 TEST_F (PathTest, PathIterator)
 
 TEST_F (PathTest, PathNodesList)
 
 TEST_F (PathTest, PathArcsList)
 
 TEST_F (PathTest, PathCopyConstruction)
 
 TEST_F (PathTest, PathMoveConstruction)
 
 TEST_F (PathTest, RemoveLastNode)
 
 TEST_F (PathTest, RemoveFirstNode)
 
 TEST_F (PathTest, IsCycle)
 
 TEST_F (PathTest, IsNotCycle)
 
 TEST_F (DirectedPathTest, AppendDirectedNode)
 
 TEST_F (DirectedPathTest, AppendDirectedArc)
 
 TEST_F (DirectedPathTest, InsertDirectedNode)
 
 TEST_F (DirectedPathTest, InsertDirectedArc)
 
 TEST_F (GraphExceptionTest, GetFirstNodeOnEmptyGraphThrows)
 
 TEST_F (GraphExceptionTest, GetFirstArcOnEmptyGraphThrows)
 
 TEST_F (GraphExceptionTest, PathAppendOnEmptyPathThrows)
 
 TEST_F (GraphExceptionTest, PathAppendInvalidArcThrows)
 
 TEST_F (GraphExceptionTest, PathInsertOnEmptyPathThrows)
 
 TEST_F (DigraphTest, NodeDegrees)
 
 TEST_F (DigraphTest, TraverseArcsFromNode)
 
 TEST_F (DigraphTest, ArcDirection)
 
 TEST_F (GraphFunctionalTest, ForEachNode)
 
 TEST_F (GraphFunctionalTest, ForEachArc)
 
 TEST_F (GraphFunctionalTest, ForallNode)
 
 TEST_F (GraphFunctionalTest, ForallArc)
 
 TEST_F (GraphFunctionalTest, FoldlNodes)
 
 TEST_F (GraphFunctionalTest, FoldlArcs)
 
 TEST_F (GraphFunctionalTest, FindPathDepthFirst)
 
 TEST_F (GraphFunctionalTest, FindPathDepthFirstNotFound)
 
 TEST_F (GraphStressTest, InsertManyNodes)
 
 TEST_F (GraphStressTest, InsertManyArcs)
 
 TEST_F (GraphStressTest, InsertAndRemoveManyNodes)
 
 TEST_F (GraphFunctionalTest, SortNodes)
 
 TEST_F (GraphFunctionalTest, SortArcs)
 
 TEST_F (GraphFunctionalTest, ClearGraph)
 
 TEST (ConceptsTest, NodeIteratorSatisfiesConcept)
 
 TEST (ConceptsTest, ArcIteratorSatisfiesConcept)
 
 TEST (ConceptsTest, NodeArcIteratorSatisfiesConcept)
 
template<BasicGraphIterator It>
size_t count_elements (It it)
 
 TEST (ConceptsTest, ConceptConstrainedFunction)
 
int main (int argc, char **argv)
 

Detailed Description

Exhaustive tests for tpl_graph.H (List_Graph, List_Digraph, Path)

These tests cover all major operations including:

  • Node and arc insertion/removal
  • Iterators (Node_Iterator, Arc_Iterator, Node_Arc_Iterator)
  • Filtered iterators
  • Path class operations
  • Graph copy operations
  • Directed graph operations
  • Edge cases and error conditions

Definition in file tpl_graph_test.cc.

Typedef Documentation

◆ Graph

using Graph = List_Graph<Graph_Node<int>, Graph_Arc<double> >

Definition at line 62 of file tpl_graph_test.cc.

◆ StringGraph

using StringGraph = List_Graph<Graph_Node<string>, Graph_Arc<string> >

Definition at line 64 of file tpl_graph_test.cc.

◆ TestDigraph

using TestDigraph = List_Digraph<Graph_Node<int>, Graph_Arc<double> >

Definition at line 63 of file tpl_graph_test.cc.

Function Documentation

◆ count_elements()

template<BasicGraphIterator It>
size_t count_elements ( It  it)

Definition at line 1191 of file tpl_graph_test.cc.

References Aleph::count().

Referenced by TEST().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 1214 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST() [1/16]

◆ TEST() [2/16]

TEST ( ConceptsTest  ,
ConceptConstrainedFunction   
)

◆ TEST() [3/16]

◆ TEST() [4/16]

TEST ( ConceptsTest  ,
NodeIteratorSatisfiesConcept   
)

◆ TEST() [5/16]

TEST ( GraphArcTest  ,
ConstructionWithInfo   
)

Definition at line 129 of file tpl_graph_test.cc.

References GTArcCommon< ArcInfo >::get_info(), and Aleph::maps().

◆ TEST() [6/16]

TEST ( GraphArcTest  ,
CopyAssignment   
)

Definition at line 142 of file tpl_graph_test.cc.

References GTArcCommon< ArcInfo >::get_info(), and Aleph::maps().

◆ TEST() [7/16]

TEST ( GraphArcTest  ,
CopyConstruction   
)

Definition at line 135 of file tpl_graph_test.cc.

References GTArcCommon< ArcInfo >::get_info(), and Aleph::maps().

◆ TEST() [8/16]

TEST ( GraphArcTest  ,
DefaultConstruction   
)

Definition at line 123 of file tpl_graph_test.cc.

References GTArcCommon< ArcInfo >::get_info(), and Aleph::maps().

◆ TEST() [9/16]

TEST ( GraphArcTest  ,
SelfAssignment   
)

Definition at line 150 of file tpl_graph_test.cc.

References GTArcCommon< ArcInfo >::get_info(), and Aleph::maps().

◆ TEST() [10/16]

TEST ( GraphNodeTest  ,
ConstructionFromPointer   
)

Definition at line 112 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST() [11/16]

TEST ( GraphNodeTest  ,
ConstructionWithInfo   
)

Definition at line 77 of file tpl_graph_test.cc.

References GTNodeCommon< NodeInfo >::get_info(), and Aleph::maps().

◆ TEST() [12/16]

TEST ( GraphNodeTest  ,
CopyAssignment   
)

Definition at line 97 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST() [13/16]

TEST ( GraphNodeTest  ,
CopyConstruction   
)

Definition at line 83 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST() [14/16]

TEST ( GraphNodeTest  ,
DefaultConstruction   
)

◆ TEST() [15/16]

TEST ( GraphNodeTest  ,
MoveConstruction   
)

Definition at line 90 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST() [16/16]

TEST ( GraphNodeTest  ,
SelfAssignment   
)

Definition at line 105 of file tpl_graph_test.cc.

References GTNodeCommon< NodeInfo >::get_info(), and Aleph::maps().

◆ TEST_F() [1/73]

TEST_F ( DigraphTest  ,
ArcDirection   
)

Definition at line 917 of file tpl_graph_test.cc.

References arcs, Aleph::maps(), and nodes.

◆ TEST_F() [2/73]

TEST_F ( DigraphTest  ,
NodeDegrees   
)

Definition at line 891 of file tpl_graph_test.cc.

References Aleph::maps(), and nodes.

◆ TEST_F() [3/73]

TEST_F ( DigraphTest  ,
TraverseArcsFromNode   
)

Definition at line 908 of file tpl_graph_test.cc.

References Aleph::count(), Aleph::maps(), and nodes.

◆ TEST_F() [4/73]

◆ TEST_F() [5/73]

◆ TEST_F() [6/73]

◆ TEST_F() [7/73]

◆ TEST_F() [8/73]

TEST_F ( GraphArcRemovalTest  ,
DisconnectAndReconnectArc   
)

Definition at line 312 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [9/73]

TEST_F ( GraphArcRemovalTest  ,
RemoveAllArcs   
)

Definition at line 303 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [10/73]

TEST_F ( GraphArcRemovalTest  ,
RemoveSingleArc   
)

Definition at line 296 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [11/73]

TEST_F ( GraphBasicTest  ,
DefaultConstructorCreatesEmptyDigraph   
)

Definition at line 175 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [12/73]

TEST_F ( GraphBasicTest  ,
DefaultConstructorCreatesEmptyGraph   
)

Definition at line 168 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [13/73]

TEST_F ( GraphBasicTest  ,
InsertArcBetweenTwoNodes   
)

Definition at line 202 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [14/73]

TEST_F ( GraphBasicTest  ,
InsertMultipleNodes   
)

Definition at line 191 of file tpl_graph_test.cc.

References Aleph::maps(), and nodes.

◆ TEST_F() [15/73]

TEST_F ( GraphBasicTest  ,
InsertSelfLoop   
)

Definition at line 215 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [16/73]

TEST_F ( GraphBasicTest  ,
InsertSingleNode   
)

Definition at line 182 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [17/73]

TEST_F ( GraphExceptionTest  ,
GetFirstArcOnEmptyGraphThrows   
)

Definition at line 831 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [18/73]

TEST_F ( GraphExceptionTest  ,
GetFirstNodeOnEmptyGraphThrows   
)

Definition at line 826 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [19/73]

TEST_F ( GraphExceptionTest  ,
PathAppendInvalidArcThrows   
)

Definition at line 847 of file tpl_graph_test.cc.

References Aleph::Path< GT >::append(), and Aleph::maps().

◆ TEST_F() [20/73]

TEST_F ( GraphExceptionTest  ,
PathAppendOnEmptyPathThrows   
)

Definition at line 837 of file tpl_graph_test.cc.

References Aleph::Path< GT >::append(), and Aleph::maps().

◆ TEST_F() [21/73]

TEST_F ( GraphExceptionTest  ,
PathInsertOnEmptyPathThrows   
)

Definition at line 858 of file tpl_graph_test.cc.

References Aleph::Path< GT >::insert(), and Aleph::maps().

◆ TEST_F() [22/73]

TEST_F ( GraphFunctionalTest  ,
ClearGraph   
)

Definition at line 1112 of file tpl_graph_test.cc.

References Aleph::clear_graph(), and Aleph::maps().

◆ TEST_F() [23/73]

TEST_F ( GraphFunctionalTest  ,
FindPathDepthFirst   
)

Definition at line 996 of file tpl_graph_test.cc.

References Aleph::find_path_depth_first(), Aleph::maps(), and nodes.

◆ TEST_F() [24/73]

TEST_F ( GraphFunctionalTest  ,
FindPathDepthFirstNotFound   
)

Definition at line 1004 of file tpl_graph_test.cc.

References Aleph::find_path_depth_first(), and Aleph::maps().

◆ TEST_F() [25/73]

TEST_F ( GraphFunctionalTest  ,
FoldlArcs   
)

Definition at line 984 of file tpl_graph_test.cc.

References Aleph::maps(), and Aleph::sum().

◆ TEST_F() [26/73]

TEST_F ( GraphFunctionalTest  ,
FoldlNodes   
)

Definition at line 976 of file tpl_graph_test.cc.

References Aleph::maps(), and Aleph::sum().

◆ TEST_F() [27/73]

TEST_F ( GraphFunctionalTest  ,
ForallArc   
)

Definition at line 968 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [28/73]

TEST_F ( GraphFunctionalTest  ,
ForallNode   
)

Definition at line 960 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [29/73]

TEST_F ( GraphFunctionalTest  ,
ForEachArc   
)

Definition at line 953 of file tpl_graph_test.cc.

References Aleph::maps(), and Aleph::sum().

◆ TEST_F() [30/73]

TEST_F ( GraphFunctionalTest  ,
ForEachNode   
)

Definition at line 946 of file tpl_graph_test.cc.

References Aleph::maps(), and Aleph::sum().

◆ TEST_F() [31/73]

TEST_F ( GraphFunctionalTest  ,
SortArcs   
)

Definition at line 1090 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [32/73]

TEST_F ( GraphFunctionalTest  ,
SortNodes   
)

Definition at line 1072 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [33/73]

TEST_F ( GraphIteratorTest  ,
ArcIteratorTraversesAllArcs   
)

Definition at line 355 of file tpl_graph_test.cc.

References Aleph::count(), and Aleph::maps().

◆ TEST_F() [34/73]

TEST_F ( GraphIteratorTest  ,
FilteredArcIterator   
)

◆ TEST_F() [35/73]

TEST_F ( GraphIteratorTest  ,
FilteredNodeIterator   
)

◆ TEST_F() [36/73]

TEST_F ( GraphIteratorTest  ,
IteratorResetFirst   
)

Definition at line 373 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [37/73]

TEST_F ( GraphIteratorTest  ,
IteratorResetLast   
)

Definition at line 382 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [38/73]

TEST_F ( GraphIteratorTest  ,
NodeArcIteratorTraversesAdjacentArcs   
)

Definition at line 364 of file tpl_graph_test.cc.

References Aleph::count(), Aleph::maps(), and nodes.

◆ TEST_F() [39/73]

TEST_F ( GraphIteratorTest  ,
NodeIteratorTraversesAllNodes   
)

Definition at line 346 of file tpl_graph_test.cc.

References Aleph::count(), and Aleph::maps().

◆ TEST_F() [40/73]

TEST_F ( GraphIteratorTest  ,
SearchArcBetweenNodes   
)

Definition at line 431 of file tpl_graph_test.cc.

References Aleph::maps(), nodes, and Aleph::search_arc().

◆ TEST_F() [41/73]

TEST_F ( GraphIteratorTest  ,
SearchArcNotFound   
)

Definition at line 438 of file tpl_graph_test.cc.

References Aleph::maps(), nodes, and Aleph::search_arc().

◆ TEST_F() [42/73]

TEST_F ( GraphIteratorTest  ,
SearchDirectedArc   
)

Definition at line 444 of file tpl_graph_test.cc.

References Aleph::maps(), nodes, and Aleph::search_directed_arc().

◆ TEST_F() [43/73]

TEST_F ( GraphMoveTest  ,
CopyAssignment   
)

Definition at line 532 of file tpl_graph_test.cc.

References Aleph::copy(), and Aleph::maps().

◆ TEST_F() [44/73]

TEST_F ( GraphMoveTest  ,
CopyConstruction   
)

Definition at line 518 of file tpl_graph_test.cc.

References Aleph::copy(), and Aleph::maps().

◆ TEST_F() [45/73]

TEST_F ( GraphMoveTest  ,
CopyToNonEmptyGraph   
)

Definition at line 541 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [46/73]

TEST_F ( GraphMoveTest  ,
MoveAssignment   
)

Definition at line 481 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [47/73]

TEST_F ( GraphMoveTest  ,
MoveConstructor   
)

Definition at line 469 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [48/73]

TEST_F ( GraphMoveTest  ,
SelfAssignment   
)

Definition at line 507 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [49/73]

TEST_F ( GraphMoveTest  ,
SwapGraphs   
)

Definition at line 492 of file tpl_graph_test.cc.

References Aleph::maps(), and Aleph::DynList< T >::swap().

◆ TEST_F() [50/73]

TEST_F ( GraphNodeRemovalTest  ,
RemoveAllNodes   
)

Definition at line 265 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [51/73]

TEST_F ( GraphNodeRemovalTest  ,
RemoveNodeWithArcs   
)

Definition at line 249 of file tpl_graph_test.cc.

References Aleph::maps(), and nodes.

◆ TEST_F() [52/73]

TEST_F ( GraphNodeRemovalTest  ,
RemoveSingleNode   
)

Definition at line 242 of file tpl_graph_test.cc.

References Aleph::maps().

◆ TEST_F() [53/73]

TEST_F ( GraphStressTest  ,
InsertAndRemoveManyNodes   
)

Definition at line 1053 of file tpl_graph_test.cc.

References Aleph::maps(), and nodes.

◆ TEST_F() [54/73]

TEST_F ( GraphStressTest  ,
InsertManyArcs   
)

Definition at line 1034 of file tpl_graph_test.cc.

References Aleph::maps(), nodes, and rng.

◆ TEST_F() [55/73]

TEST_F ( GraphStressTest  ,
InsertManyNodes   
)

◆ TEST_F() [56/73]

◆ TEST_F() [57/73]

TEST_F ( PathTest  ,
AppendNodeToPath   
)

◆ TEST_F() [58/73]

◆ TEST_F() [59/73]

TEST_F ( PathTest  ,
EmptyPathConstruction   
)

◆ TEST_F() [60/73]

TEST_F ( PathTest  ,
InsertArcToPath   
)

◆ TEST_F() [61/73]

TEST_F ( PathTest  ,
InsertNodeToPath   
)

◆ TEST_F() [62/73]

TEST_F ( PathTest  ,
IsCycle   
)

◆ TEST_F() [63/73]

TEST_F ( PathTest  ,
IsNotCycle   
)

◆ TEST_F() [64/73]

TEST_F ( PathTest  ,
PathArcsList   
)

◆ TEST_F() [65/73]

TEST_F ( PathTest  ,
PathContainsArc   
)

◆ TEST_F() [66/73]

TEST_F ( PathTest  ,
PathContainsNode   
)

◆ TEST_F() [67/73]

TEST_F ( PathTest  ,
PathCopyConstruction   
)

◆ TEST_F() [68/73]

TEST_F ( PathTest  ,
PathIterator   
)

◆ TEST_F() [69/73]

TEST_F ( PathTest  ,
PathMoveConstruction   
)

◆ TEST_F() [70/73]

TEST_F ( PathTest  ,
PathNodesList   
)

◆ TEST_F() [71/73]

◆ TEST_F() [72/73]

TEST_F ( PathTest  ,
RemoveFirstNode   
)

◆ TEST_F() [73/73]

TEST_F ( PathTest  ,
RemoveLastNode   
)