Corrections
This commit is contained in:
parent
c0495eb381
commit
867a4a52b3
69
luku17.tex
69
luku17.tex
|
@ -188,14 +188,13 @@ in the following order:
|
||||||
\end{center}
|
\end{center}
|
||||||
|
|
||||||
The notation $x/y$ means that
|
The notation $x/y$ means that
|
||||||
processing the node started at moment $x$
|
processing the node started
|
||||||
and ended at moment $y$.
|
at time $x$ and finished at time $y$.
|
||||||
The following list contains the nodes
|
Thus, the corresponding list is as follows:
|
||||||
sorted according to their ending times:
|
|
||||||
|
|
||||||
\begin{tabular}{ll}
|
\begin{tabular}{ll}
|
||||||
\\
|
\\
|
||||||
node & ending time \\
|
node & processing time \\
|
||||||
\hline
|
\hline
|
||||||
4 & 5 \\
|
4 & 5 \\
|
||||||
5 & 6 \\
|
5 & 6 \\
|
||||||
|
@ -218,7 +217,7 @@ forms the strongly connected components
|
||||||
of the graph.
|
of the graph.
|
||||||
First, the algorithm reverses every
|
First, the algorithm reverses every
|
||||||
edge in the graph.
|
edge in the graph.
|
||||||
This makes sure that during the second search,
|
This guarantees that during the second search,
|
||||||
we will always find strongly connected
|
we will always find strongly connected
|
||||||
components that do not have extra nodes.
|
components that do not have extra nodes.
|
||||||
|
|
||||||
|
@ -287,7 +286,7 @@ begins at node 3:
|
||||||
\end{tikzpicture}
|
\end{tikzpicture}
|
||||||
\end{center}
|
\end{center}
|
||||||
|
|
||||||
Note that since all edges were reversed,
|
Note that since all edges are reversed,
|
||||||
the component does not ''leak'' to other parts in the graph.
|
the component does not ''leak'' to other parts in the graph.
|
||||||
|
|
||||||
\begin{samepage}
|
\begin{samepage}
|
||||||
|
@ -359,8 +358,7 @@ that create the remaining strongy connected components:
|
||||||
|
|
||||||
The time complexity of the algorithm is $O(n+m)$,
|
The time complexity of the algorithm is $O(n+m)$,
|
||||||
because the algorithm
|
because the algorithm
|
||||||
performs two depth-first searches and
|
performs two depth-first searches.
|
||||||
both searches take $O(n+m)$ time.
|
|
||||||
|
|
||||||
\section{2SAT problem}
|
\section{2SAT problem}
|
||||||
|
|
||||||
|
@ -390,8 +388,17 @@ L_1 = (x_2 \lor \lnot x_1) \land
|
||||||
(\lnot x_2 \lor \lnot x_3) \land
|
(\lnot x_2 \lor \lnot x_3) \land
|
||||||
(x_1 \lor x_4)
|
(x_1 \lor x_4)
|
||||||
\]
|
\]
|
||||||
is true when $x_1$ and $x_2$ are false
|
is true when the variables are assigned as follows:
|
||||||
and $x_3$ and $x_4$ are true.
|
|
||||||
|
\[
|
||||||
|
\begin{cases}
|
||||||
|
x_1 = \textrm{false} \\
|
||||||
|
x_2 = \textrm{false} \\
|
||||||
|
x_3 = \textrm{true} \\
|
||||||
|
x_4 = \textrm{true} \\
|
||||||
|
\end{cases}
|
||||||
|
\]
|
||||||
|
|
||||||
However, the formula
|
However, the formula
|
||||||
\[
|
\[
|
||||||
L_2 = (x_1 \lor x_2) \land
|
L_2 = (x_1 \lor x_2) \land
|
||||||
|
@ -400,14 +407,14 @@ L_2 = (x_1 \lor x_2) \land
|
||||||
(\lnot x_1 \lor \lnot x_3)
|
(\lnot x_1 \lor \lnot x_3)
|
||||||
\]
|
\]
|
||||||
is always false, regardless of how we
|
is always false, regardless of how we
|
||||||
choose the values of the variables.
|
assign the values.
|
||||||
The reason for this is that we cannot
|
The reason for this is that we cannot
|
||||||
choose a value for variable $x_1$
|
choose a value for $x_1$
|
||||||
without creating a contradiction.
|
without creating a contradiction.
|
||||||
If $x_1$ is false, both $x_2$ and $\lnot x_2$
|
If $x_1$ is false, both $x_2$ and $\lnot x_2$
|
||||||
should hold which is impossible,
|
should be true which is impossible,
|
||||||
and if $x_1$ is true, both $x_3$ and $\lnot x_3$
|
and if $x_1$ is true, both $x_3$ and $\lnot x_3$
|
||||||
should hold which is also impossible.
|
should be true which is also impossible.
|
||||||
|
|
||||||
The 2SAT problem can be represented as a graph
|
The 2SAT problem can be represented as a graph
|
||||||
whose nodes correspond to
|
whose nodes correspond to
|
||||||
|
@ -466,19 +473,21 @@ And the graph for the formula $L_2$ is:
|
||||||
\end{tikzpicture}
|
\end{tikzpicture}
|
||||||
\end{center}
|
\end{center}
|
||||||
|
|
||||||
The structure of the graph indicates whether
|
The structure of the graph tells us whether
|
||||||
the corresponding 2SAT problem can be solved.
|
it is possible to assign the values
|
||||||
If there is a variable $x_i$ such that
|
of the variables so
|
||||||
both $x_i$ and $\lnot x_i$ belong to the
|
that the formula is true.
|
||||||
same strongly connected component,
|
It turns out that this can be done
|
||||||
then there are no solutions.
|
exactly when there are no nodes
|
||||||
In this case, the graph contains
|
$x_i$ and $\lnot x_i$ such that
|
||||||
a path from $x_i$ to $\lnot x_i$,
|
both nodes belong to the
|
||||||
|
same strongly connected component.
|
||||||
|
If there are such nodes,
|
||||||
|
the graph contains
|
||||||
|
a path from $x_i$ to $\lnot x_i$
|
||||||
and also a path from $\lnot x_i$ to $x_i$,
|
and also a path from $\lnot x_i$ to $x_i$,
|
||||||
so both $x_i$ and $\lnot x_i$ should hold
|
so both $x_i$ and $\lnot x_i$ should be true
|
||||||
which is not possible.
|
which is not possible.
|
||||||
However, if the graph does not contain
|
|
||||||
such a variable $x_i$, then there is always a solution.
|
|
||||||
|
|
||||||
In the graph of the formula $L_1$
|
In the graph of the formula $L_1$
|
||||||
there are no nodes $x_i$ and $\lnot x_i$
|
there are no nodes $x_i$ and $\lnot x_i$
|
||||||
|
@ -490,7 +499,7 @@ all nodes belong to the same strongly connected component,
|
||||||
so there are no solutions.
|
so there are no solutions.
|
||||||
|
|
||||||
If a solution exists, the values for the variables
|
If a solution exists, the values for the variables
|
||||||
can be found by processing the nodes of the
|
can be found by going through the nodes of the
|
||||||
component graph in a reverse topological sort order.
|
component graph in a reverse topological sort order.
|
||||||
At each step, we process a component
|
At each step, we process a component
|
||||||
that does not contain edges that lead to an
|
that does not contain edges that lead to an
|
||||||
|
@ -502,7 +511,7 @@ according to the values in the component,
|
||||||
and if they already have values,
|
and if they already have values,
|
||||||
they remain unchanged.
|
they remain unchanged.
|
||||||
The process continues until all variables
|
The process continues until all variables
|
||||||
have been assigned a value.
|
have been assigned values.
|
||||||
|
|
||||||
The component graph for the formula $L_1$ is as follows:
|
The component graph for the formula $L_1$ is as follows:
|
||||||
\begin{center}
|
\begin{center}
|
||||||
|
@ -533,8 +542,8 @@ All variables have been assigned a value,
|
||||||
so the remaining components $A$ and $B$
|
so the remaining components $A$ and $B$
|
||||||
do not change the variables.
|
do not change the variables.
|
||||||
|
|
||||||
Note that this method, works because the
|
Note that this method works, because the
|
||||||
structure of the graph is special.
|
graph has a special structure.
|
||||||
If there are paths from node $x_i$ to node $x_j$
|
If there are paths from node $x_i$ to node $x_j$
|
||||||
and from node $x_j$ to node $\lnot x_j$,
|
and from node $x_j$ to node $\lnot x_j$,
|
||||||
then node $x_i$ never becomes true.
|
then node $x_i$ never becomes true.
|
||||||
|
|
Loading…
Reference in New Issue