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.
Opts in
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
Opts in
collapse_bi(Cbi=false)
whether to collapse edges that connect 2 nodes in both directionscolour(colour/bnw)
graph colouredge_colour(black)
default edge colouredges_attrs([])
attributes for edgesgraph(GraphVal=_)
multiple are allowed.node_style(NdStyle=radial)
default node style radial/filled/empty)nodes_attrs([])
arbitrary node attributesnodes_colours(NdsClrs=[])
node coloursnodes_positions(NdsPos=[])
,
positions for nodesnodes_labels(NdsLbls=[])
optional labels for nodesnodes_dichromatic(Dichr=true)
values: true/false/default,white/Colour)title(false)
add an optional titletype(Type=digraph)
or graphbn_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)]) ] ).
date(Y,M,D)
.
?- disp_bn_version( V, D ). V = 0:1:0, D = date(2021, 1, 19).