11 #include <gtest/gtest.h>
13 #include <framework/logging/Logger.h>
15 #include <tracking/trackFindingVXD/segmentNetwork/DirectedNode.h>
16 #include <tracking/trackFindingVXD/segmentNetwork/DirectedNodeNetworkContainer.h>
17 #include <tracking/trackFindingVXD/segmentNetwork/CACell.h>
18 #include <tracking/trackFindingVXD/algorithms/CellularAutomaton.h>
19 #include <tracking/trackFindingVXD/algorithms/CAValidator.h>
20 #include <tracking/trackFindingVXD/algorithms/PathCollectorRecursive.h>
21 #include <tracking/trackFindingVXD/algorithms/NodeCompatibilityCheckerPathCollector.h>
47 std::array<int, 5> intArray = { { 2, 5, 3, 4, 99} };
48 std::array<int, 5> intArray2 = { { 144, 121, 33, 35, 31415} };
49 std::array<int, 5> intArray3 = { { 1440, 1210, 3, 33, 3141529} };
50 std::vector<int> onTheFlyCreatedInts;
51 onTheFlyCreatedInts.reserve(4);
55 EXPECT_EQ(0, intNetwork.
size());
58 for (
unsigned int index = 1 ; index < 5; index++) {
60 intNetwork.
addNode(intArray.at(index - 1), intArray.at(index - 1));
61 intNetwork.
addNode(intArray.at(index), intArray.at(index));
63 intNetwork.
linkNodes(intArray.at(index - 1), intArray.at(index));
66 for (
unsigned int index = 1 ; index < 5; index++) {
67 intNetwork.
addNode(intArray2.at(index - 1), intArray2.at(index - 1));
68 intNetwork.
addNode(intArray2.at(index), intArray2.at(index));
70 intNetwork.
linkNodes(intArray2.at(index - 1), intArray2.at(index));
73 for (
unsigned int index = 1 ; index < 5; index++) {
74 intNetwork.
addNode(intArray3.at(index - 1), intArray3.at(index - 1));
75 intNetwork.
addNode(intArray3.at(index), intArray3.at(index));
77 intNetwork.
linkNodes(intArray3.at(index - 1), intArray3.at(index));
82 onTheFlyCreatedInts.push_back(42);
83 int& newInnerInt = onTheFlyCreatedInts.back();
84 intNetwork.
addNode(newInnerInt, newInnerInt);
85 intNetwork.
linkNodes(newInnerInt, oldOuterInt);
89 onTheFlyCreatedInts.push_back(23);
90 int& newOuterInt = onTheFlyCreatedInts.back();
91 int& existingInt = intArray.at(1);
92 intNetwork.
addNode(newOuterInt, newOuterInt);
93 intNetwork.
linkNodes(newOuterInt, existingInt);
96 intNetwork.
linkNodes(intArray.at(0), intArray.at(2));
100 onTheFlyCreatedInts.push_back(31);
101 int& newInnerInt = onTheFlyCreatedInts.back();
102 intNetwork.
addNode(newInnerInt, newInnerInt);
109 onTheFlyCreatedInts.push_back(66);
110 int& newOuterInt = onTheFlyCreatedInts.back();
111 intNetwork.
addNode(newOuterInt, newOuterInt);
115 EXPECT_EQ(17, intNetwork.
size());
123 int nRounds = cellularAutomaton.
apply(intNetwork);
124 unsigned int nSeeds = cellularAutomaton.
findSeeds(intNetwork);
127 EXPECT_EQ(13, nSeeds);
132 std::vector<DirectedNode<int, CACell>*>,
137 PathCollectorType pathCollector;
139 std::vector< PathCollectorType::Path> paths;
140 pathCollector.findPaths(intNetwork, paths, 100000000);
142 std::string out = PathCollectorType::printPaths(paths);
147 EXPECT_EQ(13, paths.size());
148 unsigned int longestPath = 0;
149 for (
auto& aPath : paths) {
150 if (longestPath < aPath.size()) {
151 longestPath = aPath.size();
155 EXPECT_EQ(7, longestPath);
156 EXPECT_EQ(nRounds, longestPath +
161 bool test = pathCollector.findPaths(intNetwork, paths, 50,
true);
162 EXPECT_EQ(44, paths.size());
163 EXPECT_EQ(
true, test);
167 test = pathCollector.findPaths(intNetwork, paths, 10);
168 EXPECT_EQ(
false, test);
The CellularAutomaton class This class serves as a functor for the algorithm itself.
int apply(ContainerType &aNetworkContainer) override final
actual algorithm of Cellular Automaton, returns number of rounds needed to finish or -1 if CA was abo...
unsigned int findSeeds(ContainerType &aNetworkContainer, bool strictSeeding=false) override final
checks network given for seeds, returns number of seeds found (if strictSeeding is set to true,...
Network of directed nodes of the type EntryType.
bool addInnerToLastOuterNode(NodeID innerNodeID)
to the last outerNode added, another innerNode will be attached
unsigned int size() const
Returns number of nodes to be found in the network.
bool linkNodes(NodeID outerNodeID, NodeID innerNodeID)
takes two entry IDs and weaves them into the network
bool addNode(NodeID nodeID, EntryType &newEntry)
************************* PUBLIC MEMBER FUNCTIONS *************************
bool addOuterToLastInnerNode(NodeID outerNodeID)
to the last innerNode added, another outerNode will be attached
Path finder for generic ContainerType.
Test class demonstrating the behavior of The Cellular Automaton and the PathCollectorRecursive.
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
Abstract base class for different kinds of events.
These tests cover the functionality of the classes: DirectedNode, DirectedNodeNetwork.
validation tool for CA algorithm
simple NodeCompatibilityChecker, which checks for compatible Neighboring states of passed nodes (does...