56 explicit operator int() {
return m_val; }
79 node pos = newNode(), neg = newNode();
82 m_assignment.push_back(
false);
84 m_node_map.push_back(pos);
86 m_node_map.push_back(neg);
92 return nodes.size() / 2;
96 auto [p1, n1] = getNodes(var1, !sign1);
97 auto [p2, n2] = getNodes(var2, !sign2);
98 edge e1 = newEdge(n1, p2);
99 edge e2 = newEdge(n2, p1);
107 return edges.size() / 2;
116 for (
auto it = nodes.begin(); it != nodes.end(); it++) {
123 if (components[pos] == components[neg]) {
126 m_assignment[pos->
index() / 2] = (components[pos] > components[neg]);
135 m_assignment.clear();
151 int idx = getNodeIndex(var,
true);
152 node pos = m_node_map[idx];
156 node neg = m_node_map[idx + 1];
159 return std::pair(neg, pos);
161 return std::pair(pos, neg);
166 int idx = getNodeIndex(var, sign);
167 node n = m_node_map[idx];
173 int idx = ((int)var) * 2 + (sign ? 0 : 1);
Includes declaration of graph class.
Decralation of GraphElement and GraphList classes.
Basic declarations, included by all source files.
Class for the representation of edges.
int index() const
Returns the index of the edge.
Data type for general directed graphs (adjacency list representation).
Class for the representation of nodes.
int index() const
Returns the (unique) node index.
A simple solver for TwoSAT instances, representing the instance as implication graph and solving it v...
bool getAssignment(twosat_var var) const
const_iterator end() const
const_iterator begin() const
const_reverse_iterator rend() const
node getNode(twosat_var var, bool sign) const
void clear() override
Removes all nodes and all edges from the graph.
typename std::vector< bool >::const_reverse_iterator const_reverse_iterator
int getNodeIndex(twosat_var var, bool sign) const
std::vector< bool > m_assignment
typename std::vector< bool >::const_iterator const_iterator
const_reverse_iterator rbegin() const
int variableCount() const
std::vector< node > m_node_map
int newClause(twosat_var var1, bool sign1, twosat_var var2, bool sign2)
std::pair< node, node > getNodes(twosat_var var, bool flip=false) const
RegisteredArray for nodes, edges and adjEntries of a graph.
In debug mode, twosat_var is a class instead of a simple int to prevent unintened use of the default ...
bool operator!=(const twosat_var &rhs) const
bool operator==(const twosat_var &rhs) const
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
int strongComponents(const Graph &G, NodeArray< int > &component)
Computes the strongly connected components of the digraph G.
#define OGDF_DEPRECATED(reason)
Mark a class / member / function as deprecated.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
The namespace for all OGDF objects.
const twosat_var TwoSAT_Var_Undefined(-1)
Declaration of simple graph algorithms.