fixup! Implementation of Lengauer-Tarjan algorithm to find dominators

This commit is contained in:
Kamil Śliwak 2023-08-11 18:55:01 +02:00 committed by r0qs
parent 9aad3688dc
commit ffb53ad8a6
No known key found for this signature in database
GPG Key ID: 61503DBA6667276C
2 changed files with 5 additions and 5 deletions

View File

@ -95,7 +95,7 @@ public:
// @note for a vertex ``_v``, the _vs inclusion in the set of dominators of ``_v`` is implicit.
std::vector<Vertex> dominatorsOf(Vertex _v)
{
solAssert(m_vertex.size() > 0);
solAssert(!m_vertex.empty());
// The entry node always dominates all other nodes
std::vector<Vertex> dominators = std::vector<Vertex>{m_vertex[0]};
@ -112,8 +112,8 @@ public:
}
void buildDominatorTree() {
solAssert(m_vertex.size() > 0);
solAssert(m_immediateDominator.size() > 0);
solAssert(!m_vertex.empty());
solAssert(!m_immediateDominator.empty());
//Ignoring the entry node since no one dominates it.
for (size_t i = 1; i < m_immediateDominator.size(); ++i)

View File

@ -69,14 +69,14 @@ protected:
std::map<std::string, size_t> _expectedDFSIndices
)
{
soltestAssert(_edges.size() > 0);
soltestAssert(!_edges.empty());
ImmediateDominatorTest* test = new ImmediateDominatorTest();
for (std::string name: _vertices)
test->vertices.insert(make_pair(name, new Vertex{name, std::vector<Vertex*>{}}));
test->entry = test->vertices[_vertices[0]];
soltestAssert(_vertices.size() > 0 && _vertices.size() == test->vertices.size());
soltestAssert(!_vertices.empty() && _vertices.size() == test->vertices.size());
test->numVertices = _vertices.size();
for (auto const& [from, to]: _edges)