Commit 24a0149e authored by Lucas Bourneuf's avatar Lucas Bourneuf

more examples

parent a4177a6c
% To use with something like:
% python -m biseau examples/path-to-gif.lp -o out/out.gif
% More complex example of path-to-gif.lp.
% Graph.
link(a,(b;c;d)).
link(b,e;c,f;d,g).
link((b;f),h).
link((f;g),i).
link((h;i),j).
start(a).
nb_link(N):- N={link(_,_)}.
% Choose a target, and use a color depending on it.
target(j)|target(h).
color(green):- target(j).
color(blue):- target(h).
% Initial state.
place(1,N) :- start(N).
% Choose a path.
1 { place(I+1,N): link(T,N) } 1 :- place(I,T) ; not target(T) ; I<Nlink ; nb_link(Nlink).
% Discards paths not terminating at target, and looping paths.
:- not place(_,T) ; target(T).
:- place(I,N) ; place(J,N) ; I!=J.
% Colorize the nodes on the path.
color(N,C) :- place(_,N) ; color(C).
% Highlight the path: make edges red and directed.
color(A,B,red) :- link(A,B) ; place(_,A) ; place(_,B).
dot_property(A,B,arrowhead,normal) :- link(A,B) ; place(_,A) ; place(_,B).
dot_property(A,B,penwidth,5) :- link(A,B) ; place(_,A) ; place(_,B).
......@@ -20,8 +20,9 @@ place(1,N) :- start(N).
:- not place(_,T) ; target(T).
:- place(I,N) ; place(J,N) ; I!=J.
% Colorize the path.
% Colorize the nodes on the path.
color(N,green) :- place(_,N).
% Highlight the path: make edges red and directed.
color(A,B,red) :- link(A,B) ; place(_,A) ; place(_,B).
dot_property(A,B,arrowhead,normal) :- link(A,B) ; place(_,A) ; place(_,B).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment