summaryrefslogtreecommitdiff
path: root/src/prop/cryptominisat/Solver/SCCFinder.h
blob: c1d876e2ccb6f5bcf9b66fd8f09e3c8bcbbe8c7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*****************************************************************************
CryptoMiniSat -- Copyright (c) 2009 Mate Soos

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#ifndef SCCFINDER_H
#define SCCFINDER_H

#include "Vec.h"
#include "Clause.h"
#include "Solver.h"
#include <stack>

namespace CMSat {

class SCCFinder {
    public:
        SCCFinder(Solver& solver);
        bool find2LongXors();
        double getTotalTime() const;

    private:
        void tarjan(const uint32_t vertex);
        void doit(const Lit lit, const uint32_t vertex);

        uint32_t globalIndex;
        vector<uint32_t> index;
        vector<uint32_t> lowlink;
        std::stack<uint32_t> stack;
        vec<char> stackIndicator;
        vec<uint32_t> tmp;

        uint32_t recurDepth;

        Solver& solver;
        const vec<char>& varElimed1;
        const vec<char>& varElimed2;
        const vector<Lit>& replaceTable;
        double totalTime;
};

inline void SCCFinder::doit(const Lit lit, const uint32_t vertex) {
    // Was successor v' visited?
    if (index[lit.toInt()] ==  std::numeric_limits<uint32_t>::max()) {
        tarjan(lit.toInt());
        recurDepth--;
        lowlink[vertex] = std::min(lowlink[vertex], lowlink[lit.toInt()]);
    } else if (stackIndicator[lit.toInt()])  {
        lowlink[vertex] = std::min(lowlink[vertex], lowlink[lit.toInt()]);
    }
}

inline double SCCFinder::getTotalTime() const
{
    return totalTime;
}

}

#endif //SCCFINDER_H
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback