Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions clingraph.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
% ----------------------------------------------------------------------
\begin{frame}[fragile,shrink=1]{Clingraph visualization}
%
\mbox{\texttt{\$ clingo coloring.lp --outf=2 |}}
\mbox{\texttt{\;\; clingraph --viz-encoding viz.lp --out tex --type digraph }}
\pause
\small
\begin{semiverbatim}

edge((X,Y)):- edge(X,Y), not edge(Y,X).
edge((X,Y)):- edge(X,Y), edge(Y,X), Y>X.
\pause
attr(edge,(X,Y),dir,both) :- edge(X,Y), edge(Y,X), Y>X.
attr(edge,(X,Y),color,"#fff49e"):- edge((X,Y)).
attr(node,X,color,"#fff49e") :- node(X).
\pause
color_name(r, "red"). color_name(b, "blue").
color_name(g, "green").
attr(node, N, style, filled) :- node(N).
attr(node, N, fillcolor, S) :- assign(N, C), color_name(C, S).
\end{semiverbatim}
\end{frame}
% ----------------------------------------------------------------------
%
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "../../main"
%%% End:
13 changes: 13 additions & 0 deletions encodings/clingraph-coloring.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
% Not so relevant, just for nicer layout
attr(graph,default, rankdir, "LR").
attr(graph,default, nodesep, "0.2").


edge((X,Y)):- edge(X,Y), not edge(Y,X).
edge((X,Y)):- edge(X,Y), edge(Y,X), Y>X.
attr(edge,(X,Y),dir,both):- edge(X,Y), edge(Y,X), Y>X.
attr(edge,(X,Y),color,"#fff49e"):- edge((X,Y)).
attr(node,X,color,"#fff49e"):- node(X).
attr(node, N, style, filled):- node(N).
color_name(r, "red"). color_name(b, "blue"). color_name(g, "green").
attr(node, N, fillcolor, NAME) :- assign(N, C), color_name(C, NAME).
12 changes: 12 additions & 0 deletions encodings/coloring-instance.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node(1..6).
edge(1,2). edge(1,3). edge(1,4).
edge(2,4). edge(2,5). edge(2,6).
edge(3,1). edge(3,4). edge(3,5).
edge(4,1). edge(4,2).
edge(5,3). edge(5,4). edge(5,6).
edge(6,2). edge(6,3). edge(6,5).
color(r). color(b). color(g).

assign(6,b). assign(5,r). assign(4,b). assign(3,g). assign(2,g). assign(1,r).
% { assign(N,C) : color(C) } = 1 :- node(N).
% :- edge(N,M), assign(N,C), assign(M,C).
124 changes: 97 additions & 27 deletions figures/fig-graph-colored.tex
Original file line number Diff line number Diff line change
@@ -1,28 +1,98 @@
% ----------------------------------------------------------------------
\begin{tikzpicture}[
x=1pt,y=1pt,
>=stealth',
vertex/.style={draw,minimum width=16,minimum height=16,inner sep=0,circle},
]
\begin{scope}[every node/.style={vertex}]
\node [fill=red] (1) at ( 80,75 ) {1};
\node [fill=green] (2) at (200,75 ) {2};
\node [fill=green] (3) at ( 80,145) {3};
\node [fill=blue] (4) at (140,25 ) {4};
\node [fill=red] (5) at (200,145) {5};
\node [fill=blue] (6) at (140,110) {6};
\end{scope}
\path[->]
(1) edge [->] (2) edge [<->] (3) edge [<->] (4)
(2) edge [<->] (4) edge [->] (5) edge [<->] (6)
(3) edge [->,bend right=60,looseness=1.5] (4) edge [<->] (5) edge [<-] (6)
(4) edge [<-,bend right=60,looseness=1.5] (5)
(5) edge [<->] (6)
;
\end{tikzpicture}
% ----------------------------------------------------------------------
\begin{tikzpicture}[>=latex',line join=bevel,scale=0.5]
\pgfsetlinewidth{1bp}
%%
\pgfsetcolor{black}
% Edge: 1 -> 2
\definecolor{newcol}{rgb}{1.0,0.96,0.62};
\pgfsetcolor{newcol}
\draw [->] (46.663bp,42.724bp) .. controls (58.68bp,50.918bp) and (74.522bp,61.719bp) .. (97.364bp,77.294bp);
% Edge: 1 -> 3
\draw [<->] (53.74bp,26.947bp) .. controls (122.23bp,20.836bp) and (234.61bp,16.19bp) .. (324.0bp,45.0bp) .. controls (336.97bp,49.182bp) and (349.88bp,56.8bp) .. (369.61bp,70.995bp);
% Edge: 1 -> 4
\draw [<->] (52.544bp,23.193bp) .. controls (99.066bp,11.677bp) and (155.95bp,0.0000bp) .. (206.0bp,0.0bp) .. controls (206.0bp,0.0bp) and (206.0bp,0.0bp) .. (298.0bp,0.0bp) .. controls (365.4bp,0.0bp) and (426.4bp,59.881bp) .. (463.69bp,103.82bp);
% Edge: 2 -> 4
\draw [<->] (132.76bp,104.91bp) .. controls (152.07bp,121.13bp) and (165.77bp,130.38bp) .. (180.0bp,135.0bp) .. controls (270.43bp,164.36bp) and (384.52bp,143.52bp) .. (451.84bp,126.91bp);
% Edge: 2 -> 5
\draw [->] (142.98bp,95.678bp) .. controls (151.34bp,97.578bp) and (160.84bp,99.736bp) .. (180.96bp,104.31bp);
% Edge: 2 -> 6
\draw [<->] (143.88bp,87.092bp) .. controls (185.26bp,82.442bp) and (228.15bp,77.624bp) .. (270.09bp,72.912bp);
% Edge: 3 -> 4
\draw [->] (410.66bp,94.013bp) .. controls (420.34bp,97.862bp) and (431.83bp,102.43bp) .. (453.11bp,110.9bp);
% Edge: 3 -> 5
\draw [<->] (360.39bp,89.316bp) .. controls (340.87bp,92.463bp) and (332.14bp,93.817bp) .. (324.0bp,95.0bp) .. controls (297.65bp,98.828bp) and (267.85bp,102.67bp) .. (233.83bp,106.89bp);
% Edge: 5 -> 4
\draw [->] (234.18bp,110.98bp) .. controls (281.92bp,112.76bp) and (383.23bp,116.54bp) .. (449.71bp,119.02bp);
% Edge: 5 -> 6
\draw [<->] (229.75bp,100.11bp) .. controls (247.85bp,91.888bp) and (256.06bp,88.153bp) .. (274.19bp,79.913bp);
% Edge: 6 -> 3
\draw [->] (323.45bp,74.339bp) .. controls (331.5bp,75.71bp) and (340.56bp,77.255bp) .. (360.3bp,80.619bp);
% Node: 1
\begin{scope}
\definecolor{strokecol}{rgb}{1.0,0.96,0.62};
\pgfsetstrokecolor{strokecol}
\definecolor{fillcol}{rgb}{1.0,0.0,0.0};
\pgfsetfillcolor{fillcol}
\filldraw [opacity=1] (27.0bp,30.0bp) ellipse (27.0bp and 18.0bp);
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (27.0bp,30.0bp) node {1};
\end{scope}
% Node: 2
\begin{scope}
\definecolor{strokecol}{rgb}{1.0,0.96,0.62};
\pgfsetstrokecolor{strokecol}
\definecolor{fillcol}{rgb}{0.0,1.0,0.0};
\pgfsetfillcolor{fillcol}
\filldraw [opacity=1] (117.0bp,90.0bp) ellipse (27.0bp and 18.0bp);
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (117.0bp,90.0bp) node {2};
\end{scope}
% Node: 3
\begin{scope}
\definecolor{strokecol}{rgb}{1.0,0.96,0.62};
\pgfsetstrokecolor{strokecol}
\definecolor{fillcol}{rgb}{0.0,1.0,0.0};
\pgfsetfillcolor{fillcol}
\filldraw [opacity=1] (387.0bp,85.0bp) ellipse (27.0bp and 18.0bp);
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (387.0bp,85.0bp) node {3};
\end{scope}
% Node: 4
\begin{scope}
\definecolor{strokecol}{rgb}{1.0,0.96,0.62};
\pgfsetstrokecolor{strokecol}
\definecolor{fillcol}{rgb}{0.0,0.0,1.0};
\pgfsetfillcolor{fillcol}
\filldraw [opacity=1] (477.0bp,120.0bp) ellipse (27.0bp and 18.0bp);
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (477.0bp,120.0bp) node {4};
\end{scope}
% Node: 5
\begin{scope}
\definecolor{strokecol}{rgb}{1.0,0.96,0.62};
\pgfsetstrokecolor{strokecol}
\definecolor{fillcol}{rgb}{1.0,0.0,0.0};
\pgfsetfillcolor{fillcol}
\filldraw [opacity=1] (207.0bp,110.0bp) ellipse (27.0bp and 18.0bp);
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (207.0bp,110.0bp) node {5};
\end{scope}
% Node: 6
\begin{scope}
\definecolor{strokecol}{rgb}{1.0,0.96,0.62};
\pgfsetstrokecolor{strokecol}
\definecolor{fillcol}{rgb}{0.0,0.0,1.0};
\pgfsetfillcolor{fillcol}
\filldraw [opacity=1] (297.0bp,70.0bp) ellipse (27.0bp and 18.0bp);
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (297.0bp,70.0bp) node {6};
\end{scope}
%
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "../../../main"
%%% End:
\end{tikzpicture}


111 changes: 84 additions & 27 deletions figures/fig-graph.tex
Original file line number Diff line number Diff line change
@@ -1,28 +1,85 @@
% ----------------------------------------------------------------------
\begin{tikzpicture}[
x=1pt,y=1pt,
>=stealth',
vertex/.style={draw,minimum width=16,minimum height=16,inner sep=0,circle},
]
\begin{scope}[every node/.style={vertex}]
\node (1) at ( 80,75 ) {1};
\node (2) at (200,75 ) {2};
\node (3) at ( 80,145) {3};
\node (4) at (140,25 ) {4};
\node (5) at (200,145) {5};
\node (6) at (140,110) {6};
\end{scope}
\path
(1) edge [->] (2) edge [<->] (3) edge [<->] (4)
(2) edge [<->] (4) edge [->] (5) edge [<->] (6)
(3) edge [->,bend right=60,looseness=1.5] (4) edge [<->] (5) edge [<-] (6)
(4) edge [<-,bend right=60,looseness=1.5] (5)
(5) edge [<->] (6)
;
\end{tikzpicture}
% ----------------------------------------------------------------------
\begin{tikzpicture}[>=latex',line join=bevel,scale=0.5]
\pgfsetlinewidth{1bp}
%%
\pgfsetcolor{black}
% Edge: 1 -> 3
\definecolor{newcol}{rgb}{1.0,0.96,0.62};
\pgfsetcolor{newcol}
\draw [<->] (54.403bp,99.193bp) .. controls (69.955bp,99.193bp) and (74.163bp,99.193bp) .. (89.616bp,99.193bp);
% Edge: 1 -> 4
\draw [<->] (49.184bp,110.09bp) .. controls (69.016bp,118.51bp) and (79.735bp,122.2bp) .. (90.0bp,124.19bp) .. controls (106.85bp,127.46bp) and (219.35bp,124.44bp) .. (234.0bp,122.19bp) .. controls (243.19bp,120.78bp) and (252.94bp,118.39bp) .. (272.77bp,112.49bp);
% Edge: 1 -> 2
\draw [->] (46.663bp,86.468bp) .. controls (58.68bp,78.275bp) and (74.522bp,67.473bp) .. (97.364bp,51.899bp);
% Edge: 3 -> 4
\draw [->] (143.2bp,104.7bp) .. controls (154.41bp,106.88bp) and (167.8bp,109.12bp) .. (180.0bp,110.19bp) .. controls (206.34bp,112.51bp) and (236.14bp,110.88bp) .. (270.16bp,107.59bp);
% Edge: 3 -> 5
\draw [<->] (134.97bp,85.696bp) .. controls (155.24bp,69.572bp) and (168.46bp,59.051bp) .. (188.78bp,42.887bp);
% Edge: 2 -> 4
\draw [<->] (141.27bp,47.69bp) .. controls (183.72bp,63.191bp) and (230.66bp,80.332bp) .. (272.72bp,95.693bp);
% Edge: 2 -> 5
\draw [->] (143.93bp,36.246bp) .. controls (151.65bp,35.369bp) and (160.26bp,34.39bp) .. (179.95bp,32.152bp);
% Edge: 2 -> 6
\draw [<->] (135.91bp,25.79bp) .. controls (155.85bp,13.422bp) and (167.99bp,7.3496bp) .. (180.0bp,4.1925bp) .. controls (203.21bp,-1.9069bp) and (210.44bp,-0.37878bp) .. (234.0bp,4.1925bp) .. controls (244.26bp,6.1841bp) and (254.98bp,9.8703bp) .. (274.82bp,18.293bp);
% Edge: 5 -> 4
\draw [->] (224.55bp,43.299bp) .. controls (237.58bp,54.404bp) and (255.96bp,70.064bp) .. (279.52bp,90.149bp);
% Edge: 5 -> 6
\draw [<->] (234.4bp,29.193bp) .. controls (249.95bp,29.193bp) and (254.16bp,29.193bp) .. (269.62bp,29.193bp);
% Edge: 6 -> 3
\draw [->] (273.35bp,38.407bp) .. controls (261.62bp,43.159bp) and (247.06bp,49.027bp) .. (234.0bp,54.193bp) .. controls (206.21bp,65.186bp) and (174.57bp,77.441bp) .. (140.71bp,90.486bp);
% Node: 1
\begin{scope}
\definecolor{strokecol}{rgb}{1.0,0.96,0.62};
\pgfsetstrokecolor{strokecol}
\draw (27.0bp,99.19bp) ellipse (27.0bp and 18.0bp);
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (27.0bp,99.193bp) node {1};
\end{scope}
% Node: 3
\begin{scope}
\definecolor{strokecol}{rgb}{1.0,0.96,0.62};
\pgfsetstrokecolor{strokecol}
\draw (117.0bp,99.19bp) ellipse (27.0bp and 18.0bp);
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (117.0bp,99.193bp) node {3};
\end{scope}
% Node: 4
\begin{scope}
\definecolor{strokecol}{rgb}{1.0,0.96,0.62};
\pgfsetstrokecolor{strokecol}
\draw (297.0bp,104.19bp) ellipse (27.0bp and 18.0bp);
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (297.0bp,104.19bp) node {4};
\end{scope}
% Node: 2
\begin{scope}
\definecolor{strokecol}{rgb}{1.0,0.96,0.62};
\pgfsetstrokecolor{strokecol}
\draw (117.0bp,39.19bp) ellipse (27.0bp and 18.0bp);
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (117.0bp,39.193bp) node {2};
\end{scope}
% Node: 5
\begin{scope}
\definecolor{strokecol}{rgb}{1.0,0.96,0.62};
\pgfsetstrokecolor{strokecol}
\draw (207.0bp,29.19bp) ellipse (27.0bp and 18.0bp);
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (207.0bp,29.193bp) node {5};
\end{scope}
% Node: 6
\begin{scope}
\definecolor{strokecol}{rgb}{1.0,0.96,0.62};
\pgfsetstrokecolor{strokecol}
\draw (297.0bp,29.19bp) ellipse (27.0bp and 18.0bp);
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (297.0bp,29.193bp) node {6};
\end{scope}
%
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "../../../main"
%%% End:
\end{tikzpicture}
% End of code
3 changes: 3 additions & 0 deletions workflow-example-coloring.tex
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@
% ----------------------------------------------------------------------
\input{modeling/workflow-solution}
% ----------------------------------------------------------------------
% ----------------------------------------------------------------------
\input{modeling/clingraph}
% ----------------------------------------------------------------------
%
%%% Local Variables:
%%% mode: latex
Expand Down