cima_pdoutmat_2023-12-11.vrb
1.89 KB
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
\frametitle{An Example of Logic Programming}
%-------------------------------------------------------------
\begin{columns}[c]
\column{0.4\textwidth}
\begin{tikzpicture}[>=Latex]
\node[vert] (v6) {6};
\node[vert, above left = of v6] (v3) {3};
\node[vert, above right = of v6] (v5) {5};
\node[vert, below left = of v6] (v1) {1};
\node[vert, below right = of v6] (v2) {2};
\node[vert, below right = of v1] (v4) {4};
\draw[->] (v6) to (v3);
\draw[<->] (v6) to (v5);
\draw[<->] (v6) to (v2);
\draw[<->] (v3) to (v5);
\draw[<->] (v3) to (v1);
\draw[->] (v3) to[bend right, out=225, in =180,relative=false] (v4);
\draw[->] (v1) to (v2);
\draw[<->] (v1) to (v4);
\draw[->] (v2) to (v5);
\draw[<->] (v2) to (v4);
\draw[->] (v5) to[bend left, out=-45, in=0,relative=false] (v4);
\end{tikzpicture}
\column{0.6\textwidth}
\scriptsize
\begin{lstlisting}
node(1..6).
edge(1,2). edge(2,4). edge(3,1).
edge(4,1). edge(5,3). edge(6,2).
edge(1,3). edge(2,5). edge(3,4).
edge(4,2). edge(5,4). edge(6,3).
edge(1,4). edge(2,6). edge(3,5).
edge(5,6). edge(6,5).
col(r). col(b). col(g).
1 { color(X,C) : col(C) } 1 :- node(X).
:- edge(X,Y), color(X,C), color(Y,C).
#show color/2.
\end{lstlisting}
\end{columns}
\vfill
\scriptsize
\begin{lstlisting}
color(2,b) color(1,g) color(4,r) color(3,b) color(5,g) color(6,r)
color(1,r) color(2,b) color(4,g) color(3,b) color(5,r) color(6,g)
color(1,r) color(2,g) color(4,b) color(3,g) color(5,r) color(6,b)
color(1,b) color(2,g) color(4,r) color(3,g) color(5,b) color(6,r)
color(2,r) color(1,g) color(4,b) color(3,r) color(5,g) color(6,b)
color(2,r) color(1,b) color(4,g) color(3,r) color(5,b) color(6,g)
\end{lstlisting}