disp_bn.pl -- Construct and display BN terms via graphviz

Construct and display graphs via graphviz. Originallly for Bayesian networks (thus the name) but can deal with all graph types supported via graphviz.

The dot executable from the graphviz distributions should be in your $PATH environment variable.

Only tested on Linux systems.

author
- nicos angelopoulos
version
- 0.1 2021/01/19
See also
- http://stoics.org.uk/~nicos/sware/contact.html
 disp_bn(+Bn)
 disp_bn(+Bn, +Opts)
Construct a dot file for graph BN and display it on a number of output devices. Unused options are passed to bn_to_dot_dag/3.

Opts in

dot_file(Dot)
dot file to use. Default is constructed by mktemp_in_dir/3.
rmv(Rmv)
whether to remove dot file before exiting. Default is false if no dot_file/1 was given and true otherwise.
output(Dev)
device to use for output. Should be x11 or something that will work with dot -T<Dev>.
output_stem(Stem)
the stem of the file on which dot will write its output. Defaults to the stem of Dot (option dot_file/1 above).
disp_bn( [1-[2,3], 2-[3,4],3-[4], 4-[]] ).
disp_bn( [1-[2,3], 2-[3,4],3-[4], 4-[]], [edges_attrs([2-1-color(blue)]) ] ).
disp_bn( [1-[2,3], 2-[3,4],3-[4], 4-[]], [edges_attrs([2-1-[color(red),penwidth(4)]])] ).
disp_bn( [1-[2,3], 2-[3,4],3-[4], 4-[]], [edges_attrs([2-1-[color(red),penwidth(4)]]), nodes_attrs(3-shape(egg))] ).
disp_bn( [1-[2,3], 2-[3,4],3-[4], 4-[]], [edges_attrs([2-1-[color(red),penwidth(4)]]), nodes_attrs(3-[shape(box),style(rounded)])] ).
disp_bn( [1-[2,3], 2-[3,4],3-[4], 4-[]], [edges_attrs([2-1-[color(red),penwidth(4)]]), nodes_attrs(3-[shape(box),style('rounded,filled'),fillcolor(yellow)])] ).

disp_bn( [1-[2,3], 2-[3,4],3-[4], 4-[]], [output(x11),edges_attrs([2-1-[color(red),penwidth(4)]]), nodes_attrs(3-[shape(box),style('radial,rounded'),fillcolor('white:darkorange')])] ).

style="radial",color="white:darkorange"


disp_bn( [1-[],2-[1],3-[2,5],4-[],5-[4],6-[4],7-[3],8-[3,6]] ).
disp_bn( [1-[],2-[1,4],3-[1],4-[1],5-[],6-[],7-[1,2,3,4,5,6],8-[2]], [1-[],2-[1],3-[2,5],4-[],5-[4],6-[4],7-[3],8-[3,6]] ).
% red edges (ok) yellow edges (new) magenta (missing)
disp_bn( [1-[],2-[1],3-[2,5],4-[],5-[4],6-[4],7-[3],8-[3,6]], [1-[],2-[1],3-[5],4-[],5-[4],6-[4],7-[5],8-[3,6]] ). % the best learned...
disp_bn( [1-[],2-[1],3-[2,5],4-[],5-[4],6-[4],7-[3],8-[3,6]], [1-[],2-[1],3-[5],4-[],5-[4],6-[4],7-[5],8-[3,6]], [node_style(empty)] ). % as above with non-filled style nodes
disp_dag /usr/nicos/islp/bn_lbl_kernel/slp/disp/asia.dot
 
disp_bn( [1-[2],3-[4,5]] ).

?-
   Opts1 = [ output(x11),colour(bnw),type(graph),graph(bgcolor("#D3D3D3")),
           node_shape(box),rmv(false),node_style(rounded),
           nodes_dichromatic(false,false) ] ),
   assert( bn1([1-[2],3-[4,5]]) ), assert( opts1(Opts1) ).

?- opts1(Opts), bn1(Bn1), disp_bn(Bn1,Opts).

?- Eats = edges_attrs([1-2-color(red)])

Other background colours (latexcolor.com) graph(bgcolor("#B2BEB5")), % Ash grey graph(bgcolor("#91A3B0")), % Cadet gray graph(bgcolor("#A3C1AD")), % Cambridge Blue graph(bgcolor("#8C92AC")), % Cool gray graph(bgcolor("#A9A9A9")), % Dark gray graph(bgcolor("#BEBEBE")), % Gray (X11 gray)Gray (X11 gray) graph(bgcolor("#C4C3D0")), % Lavender gray

author
- nicos angelopoulos
version
- 0.2 2014/03/13
 bn_to_dot_dag(+Bn, +File, +Opts)
Render the graph Bn onto a graphviz dot File.

Opts in

bn_to_dot_dag([1-[],2-[1],3-[2]],[output(x11),edges_attrs(2-3-penwidth(2))] ).

bn_to_dot_dag( [1-[],2-[1],3-[2,5],4-[],5-[4],6-[4],7-[3],8-[3,6]], naku ).
bn_to_dot_dag( [1-[],2-[1],3-[1]], three, [nodes_positions([1-pos(10,10),2-pos(20,20),3-pos(30,30)]) ] ).
author
- nicos angelopoulos
version
- 0.1 2014/03/13
- 0.2 2014/04/27
To be done
- use label="Network Diagram"; for title (name it main to keep the old way ?
- when Colour=bnw default nodes_dichromatic should be false ?
 disp_bn_version(-Vers, -Date)
Version Mj:Mn:Fx, and release date date(Y,M,D).
?- disp_bn_version( V, D ).
V = 0:1:0,
D = date(2021, 1, 19).
author
- Nicos Angelopoulos
version
- 0:1 2021/1/19
See also
- http://stoics.org.uk/~nicos/sware/packs/disp_bn