#include <gtest/gtest.h>
#include <jlm/util/HashSet.hpp>
#include <jlm/util/TarjanScc.hpp>
#include <iostream>
#include <optional>
#include <tuple>
#include <vector>
Go to the source code of this file.
|
| static size_t | Identity (size_t i) |
| |
| template<typename UnificationRootFunctor , typename SuccessorFunctor > |
| static void | ValidateTopologicalOrderAndSccIndices (size_t numNodes, UnificationRootFunctor &unificationRoot, SuccessorFunctor &successors, size_t numSccs, const std::vector< size_t > &sccIndex, const std::vector< size_t > &reverseTopologicalOrder) |
| |
| | TEST (TarjanSccTests, TestDag) |
| |
| | TEST (TarjanSccTests, TestCycles) |
| |
| static std::tuple< size_t, size_t, std::vector< size_t > > | CreateDiamondChain (size_t knots, std::optional< std::pair< size_t, size_t >> extraEdge) |
| |
| | TEST (TarjanSccTests, TestSimpleDiamondChain) |
| |
| | TEST (TarjanSccTests, TestDiamondChainWithForwardEdge) |
| |
| | TEST (TarjanSccTests, TestDiamondChainWithBackEdge) |
| |
| | TEST (TarjanSccTests, TestVisitEachNodeTwice) |
| |
| | TEST (TarjanSccTests, TestUnifiedNodes) |
| |
◆ CreateDiamondChain()
| static std::tuple<size_t, size_t, std::vector<size_t> > CreateDiamondChain |
( |
size_t |
knots, |
|
|
std::optional< std::pair< size_t, size_t >> |
extraEdge |
|
) |
| |
|
static |
Creates a chain of diamonds, possibly with an extra edge. Performs SCC on the graph. The node indices are shuffled before being sent to the SCC algorithm.
- Parameters
-
| knots | The knots are the bottlenecks in the diamonds. All edges go that way ==> 1 4 etc. / \ / \ / 0 3 6 <- these are the knots \ / \ / \ 2 5 etc. |
| extraEdge | an optional extra edge going from first to second. If the extra edge is a forward edge (first < second), no cycles exist. If the extra edge is a back edge, there should be a single SCC with order > 1. |
- Returns
- a pair: the number of nodes, the number of SCCs, and the sccIndex of each node, after un-shuffling
Definition at line 195 of file TarjanSccTests.cpp.
◆ Identity()
| static size_t Identity |
( |
size_t |
i | ) |
|
|
static |
◆ TEST() [1/7]
| TEST |
( |
TarjanSccTests |
, |
|
|
TestCycles |
|
|
) |
| |
◆ TEST() [2/7]
| TEST |
( |
TarjanSccTests |
, |
|
|
TestDag |
|
|
) |
| |
◆ TEST() [3/7]
| TEST |
( |
TarjanSccTests |
, |
|
|
TestDiamondChainWithBackEdge |
|
|
) |
| |
◆ TEST() [4/7]
| TEST |
( |
TarjanSccTests |
, |
|
|
TestDiamondChainWithForwardEdge |
|
|
) |
| |
◆ TEST() [5/7]
| TEST |
( |
TarjanSccTests |
, |
|
|
TestSimpleDiamondChain |
|
|
) |
| |
◆ TEST() [6/7]
| TEST |
( |
TarjanSccTests |
, |
|
|
TestUnifiedNodes |
|
|
) |
| |
◆ TEST() [7/7]
| TEST |
( |
TarjanSccTests |
, |
|
|
TestVisitEachNodeTwice |
|
|
) |
| |
◆ ValidateTopologicalOrderAndSccIndices()
template<typename UnificationRootFunctor , typename SuccessorFunctor >
| static void ValidateTopologicalOrderAndSccIndices |
( |
size_t |
numNodes, |
|
|
UnificationRootFunctor & |
unificationRoot, |
|
|
SuccessorFunctor & |
successors, |
|
|
size_t |
numSccs, |
|
|
const std::vector< size_t > & |
sccIndex, |
|
|
const std::vector< size_t > & |
reverseTopologicalOrder |
|
) |
| |
|
static |
Validation function checking that the found SCCs correspond to the successors:
- All sccIndex are between 0 and numSccs-1
- All SCCs contain at least one node
- All edges in the graph point to an
sccIndex which is equal or lower
- The reverseTopologicalOrder contains all nodes, sorted by descending sccIndex
Definition at line 32 of file TarjanSccTests.cpp.