A tool to navigate the achivement in the source tree

Reading time: 531 minutes and 1 second with 116826 words. 本文总阅读量

We go to github, then download the souce code, go on looking into the code, dame it! So many codes ,so many branches, how to figure out the develop process?

Maybe you can use the sourceTree to help you visulize the source tree, or the right below tool for helping navigating the source tree in the time and compare with each other continually.

1. 比较目录

color block languages for modify,maybe you need sometimes in your blogs writing life.

2. 文件细节

1: 正在比较变动前 6ced089 和变动后 3d8b517

[back to content](#compare) ``` diff diff --git a/.gitmodules b/.gitmodules index f1b9cf5..a63cbff 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "Prolog-Library-Collection"] path = Prolog-Library-Collection url = https://github.com/wouterbeek/Prolog-Library-Collection.git +[submodule "plHtml"] + path = plHtml + url = https://github.com/wouterbeek/plHtml.git diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 4a51c6e..184c33e 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 4a51c6e0936179bff57fda23686219e6a6cd3c9b +Subproject commit 184c33eecf561c109919a7f765de0b1e53d99d00 diff --git a/plHtml b/plHtml new file mode 160000 index 0000000..2c45ebc --- /dev/null +++ b/plHtml @@ -0,0 +1 @@ +Subproject commit 2c45ebcd3f946c1e207a69ece1e2d730d4d090ed ```

2: 正在比较变动前 3d8b517 和变动后 ccd942c

[back to content](#compare) ``` diff diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 184c33e..03d4b46 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 184c33eecf561c109919a7f765de0b1e53d99d00 +Subproject commit 03d4b46ba9c6f658828ff843e5785c221ffc3a57 diff --git a/plHtml b/plHtml index 2c45ebc..50743da 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit 2c45ebcd3f946c1e207a69ece1e2d730d4d090ed +Subproject commit 50743daad8dd0f3664e1cafbc14523a423314f84 ```

3: 正在比较变动前 ccd942c 和变动后 0b3607d

[back to content](#compare) ``` diff diff --git a/gv_attr_type.pl b/gv_attr_type.pl index c62d146..200c034 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -41,7 +41,7 @@ ] ). :- reexport( - gv(gv_color), + plGraphViz(gv_color), [ color//1, % +Color:compound colorList//1 % +ColorList:list(compound) diff --git a/gv_attrs.pl b/gv_attrs.pl index 81d51df..728640e 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -68,7 +68,7 @@ check_minimum(V, Min1):- gv_attrs_download:- gv_attrs_url(Url), - download_html(Url, Dom, [html_dialect(html4)]), + download_html(Url, Dom, [html_dialect(html4),verbose(silent)]), xpath(Dom, //table(@align=center), TableDom), % @tbd This does not work, since in `record_name(Element, Name)`, diff --git a/gv_color.pl b/gv_color.pl index fd22d35..ad18728 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -81,7 +81,7 @@ gv_color_url('http://www.graphviz.org/doc/info/colors.html'). gv_color_download:- gv_color_url(Url), - download_html(Url, Dom, [html_dialect(html4)]), + download_html(Url, Dom, [html_dialect(html4),verbose(silent)]), xpath(Dom, //table(1), TableDom1), xpath(Dom, //table(2), TableDom2), maplist(assert_color_table, [x11,svg], [TableDom1,TableDom2]). ```

4: 正在比较变动前 0b3607d 和变动后 acf4ec3

[back to content](#compare) ``` diff diff --git a/gv_attrs.pl b/gv_attrs.pl index 728640e..b360039 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -14,16 +14,21 @@ */ :- use_module(library(apply)). +:- use_module(library(persistency)). :- use_module(library(xpath)). :- use_module(dcg(dcg_content)). :- use_module(dcg(dcg_generic)). +:- use_module(generics(db_ext)). +:- use_module(os(file_ext)). :- use_module(plHtml(html)). :- use_module(plHtml(html_table)). :- use_module(plGraphViz(gv_attr_type)). % DCGs implementing attribute types. +:- db_add_novel(user:prolog_file_type(log, logging)). + %! gv_attr( %! ?Name:atom, %! ?UsedBy:list(oneof([cluster,edge,graph,node,subgraph])), @@ -33,9 +38,18 @@ %! ?Notes:atom %! ) is nondet. -:- dynamic(gv_attr/6). +:- persistent( + gv_attr( + name:atom, + used_by:list(oneof([cluster,edge,graph,node,subgraph])), + types:list(atom), + default, + minimum, + notes:atom + ) +). -:- initialization(gv_attrs_download). +:- initialization(gv_attrs_init). @@ -64,7 +78,20 @@ check_minimum(V, Min1):- -% Download attributes from graphviz.org +% INITIALIZATION + +%! assert_gv_attr_row(+Row:list(atom)) is det. + +assert_gv_attr_row([Name,UsedBy1,Types1,Default1,Minimum,Notes]):- + dcg_phrase(translate_usedby(UsedBy2), UsedBy1), + once(dcg_phrase(translate_type(Types2), Types1)), + sort(UsedBy2, UsedBy3), + translate_default(Default1, Default2), + assert_gv_attr(Name, UsedBy3, Types2, Default2, Minimum, Notes). + + +%! gv_attrs_downloads is det. +% Downloads the table describing GraphViz attributes from `graphviz.org`. gv_attrs_download:- gv_attrs_url(Url), @@ -76,16 +103,56 @@ gv_attrs_download:- %%%%xpath(Dom, /html/body/table, TableDom), html_to_table(TableDom, _, Rows), - maplist(assert_gv_attr, Rows). + maplist(assert_gv_attr_row, Rows). + + +%! gv_attrs_file(-File:atom) is det. + +gv_attrs_file(File):- + absolute_file_name( + data(gv_attrs), + File, + [access(write),file_type(logging)] + ). + + +%! gv_attrs_init is det. + +gv_attrs_init:- + gv_attrs_file(File), + safe_db_attach(File), + file_age(File, Age), + gv_attrs_update(Age). + + +%! gv_attrs_update(+Age:float) is det. + +% The persistent store is still fresh. +gv_attrs_update(Age):- + once(gv_attr(_, _, _, _, _, _)), + Age < 3600, !. +% The persistent store has become stale, so refresh it. +gv_attrs_update(_):- + retractall_gv_attr(_, _, _, _, _, _), + gv_attrs_download. + + +%! gv_attrs_url(-Url:url) is det. gv_attrs_url('http://www.graphviz.org/doc/info/attrs.html'). -assert_gv_attr([Name,UsedBy1,Types1,Default1,Minimum,Notes]):- - dcg_phrase(translate_usedby(UsedBy2), UsedBy1), - once(dcg_phrase(translate_type(Types2), Types1)), - sort(UsedBy2, UsedBy3), - translate_default(Default1, Default2), - assert(gv_attr(Name, UsedBy3, Types2, Default2, Minimum, Notes)). + +%! safe_db_attach(+File:atom) is det. + +safe_db_attach(File):- + exists_file(File), !, + db_attach(File, []). +safe_db_attach(File):- + touch_file(File), + safe_db_attach(File). + + +%! translate_default(+Default1:atom, -Default2:atom) is det. % The empty string is represented by the empty atom. translate_default('""', ''):- !. @@ -93,12 +160,20 @@ translate_default('""', ''):- !. translate_default('', _):- !. translate_default(Default, Default). + +%! translate_type(-Types:list(atom))// is det. + translate_type([H|T]) --> {gv_attr_type(H)}, atom(H), whites, translate_type(T). -translate_type([]) --> []. +translate_type([]) --> !, []. + + +%! translated_usedby( +%! -UsedBy:list(oneof([cluster,edge,graph,node,subgraph])) +%! )// is det. translate_usedby([cluster|T]) --> `C`, !, translate_usedby(T). translate_usedby([edge|T]) --> `E`, !, translate_usedby(T). diff --git a/gv_color.pl b/gv_color.pl index ad18728..cf92f56 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -18,20 +18,25 @@ :- use_module(library(apply)). :- use_module(library(lists)). +:- use_module(library(persistency)). :- use_module(library(xpath)). :- use_module(dcg(dcg_abnf)). :- use_module(dcg(dcg_cardinal)). +:- use_module(generics(db_ext)). +:- use_module(os(file_ext)). :- use_module(sparql(sparql_char)). :- use_module(plHtml(html)). :- use_module(plHtml(html_table)). +:- db_add_novel(user:prolog_file_type(log, logging)). + %! gv_color(?Colorscheme:oneof([svg,x11]), ?Color:atom) is nondet. -:- dynamic(gv_color/2). +:- persistent(gv_color(colorscheme:oneof([svg,x11]),color:atom)). -:- initialization(gv_color_download). +:- initialization(gv_color_init). @@ -75,9 +80,9 @@ wc_weight(Float) --> -% Initialization. +% INITIALIZATION -gv_color_url('http://www.graphviz.org/doc/info/colors.html'). +%! gv_color_download is det. gv_color_download:- gv_color_url(Url), @@ -91,6 +96,52 @@ assert_color_table(Colorscheme, TableDom):- append(Rows, Cells), forall( member(Cell, Cells), - assert(gv_color(Colorscheme, Cell)) + assert_gv_color(Colorscheme, Cell) + ). + + +%! gv_color_file(-File:atom) is det. + +gv_color_file(File):- + absolute_file_name( + data(gv_color), + File, + [access(write),file_type(logging)] ). + +%! gv_color_init is det. + +gv_color_init:- + gv_color_file(File), + safe_db_attach(File), + file_age(File, Age), + gv_color_update(Age). + + +%! gv_color_update(+Age:float) is det. + +% The persistent store is still fresh. +gv_color_update(Age):- + once(gv_color(_, _)), + Age < 3600, !. +% The persistent store has become stale, so refresh it. +gv_color_update(_):- + retractall_gv_color(_, _), + gv_color_download. + + +%! gv_color_url(-Url:url) is det. + +gv_color_url('http://www.graphviz.org/doc/info/colors.html'). + + +%! safe_db_attach(+File:atom) is det. + +safe_db_attach(File):- + exists_file(File), !, + db_attach(File, []). +safe_db_attach(File):- + touch_file(File), + safe_db_attach(File). + ```

5: 正在比较变动前 acf4ec3 和变动后 c1ad93f

[back to content](#compare) ``` diff diff --git a/gv_attrs.pl b/gv_attrs.pl index b360039..fa499d0 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -130,7 +130,7 @@ gv_attrs_init:- % The persistent store is still fresh. gv_attrs_update(Age):- once(gv_attr(_, _, _, _, _, _)), - Age < 3600, !. + Age < 8640000, !. % The persistent store has become stale, so refresh it. gv_attrs_update(_):- retractall_gv_attr(_, _, _, _, _, _), diff --git a/gv_color.pl b/gv_color.pl index cf92f56..70e0495 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -124,7 +124,7 @@ gv_color_init:- % The persistent store is still fresh. gv_color_update(Age):- once(gv_color(_, _)), - Age < 3600, !. + Age < 8640000, !. % The persistent store has become stale, so refresh it. gv_color_update(_):- retractall_gv_color(_, _), ```

6: 正在比较变动前 c1ad93f 和变动后 c7c8226

[back to content](#compare) ``` diff diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 03d4b46..af1a250 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 03d4b46ba9c6f658828ff843e5785c221ffc3a57 +Subproject commit af1a250d6074d0ab61a525fd064bfd555c5815a1 diff --git a/plHtml b/plHtml index 50743da..81eb731 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit 50743daad8dd0f3664e1cafbc14523a423314f84 +Subproject commit 81eb731eb46d98979c8f2862cfbf0e0aca9c1ef8 ```

7: 正在比较变动前 c7c8226 和变动后 0cd29ea

[back to content](#compare) ``` diff diff --git a/load.pl b/load.pl index d502d58..4b117d1 100644 --- a/load.pl +++ b/load.pl @@ -1,11 +1,11 @@ % Load file for plGraphViz. -:- multifile(user:prolog/3). :- dynamic(user:prolog/3). -user:project(plGraphViz, 'GraphViz support for SWI-Prolog.', plGraphViz). +:- multifile(user:prolog/3). + user:project(plGraphViz, 'GraphViz support for SWI-Prolog.', plGraphViz). :- use_module(load_project). -:- load_project([ +:- load_project(plGraphViz, [ plc-'Prolog-Library-Collection', plHtml ]). diff --git a/load_project.pl b/load_project.pl index 3eae83d..5599b5e 100644 --- a/load_project.pl +++ b/load_project.pl @@ -1,7 +1,8 @@ :- module( load_project, [ - load_project/1, % +ChildProjects:list(or([atom,pair(atom)])) + load_project/2, % +Parent:atom + % +ChildProjects:list(or([atom,pair(atom)])) load_subproject/2, % +ParentFileSearchPath:atom % +Child:or([atom,pair(atom)]) set_data_subdirectory/1 % +ParentDirectory:atom @@ -16,19 +17,24 @@ Generic code for loading a project: * Load the index of subprojects onto the file search path. @author Wouter Beek -@version 2014/05/27 +@version 2014/06/14 */ -:- use_module(library(ansi_term)). +:- use_module(library(ansi_term)). % Colorized terminal messages. :- use_module(library(apply)). +:- dynamic(user:project/2). +:- multifile(user:project/2). +:- dynamic(user:project/3). +:- multifile(user:project/3). -load_project(ChildProjects):- - user:project(_, _, ParentFsp), + +load_project(Parent, ChildProjects):- + parent_alias(Parent, ParentFsp), % Entry point. - source_file(load_project(_), ThisFile), + source_file(load_project(_,_), ThisFile), file_directory_name(ThisFile, ThisDir), assert(user:file_search_path(ParentFsp, ThisDir)), assert(user:file_search_path(project, ThisDir)), @@ -38,7 +44,7 @@ load_project(ChildProjects):- % Load the root of submodules onto the file search path. maplist(load_subproject(ParentFsp), ChildProjects), - + % Load the index into the file search path. load_project_index(ParentFsp). @@ -77,8 +83,20 @@ load_subproject_file_search_path(_, ChildFsp, ChildDir):- load_project_index(Fsp):- Spec =.. [Fsp,index], - absolute_file_name(Spec, File, [access(read),file_type(prolog)]), + absolute_file_name( + Spec, + File, + [access(read),file_errors(fail),file_type(prolog)] + ), !, ensure_loaded(File). +load_project_index(_). + + +%! parent_alias(+Parent:atom, -ParentFsp:atom) is det. + +parent_alias(Parent, ParentFsp):- + user:project(Parent, _, ParentFsp), !. +parent_alias(Parent, Parent). %! set_data_subdirectory(+ParentDirectory:atom) is det. ```

8: 正在比较变动前 0cd29ea 和变动后 13f7fbf

[back to content](#compare) ``` diff diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index af1a250..5b34b01 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit af1a250d6074d0ab61a525fd064bfd555c5815a1 +Subproject commit 5b34b01ab0cc82a56e6fd90fc26e75da22f5a0fe diff --git a/plHtml b/plHtml index 81eb731..08480c4 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit 81eb731eb46d98979c8f2862cfbf0e0aca9c1ef8 +Subproject commit 08480c40acaee5f70bfb21e3c641bef1e7d258bd ```

9: 正在比较变动前 13f7fbf 和变动后 5520d75

[back to content](#compare) ``` diff diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 200c034..f9a0e7f 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -29,18 +29,13 @@ smoothType//1, % +SmoothType:atom %splineType//1, %startType//1, + string//1, % ?Content:atom style//2 % +Context:oneof([cluster,edge,node]) % +Style:atom %viewPort//1 ] ). :- reexport( - library(dcg/basics), - [ - string//1 % +String:atom - ] -). -:- reexport( plGraphViz(gv_color), [ color//1, % +Color:compound @@ -383,6 +378,13 @@ smoothType(triangle). % @tbd startType +%! string(?Content:atom)// . +% A GraphViz string. + +string(Content) --> + atom(Content). + + %! style(?Context:oneof([cluster,edge,node]), ?Style:atom) is nondet. style(Context, Style) --> diff --git a/gv_attrs.pl b/gv_attrs.pl index fa499d0..dd0145a 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -68,7 +68,7 @@ gv_attr(Context, N=V1, N=V2):- ; Dcg =.. [Type,V1] ), - dcg_phrase(Dcg, V2), + once(dcg_phrase(Dcg, V2)), check_minimum(V1, Minimum). check_minimum(_, ''):- !. diff --git a/gv_color.pl b/gv_color.pl index 70e0495..19d6e05 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -23,6 +23,7 @@ :- use_module(dcg(dcg_abnf)). :- use_module(dcg(dcg_cardinal)). +:- use_module(dcg(dcg_content)). :- use_module(generics(db_ext)). :- use_module(os(file_ext)). :- use_module(sparql(sparql_char)). @@ -46,14 +47,17 @@ % 2. `rgba(Red:nonneg,Green:nonneg,Blue:nonneg,Alpha:nonneg)` % 3. `hsv(Hue:between(0.0,1.0),Saturation:between(0.0,1.0),Value:between(0.0,1.0))` -color(rgb(Red,Green,Blue)) --> +color(rgb(Red,Green,Blue)) --> !, `#`, '#'(3, hex_color, [Red,Green,Blue]). -color(rgbs(Red,Green,Blue,Alpha)) --> +color(rgbs(Red,Green,Blue,Alpha)) --> !, `#`, '#'(4, hex_color, [Red,Green,Blue,Alpha]). -color(hsv(Hue,Saturation,Value)) --> +color(hsv(Hue,Saturation,Value)) --> !, '#'(3, hsv_color, [Hue,Saturation,Value]). +color(Name) --> + {gv_color(_, Name)}, + atom(Name). hex_color(I) --> {W1 is I / 16}, diff --git a/gv_file.pl b/gv_file.pl index 827f680..fe63e28 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -1,16 +1,13 @@ :- module( gv_file, [ - graph_to_gv_file/3, % +Options:list(nvpair) + gif_to_gv_file/3, % +Options:list(nvpair) % +GraphInterchangeFormat:compound % ?ToFile:atom graph_to_svg_dom/3, % +Options:list(nvpair) % +GraphInterchangeFormat:compound % -SvgDom:list(compound) - open_dot/1, % +File:file - tree_to_gv_file/3 % +Options:list(nvpair) - % +Tree:compound - % ?ToFile:atom + open_dot/1 % +File:file ] ). @@ -81,7 +78,7 @@ user:prolog_file_type(xdot, xdot). -%! graph_to_gv_file( +%! gif_to_gv_file( %! +Options:list(nvpair), %! +GIF:compound, %! -ToFile:atom @@ -99,7 +96,7 @@ user:prolog_file_type(xdot, xdot). % @arg GIF A compound term representing a graph. % @arg ToFile The atomic name of a file. -graph_to_gv_file(O1, GIF, ToFile):- +gif_to_gv_file(O1, GIF, ToFile):- once(phrase(gv_graph(GIF), Codes)), to_gv_file(O1, Codes, ToFile). @@ -117,7 +114,7 @@ graph_to_gv_file(O1, GIF, ToFile):- graph_to_svg_dom(O1, GIF, SvgDom):- % Make sure the file type of the output file is SvgDom. merge_options([to_file_type=svg], O1, O2), - graph_to_gv_file(O2, GIF, ToFile), + gif_to_gv_file(O2, GIF, ToFile), file_to_svg(ToFile, SvgDom), safe_delete_file(ToFile). @@ -133,33 +130,6 @@ open_dot(File):- run_program(Program, [File]). -%! tree_to_gv_file(+Options:list(nvpair), +Tree:compound, ?ToFile:atom) is det. -% Stores the given tree term into a GraphViz file. -% -% The following options are supported: -% * =|method(+Method:oneof([dot,sfdp])|= -% The algorithm used by GraphViz for positioning the tree nodes. -% Either =dot= (default) or =sfdp=. -% * =|to_file_type(+FileType:oneof([jpeg,pdf,svg,xdot])|= -% The file type of the generated GraphViz file. -% -% @arg Options A list of name-value pairs. -% @arg Tree A compound term representing a tree. -% @arg ToFile The atomic name of the generated file. - -tree_to_gv_file(O1, Tree, ToFile):- - once(phrase(gv_tree(O1, Tree), Codes)), - to_gv_file(O1, Codes, ToFile). - -gv_tree(O1, T) --> - { - tree_to_ugraph(T, UG), - merge_options([edge_labels(false)], O1, O2), - export_ugraph(O2, UG, G_Term) - }, - gv_graph(G_Term). - - % SUPPORT PREDICATES % diff --git a/gv_gif.pl b/gv_gif.pl new file mode 100644 index 0000000..becf7e2 --- /dev/null +++ b/gv_gif.pl @@ -0,0 +1,109 @@ +:- module( + gv_gif, + [ + create_gif/3, % +Edges:ordset + % -Gif:compound + % +Options:list(nvpair) + create_gif/4 % +Vertices:ordset + % +Edges:ordset + % -Gif:compound + % +Options:list(nvpair) + ] +). + +/** GraphViz Graph Interchange Format (GIF) + +Support for creating GIF representations. + +@author Wouter Beek +@version 2014/06 +*/ + +:- use_module(library(apply)). +:- use_module(library(ordsets)). + +:- use_module(generics(list_ext)). + +:- use_module(plRdf(rdf_name)). % Meta-DCG. + + + +%! create_gif(+Edges:ordset, -Gif:compound, +Options:list(nvpair)) is det. + +create_gif(Es, Gif, Options):- + edges_to_vertices(Es, Vs), + create_gif(Vs, Es, Gif, Options). + +%! create_gif( +%! +Vertices:ordset, +%! +Edges:ordset, +%! -Gif:compound, +%! +Options:list(nvpair) +%! ) is det. + +create_gif(Vs, Es, graph(V_Terms,E_Terms,G_Attrs), Options):- + maplist(vertex_term0(Vs, Options), Vs, V_Terms), + maplist(edge_term0(Vs, Options), Es, E_Terms), + G_Attrs = [directed=true]. + +edge_term0(Vs, Options, E, E_Term):- + edge_term(Vs, E, E_Term, Options). + +vertex_term0(Vs, Options, V, V_Term):- + vertex_term(Vs, V, V_Term, Options). + + +%! edge_term( +%! +Vertices:ordset, +%! +Edge:pair, +%! -EdgeTerm:compound, +%! +Options:list(nvpair) +%! ) is det. + +edge_term(Vs, E, edge(FromId,ToId,E_Attrs), _):- + edge_components(E, FromV, _, ToV), + nth0chk(FromId, Vs, FromV), + nth0chk(ToId, Vs, ToV), + E_Attrs = []. + + +%! vertex_term( +%! +Vertices:ordset, +%! +Vertex, +%! -VertexTerm:compound, +%! +Options:list(nvpair) +%! ) is det. + +vertex_term(Vs, V, vertex(Id,V,V_Attrs), Options):- + nth0chk(Id, Vs, V), + + % Label. + option(vertex_label(VertexLabel), Options, =), + call(VertexLabel, V, V_Label), + + V_Attrs = [label=V_Label]. + +vertex_label(V, V_Label):- + dcg_with_output_to(atom(V_Label), rdf_term_name([literal_ellipsis(50)], V)). + + + +% Helpers + +%! edge_components(+Edge:compound, -FromVertex, -EdgeType, -ToVertex) is det. +%! edge_components(-Edge:compound, +FromVertex, ?EdgeType, +ToVertex) is det. + +edge_components(FromV-EdgeType-ToV, FromV, EdgeType, ToV):- + nonvar(EdgeType). +edge_components(FromV-ToV, FromV, EdgeType, ToV):- + var(EdgeType). + + +%! edges_to_vertices(+Edges:ordset, -Vertices:ordset) is det. + +edges_to_vertices([], []):- !. +edges_to_vertices([S-_-O|T], S3):- + edges_to_vertices(T, S1), + ord_add_element(S1, S, S2), + ord_add_element(S2, O, S3). + diff --git a/gv_tree.pl b/gv_tree.pl new file mode 100644 index 0000000..4412a90 --- /dev/null +++ b/gv_tree.pl @@ -0,0 +1,39 @@ +:- module( + gv_tree, + [ + tree_to_gv_file/3 % +Options:list(nvpair) + % +Tree:compound + % ?ToFile:atom + ] +). + +/** GraphViz tree + +Export trees to GraphViz. + +@author Wouter Beek +@version 2014/06 +*/ + +:- use_module(library(aggregate)). + +:- use_module(generics(trees)). + +:- use_module(plGraphViz(gv_file)). +:- use_module(plGraphViz(gv_gif)). + + +%! tree_to_gv_file(+Options:list(nvpair), +Tree:compound, ?ToFile:atom) is det. +% Stores the given tree term into a GraphViz file. +% +% Options are passed on to create_gif/3 and gif_to_gv_file/3. + +tree_to_gv_file(Options, Tree, ToFile):- + tree_to_gif(Tree, Gif, Options), + gif_to_gv_file(Options, Gif, ToFile). + + +tree_to_gif(H-T, Gif, Options):- + tree_to_vertices_edges(Tree, Vs, Es), + create_gif(Vs, Es, Gif, Options). + ```

10: 正在比较变动前 5520d75 和变动后 8656a39

[back to content](#compare) ``` diff diff --git a/gv_attr_type.pl b/gv_attr_type.pl index f9a0e7f..7a64c82 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -191,7 +191,7 @@ doubleList1(Float) --> double(Float). -%! escString(+String:atom)// , +%! escString(+String:atom)// . % @tbd Support for context-dependent replacements. escString(String) --> ```

11: 正在比较变动前 8656a39 和变动后 7421981

[back to content](#compare) ``` diff diff --git a/gv_file.pl b/gv_file.pl index fe63e28..c780692 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -1,12 +1,12 @@ :- module( gv_file, [ - gif_to_gv_file/3, % +Options:list(nvpair) - % +GraphInterchangeFormat:compound - % ?ToFile:atom - graph_to_svg_dom/3, % +Options:list(nvpair) - % +GraphInterchangeFormat:compound + gif_to_gv_file/3, % +GraphInterchangeFormat:compound + % ?ToFile:atom + % +Options:list(nvpair) + graph_to_svg_dom/3, % +GraphInterchangeFormat:compound % -SvgDom:list(compound) + % +Options:list(nvpair) open_dot/1 % +File:file ] ). @@ -20,11 +20,12 @@ Also converts between GraphViz DOT formatted files and GraphViz output files or SVG DOM structures. @author Wouter Beek -@version 2011-2013/09, 2013/11-2014/01, 2014/05 +@version 2011-2013/09, 2013/11-2014/01, 2014/05, 2014/07 */ :- use_module(library(option)). :- use_module(library(process)). +:- use_module(library(predicate_options)). % Declarations. :- use_module(generics(codes_ext)). :- use_module(generics(db_ext)). @@ -48,73 +49,76 @@ and GraphViz output files or SVG DOM structures. :- multifile(user:prolog_file_type/2). % Register DOT. -user:prolog_file_type(dot, dot). -user:prolog_file_type(dot, graphviz). -user:file_type_program(dot, dotty). -user:file_type_program(dot, dotx). -user:module_uses(gv_file, file_type(dot)). +:- db_add_novel(user:prolog_file_type(dot, dot)). +:- db_add_novel(user:prolog_file_type(dot, graphviz)). +:- db_add_novel(user:file_type_program(dot, dotty)). +:- db_add_novel(user:file_type_program(dot, dotx)). +:- db_add_novel(user:module_uses(gv_file, file_type(dot))). % Register JPG/JPEG. -user:prolog_file_type(jpeg, jpeg). -user:prolog_file_type(jpeg, graphviz_output). -user:prolog_file_type(jpg, jpeg). -user:prolog_file_type(jpg, graphviz_output). +:- db_add_novel(user:prolog_file_type(jpeg, jpeg)). +:- db_add_novel(user:prolog_file_type(jpeg, graphviz_output)). +:- db_add_novel(user:prolog_file_type(jpg, jpeg)). +:- db_add_novel(user:prolog_file_type(jpg, graphviz_output)). % Register PDF. -user:prolog_file_type(pdf, pdf). -user:prolog_file_type(pdf, graphviz_output). +:- db_add_novel(user:prolog_file_type(pdf, pdf)). +:- db_add_novel(user:prolog_file_type(pdf, graphviz_output)). % Register PNG. -user:prolog_file_type(png, png). -user:prolog_file_type(png, graphviz_output). +:- db_add_novel(user:prolog_file_type(png, png)). +:- db_add_novel(user:prolog_file_type(png, graphviz_output)). % Register SVG. -user:prolog_file_type(svg, graphviz_output). -user:prolog_file_type(svg, svg). +:- db_add_novel(user:prolog_file_type(svg, graphviz_output)). +:- db_add_novel(user:prolog_file_type(svg, svg)). % Register XDOT. -user:prolog_file_type(xdot, graphviz_output). -user:prolog_file_type(xdot, xdot). - - - -%! gif_to_gv_file( -%! +Options:list(nvpair), -%! +GIF:compound, -%! -ToFile:atom -%! ) is det. +:- db_add_novel(user:prolog_file_type(xdot, graphviz_output)). +:- db_add_novel(user:prolog_file_type(xdot, xdot)). + +:- predicate_options(graph_to_svg_dom/3, 3, [ + pass_to(gif_to_gv_file/3, 3) + ]). +:- predicate_options(gif_to_gv_file/3, 3, [ + pass_to(to_gv_file/3, 3) + ]). +:- predicate_options(to_gv_file/3, 3, [ + pass_to(convert_gv/3, 3) + ]). +:- predicate_options(convert_gv/3, 3, [ + method(+oneof([dot,sfdp])), + to_file_type(+oneof([dot,jpeg,pdf,svg,xdot])) + ]). + + + +%! gif_to_gv_file(+Gif:compound, -ToFile:atom, +Options:list(nvpair)) is det. % Returns a file containing a GraphViz visualization of the given graph. % % The following options are supported: % * =|method(+Method:oneof([dot,sfdp])|= % The algorithm used by GraphViz for positioning the tree nodes. % Either =dot= (default) or =sfdp=. -% * =|to_file_type(+FileType:oneof([jpeg,pdf,svg,xdot])|= +% * =|to_file_type(+FileType:oneof([dot,jpeg,pdf,svg,xdot])|= % The file type of the generated GraphViz file. -% -% @arg Options A list of name-value pairs. -% @arg GIF A compound term representing a graph. -% @arg ToFile The atomic name of a file. +% Default: `pdf`. -gif_to_gv_file(O1, GIF, ToFile):- - once(phrase(gv_graph(GIF), Codes)), - to_gv_file(O1, Codes, ToFile). +gif_to_gv_file(Gif, ToFile, Options):- + once(phrase(gv_graph(Gif), Codes)), + to_gv_file(Codes, ToFile, Options). %! graph_to_svg_dom( -%! +Options:list(nvpair), %! +GraphInterchangeFormat:compound, -%! -SvgDom:list(compound) +%! -SvgDom:list(compound), +%! +Options:list(nvpair) %! ) is det. -% The following options are supported: -% * =|method(+Method:oneof([dot,sfdp])|= -% The algorithm used by GraphViz for positioning the tree nodes. -% Either =dot= (default) or =sfdp=. -graph_to_svg_dom(O1, GIF, SvgDom):- +graph_to_svg_dom(Gif, SvgDom, Options1):- % Make sure the file type of the output file is SvgDom. - merge_options([to_file_type=svg], O1, O2), - gif_to_gv_file(O2, GIF, ToFile), + merge_options([to_file_type=svg], Options1, Options2), + gif_to_gv_file(Gif, ToFile, Options2), file_to_svg(ToFile, SvgDom), safe_delete_file(ToFile). @@ -133,31 +137,23 @@ open_dot(File):- % SUPPORT PREDICATES % -%! convert_gv(+Options:list(nvpair), +FromFile:atom, ?ToFile:atom) is det. +%! convert_gv(+FromFile:atom, ?ToFile:atom, +Options:list(nvpair)) is det. % Converts a GraphViz DOT file to an image file, using a specific % visualization method. -% -% The following options are supported: -% * =|method(+Method:oneof([dot,sfdp])|= -% The algorithm used by GraphViz for positioning the tree nodes. -% Either =dot= (default) or =sfdp=. -% * =|to_file_type(+FileType:oneof([jpeg,pdf,svg,xdot])|= -% The file type of the generated GraphViz file. -% -% @arg Options -% @arg FromFile -% @arg ToFile -convert_gv(O1, FromFile, ToFile):- +convert_gv(FromFile, ToFile, Options):- + option(to_file_type(dot), Options), !, + rename_file(FromFile, ToFile). +convert_gv(FromFile, ToFile, Options):- % The input file must be readable. access_file(FromFile, read), % The method option. - option(method(Method), O1, dot), + option(method(Method), Options, dot), must_be(oneof([dot,sfdp]), Method), % The file type option. - option(to_file_type(ToFileType), O1, pdf), + option(to_file_type(ToFileType), Options, pdf), prolog_file_type(ToExtension, ToFileType), prolog_file_type(ToExtension, graphviz_output), !, @@ -189,15 +185,10 @@ convert_gv(O1, FromFile, ToFile):- process_wait(PID, exit(ShellStatus)), exit_code_handler('GraphViz', ShellStatus). -%! to_gv_file(+Options:list(nvpair), +Codes:list(code), ?ToFile:atom) is det. -% The following options are supported: -% * =|method(+Method:oneof([dot,sfdp])|= -% The algorithm used by GraphViz for positioning the tree nodes. -% Either =dot= (default) or =sfdp=. -% * =|to_file_type(+FileType:oneof([jpeg,pdf,svg,xdot])|= -% The file type of the generated GraphViz file. -to_gv_file(O1, Codes, ToFile):- +%! to_gv_file(+Codes:list(code), ?ToFile:atom, +Options:list(nvpair)) is det. + +to_gv_file(Codes, ToFile, Options):- absolute_file_name( data(tmp), FromFile, @@ -208,13 +199,13 @@ to_gv_file(O1, Codes, ToFile):- put_codes(Out, Codes), close(Out) ), - convert_gv(O1, FromFile, ToFile), + convert_gv(FromFile, ToFile, Options), - % DEB: Store DOT file. - ignore(( - file_type_alternative(ToFile, graphviz, DOT_File), - safe_copy_file(FromFile, DOT_File) - )), + %%%%% DEB: Store DOT file. + %%%%ignore(( + %%%% file_type_alternative(ToFile, graphviz, DOT_File), + %%%% safe_copy_file(FromFile, DOT_File) + %%%%)), safe_delete_file(FromFile). diff --git a/gv_tree.pl b/gv_tree.pl index 4412a90..afeb8f6 100644 --- a/gv_tree.pl +++ b/gv_tree.pl @@ -1,9 +1,9 @@ :- module( gv_tree, [ - tree_to_gv_file/3 % +Options:list(nvpair) - % +Tree:compound + tree_to_gv_file/3 % +Tree:compound % ?ToFile:atom + % +Options:list(nvpair) ] ). @@ -12,7 +12,7 @@ Export trees to GraphViz. @author Wouter Beek -@version 2014/06 +@version 2014/06-2014/07 */ :- use_module(library(aggregate)). @@ -23,14 +23,18 @@ Export trees to GraphViz. :- use_module(plGraphViz(gv_gif)). -%! tree_to_gv_file(+Options:list(nvpair), +Tree:compound, ?ToFile:atom) is det. +%! tree_to_gv_file( +%! +Tree:compound, +%! ?ToFile:atom, +%! +Options:list(nvpair) +%! ) is det. % Stores the given tree term into a GraphViz file. % % Options are passed on to create_gif/3 and gif_to_gv_file/3. -tree_to_gv_file(Options, Tree, ToFile):- +tree_to_gv_file(Tree, ToFile, Options):- tree_to_gif(Tree, Gif, Options), - gif_to_gv_file(Options, Gif, ToFile). + gif_to_gv_file(Gif, ToFile, Options). tree_to_gif(H-T, Gif, Options):- ```

12: 正在比较变动前 7421981 和变动后 bfcb63b

[back to content](#compare) ``` diff diff --git a/gv_file.pl b/gv_file.pl index c780692..9cb1f95 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -4,9 +4,9 @@ gif_to_gv_file/3, % +GraphInterchangeFormat:compound % ?ToFile:atom % +Options:list(nvpair) - graph_to_svg_dom/3, % +GraphInterchangeFormat:compound - % -SvgDom:list(compound) - % +Options:list(nvpair) + gif_to_svg_dom/3, % +GraphInterchangeFormat:compound + % -SvgDom:list(compound) + % +Options:list(nvpair) open_dot/1 % +File:file ] ). @@ -77,7 +77,7 @@ and GraphViz output files or SVG DOM structures. :- db_add_novel(user:prolog_file_type(xdot, graphviz_output)). :- db_add_novel(user:prolog_file_type(xdot, xdot)). -:- predicate_options(graph_to_svg_dom/3, 3, [ +:- predicate_options(gif_to_svg_dom/3, 3, [ pass_to(gif_to_gv_file/3, 3) ]). :- predicate_options(gif_to_gv_file/3, 3, [ @@ -109,13 +109,13 @@ gif_to_gv_file(Gif, ToFile, Options):- to_gv_file(Codes, ToFile, Options). -%! graph_to_svg_dom( +%! gif_to_svg_dom( %! +GraphInterchangeFormat:compound, %! -SvgDom:list(compound), %! +Options:list(nvpair) %! ) is det. -graph_to_svg_dom(Gif, SvgDom, Options1):- +gif_to_svg_dom(Gif, SvgDom, Options1):- % Make sure the file type of the output file is SvgDom. merge_options([to_file_type=svg], Options1, Options2), gif_to_gv_file(Gif, ToFile, Options2), ```

13: 正在比较变动前 bfcb63b 和变动后 84afd69

[back to content](#compare) ``` diff diff --git a/gv_file.pl b/gv_file.pl index 9cb1f95..98cb0a2 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -1,8 +1,13 @@ :- module( gv_file, [ + file_to_gv/2, % +File:atom + % +Options:list(nvpair) + file_to_gv/3, % +FromFile:atom + % ?ToFile:atom + % +Options:list(nvpair) gif_to_gv_file/3, % +GraphInterchangeFormat:compound - % ?ToFile:atom + % +ToFile:atom % +Options:list(nvpair) gif_to_svg_dom/3, % +GraphInterchangeFormat:compound % -SvgDom:list(compound) @@ -23,6 +28,7 @@ and GraphViz output files or SVG DOM structures. @version 2011-2013/09, 2013/11-2014/01, 2014/05, 2014/07 */ +:- use_module(library(memfile)). :- use_module(library(option)). :- use_module(library(process)). :- use_module(library(predicate_options)). % Declarations. @@ -77,74 +83,60 @@ and GraphViz output files or SVG DOM structures. :- db_add_novel(user:prolog_file_type(xdot, graphviz_output)). :- db_add_novel(user:prolog_file_type(xdot, xdot)). -:- predicate_options(gif_to_svg_dom/3, 3, [ - pass_to(gif_to_gv_file/3, 3) - ]). -:- predicate_options(gif_to_gv_file/3, 3, [ - pass_to(to_gv_file/3, 3) +:- predicate_options(codes_to_gv_file/3, 3, [ + pass_to(file_to_gv/3, 3) ]). -:- predicate_options(to_gv_file/3, 3, [ - pass_to(convert_gv/3, 3) +:- predicate_options(file_to_gv/2, 2, [ + pass_to(file_to_gv/3, 3) ]). -:- predicate_options(convert_gv/3, 3, [ +:- predicate_options(file_to_gv/3, 3, [ method(+oneof([dot,sfdp])), to_file_type(+oneof([dot,jpeg,pdf,svg,xdot])) ]). +:- predicate_options(gif_to_svg_dom/3, 3, [ + pass_to(gif_to_gv_file/3, 3) + ]). +:- predicate_options(gif_to_gv_file/3, 3, [ + pass_to(codes_to_gv_file/3, 3) + ]). -%! gif_to_gv_file(+Gif:compound, -ToFile:atom, +Options:list(nvpair)) is det. -% Returns a file containing a GraphViz visualization of the given graph. -% -% The following options are supported: -% * =|method(+Method:oneof([dot,sfdp])|= -% The algorithm used by GraphViz for positioning the tree nodes. -% Either =dot= (default) or =sfdp=. -% * =|to_file_type(+FileType:oneof([dot,jpeg,pdf,svg,xdot])|= -% The file type of the generated GraphViz file. -% Default: `pdf`. - -gif_to_gv_file(Gif, ToFile, Options):- - once(phrase(gv_graph(Gif), Codes)), - to_gv_file(Codes, ToFile, Options). - - -%! gif_to_svg_dom( -%! +GraphInterchangeFormat:compound, -%! -SvgDom:list(compound), +%! codes_to_gv_file( +%! +Codes:list(code), +%! +ToFile:atom, %! +Options:list(nvpair) %! ) is det. -gif_to_svg_dom(Gif, SvgDom, Options1):- - % Make sure the file type of the output file is SvgDom. - merge_options([to_file_type=svg], Options1, Options2), - gif_to_gv_file(Gif, ToFile, Options2), - file_to_svg(ToFile, SvgDom), - safe_delete_file(ToFile). - - -%! open_dot(+File:atom) is det. -% Opens the given DOT file. -% -% @tbd Test support on Windows. -% @tbd Test support on OS-X. - -open_dot(File):- - once(find_program_by_file_type(dot, Program)), - run_program(Program, [File]). +codes_to_gv_file(Codes, ToFile, Options):- + access_file(ToFile, write), + setup_call_cleanup( + new_memory_file(MemFile), + ( + setup_call_cleanup( + open(MemFile, write, Write, [encoding(utf8),type(test)]), + put_codes(Write, Codes), + close(Write) + ), + file_to_gv(MemFile, ToFile, Options) + ), + free_memory_file(MemFile) + ). +%! file_to_gv(+FromFile:atom, +Options:list(nvpair)) is det. -% SUPPORT PREDICATES % +file_to_gv(FromFile, Options):- + file_to_gv(FromFile, _, Options). -%! convert_gv(+FromFile:atom, ?ToFile:atom, +Options:list(nvpair)) is det. +%! file_to_gv(+FromFile:atom, ?ToFile:atom, +Options:list(nvpair)) is det. % Converts a GraphViz DOT file to an image file, using a specific % visualization method. -convert_gv(FromFile, ToFile, Options):- +file_to_gv(FromFile, ToFile, Options):- option(to_file_type(dot), Options), !, rename_file(FromFile, ToFile). -convert_gv(FromFile, ToFile, Options):- +file_to_gv(FromFile, ToFile, Options):- % The input file must be readable. access_file(FromFile, read), @@ -186,26 +178,43 @@ convert_gv(FromFile, ToFile, Options):- exit_code_handler('GraphViz', ShellStatus). -%! to_gv_file(+Codes:list(code), ?ToFile:atom, +Options:list(nvpair)) is det. +%! gif_to_gv_file(+Gif:compound, +ToFile:atom, +Options:list(nvpair)) is det. +% Returns a file containing a GraphViz visualization of the given graph. +% +% The following options are supported: +% * =|method(+Method:oneof([dot,sfdp])|= +% The algorithm used by GraphViz for positioning the tree nodes. +% Either =dot= (default) or =sfdp=. +% * =|to_file_type(+FileType:oneof([dot,jpeg,pdf,svg,xdot])|= +% The file type of the generated GraphViz file. +% Default: `pdf`. + +gif_to_gv_file(Gif, ToFile, Options):- + once(phrase(gv_graph(Gif), Codes)), + codes_to_gv_file(Codes, ToFile, Options). + + +%! gif_to_svg_dom( +%! +GraphInterchangeFormat:compound, +%! -SvgDom:list(compound), +%! +Options:list(nvpair) +%! ) is det. + +gif_to_svg_dom(Gif, SvgDom, Options1):- + % Make sure the file type of the output file is SvgDom. + merge_options([to_file_type=svg], Options1, Options2), + gif_to_gv_file(Gif, ToFile, Options2), + file_to_svg(ToFile, SvgDom), + safe_delete_file(ToFile). -to_gv_file(Codes, ToFile, Options):- - absolute_file_name( - data(tmp), - FromFile, - [access(write),file_type(graphviz)] - ), - setup_call_cleanup( - open(FromFile, write, Out, [encoding(utf8),type(test)]), - put_codes(Out, Codes), - close(Out) - ), - convert_gv(FromFile, ToFile, Options), - %%%%% DEB: Store DOT file. - %%%%ignore(( - %%%% file_type_alternative(ToFile, graphviz, DOT_File), - %%%% safe_copy_file(FromFile, DOT_File) - %%%%)), +%! open_dot(+File:atom) is det. +% Opens the given DOT file. +% +% @tbd Test support on Windows. +% @tbd Test support on OS-X. - safe_delete_file(FromFile). +open_dot(File):- + once(find_program_by_file_type(dot, Program)), + run_program(Program, [File]). ```

14: 正在比较变动前 84afd69 和变动后 c2bfd3f

[back to content](#compare) ``` diff diff --git a/gv_gif.pl b/gv_gif.pl index becf7e2..908b9bc 100644 --- a/gv_gif.pl +++ b/gv_gif.pl @@ -16,16 +16,35 @@ Support for creating GIF representations. @author Wouter Beek -@version 2014/06 +@version 2014/06-2014/07 */ :- use_module(library(apply)). +:- use_module(library(lambda)). +:- use_module(library(option)). :- use_module(library(ordsets)). +:- use_module(library(predicate_options)). % Declarations. :- use_module(generics(list_ext)). +:- use_module(generics(option_ext)). +:- use_module(graph_theory(graph_generic)). :- use_module(plRdf(rdf_name)). % Meta-DCG. +:- predicate_options(create_gif/3, 3, [ + pass_to(create_gif/4, 4) + ]). +:- predicate_options(create_gif/4, 4, [ + pass_to(vertex_term/3, 3), + pass_to(edge_term/3, 3), + graph_label(+atom) + ]). +:- predicate_options(edge_term/3, 3, [ + ]). +:- predicate_options(vertex_term/3, 3, [ + vertex_label(+atom) + ]). + %! create_gif(+Edges:ordset, -Gif:compound, +Options:list(nvpair)) is det. @@ -40,17 +59,28 @@ create_gif(Es, Gif, Options):- %! -Gif:compound, %! +Options:list(nvpair) %! ) is det. - -create_gif(Vs, Es, graph(V_Terms,E_Terms,G_Attrs), Options):- - maplist(vertex_term0(Vs, Options), Vs, V_Terms), - maplist(edge_term0(Vs, Options), Es, E_Terms), - G_Attrs = [directed=true]. - -edge_term0(Vs, Options, E, E_Term):- - edge_term(Vs, E, E_Term, Options). - -vertex_term0(Vs, Options, V, V_Term):- - vertex_term(Vs, V, V_Term, Options). +% The following options are supported: +% * =|graph_label(+LabelFunction)|= +% The functions that assigns names to graphs. +% No default. + +create_gif(Vs, Es, graph(VTerms,ETerms,GAttrs), Options):- + % Vertex terms. + maplist(\V^VTerm^vertex_term(Vs, V, VTerm, Options), Vs, VTerms), + + % Edge terms. + maplist(\E^ETerm^edge_term(Vs, E, ETerm, Options), Es, ETerms), + + % Graph attributes. + ( + option(graph_label(LabelFunction), Options) + -> + call(LabelFunction, Graph, GraphLabel) + ; + true + ), + + merge_options([directed=true,label=GraphLabel], GAttrs). %! edge_term( @@ -60,11 +90,13 @@ vertex_term0(Vs, Options, V, V_Term):- %! +Options:list(nvpair) %! ) is det. -edge_term(Vs, E, edge(FromId,ToId,E_Attrs), _):- - edge_components(E, FromV, _, ToV), +edge_term(Vs, E, edge(FromId,ToId,EAttrs), _):- + edge_components(E, FromV, ToV), + nth0chk(FromId, Vs, FromV), nth0chk(ToId, Vs, ToV), - E_Attrs = []. + + EAttrs = []. %! vertex_term( @@ -73,37 +105,16 @@ edge_term(Vs, E, edge(FromId,ToId,E_Attrs), _):- %! -VertexTerm:compound, %! +Options:list(nvpair) %! ) is det. +% The following options are supported: +% * =|vertex_label(+LabelFunction)|= +% A function that assigns labels to vertices. -vertex_term(Vs, V, vertex(Id,V,V_Attrs), Options):- +vertex_term(Vs, V, vertex(Id,V,VAttrs), Options):- nth0chk(Id, Vs, V), % Label. - option(vertex_label(VertexLabel), Options, =), - call(VertexLabel, V, V_Label), + option(vertex_label(LabelFunction), Options, =), + call(LabelFunction, V, VLabel), - V_Attrs = [label=V_Label]. - -vertex_label(V, V_Label):- - dcg_with_output_to(atom(V_Label), rdf_term_name([literal_ellipsis(50)], V)). - - - -% Helpers - -%! edge_components(+Edge:compound, -FromVertex, -EdgeType, -ToVertex) is det. -%! edge_components(-Edge:compound, +FromVertex, ?EdgeType, +ToVertex) is det. - -edge_components(FromV-EdgeType-ToV, FromV, EdgeType, ToV):- - nonvar(EdgeType). -edge_components(FromV-ToV, FromV, EdgeType, ToV):- - var(EdgeType). - - -%! edges_to_vertices(+Edges:ordset, -Vertices:ordset) is det. - -edges_to_vertices([], []):- !. -edges_to_vertices([S-_-O|T], S3):- - edges_to_vertices(T, S1), - ord_add_element(S1, S, S2), - ord_add_element(S2, O, S3). + VAttrs = [label=VLabel]. ```

15: 正在比较变动前 c2bfd3f 和变动后 fa364fc

[back to content](#compare) ``` diff diff --git a/gv_dot.pl b/gv_dot.pl index 9888973..68443ba 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -76,13 +76,13 @@ gv_compass_pt(sw) --> `sw`. gv_compass_pt(w) --> `w`. -%! gv_edge_operator(+Directed:boolean)// . +%! gv_edge_operator(+Directedness:boolean)// . % The binary edge operator between two vertices. % The operator that is used depends on whether the graph is directed or % undirected. % -% @arg Directed Whether an edge is directed (operator `->`) or -% undirected (operator `--`). +% @arg Directedness Whether an edge is directed (operator `->`) or +% undirected (operator `--`). gv_edge_operator(false) --> !, `--`. gv_edge_operator(true) --> arrow(right, 2). @@ -90,14 +90,14 @@ gv_edge_operator(true) --> arrow(right, 2). %! gv_edge_statement( %! +Indent:nonneg, -%! +Directed:boolean, +%! +Directedness:boolean, %! +GraphAttributes:list(nvpair), %! +EdgeTerm:compound %! )// is det. % A GraphViz statement describing an edge. % % @arg Indent The indentation level at which the edge statement is written. -% @arg Directed Whether the graph is directed or not. +% @arg Directedness Whether the graph is directed or not. % @arg GraphAttributes The attributes of the graph. Some of these attributes % may be used in the edge statement (e.g., the colorscheme). % @arg EdgeTerm A compound term in the GIFormat, representing an edge. @@ -106,11 +106,11 @@ gv_edge_operator(true) --> arrow(right, 2). % at the from and/or to location. % @tbd Add support for multiple, consecutive occurrences of gv_edge_rhs//2. -gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> +gv_edge_statement(I, Directedness, GAttrs, edge(FromId,ToId,EAttrs)) --> indent(I), gv_node_id(FromId), ` `, - gv_edge_operator(Directed), ` `, + gv_edge_operator(Directedness), ` `, gv_node_id(ToId), ` `, @@ -148,11 +148,11 @@ gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> %! gv_graph(+GraphTerm:compound)// % The follow graph attributes are supported, % beyond the GraphViz attributes for graphs: -% 1. `directonality(+Directed:oneof([directed,undirected]))` -% A directed graph uses the keyword `digraph`. -% An undirected graph uses the keyword `graph`. -% 2. `name(+GraphName:atom)` -% 3. `strict(+StrictGraph:boolean)` +% * `directedness(+boolean)` +% Whether the graph is directed (`true`) or undirected (`false`). +% Default: `false`. +% * `name(+GraphName:atom)` +% * `strict(+StrictGraph:boolean)` % This forbids the creation of self-arcs and multi-edges; % they are ignored in the input file. % Only in combinattion with directionality `directed`. @@ -185,7 +185,7 @@ gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> shared_attributes(VTerms, SharedVAttrs, NewVTerms), shared_attributes(ETerms, SharedEAttrs, NewETerms), select_nvpair(strict=Strict, GAttrs1, GAttrs2, false), - select_nvpair(directed=Directed, GAttrs2, GAttrs3, true), + select_nvpair(directedness=Directedness, GAttrs2, GAttrs3, true), select_nvpair(name=GName, GAttrs3, GAttrs4, noname), add_default_nvpair(GAttrs4, overlap, false, GAttrs5), I = 0 @@ -195,24 +195,24 @@ gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> % States that this file represents a graph according to the GraphViz format. indent(I), gv_strict(Strict), - gv_graph_type(Directed), ` `, + gv_graph_type(Directedness), ` `, gv_id(GName), ` `, bracketed( curly, - gv_graph1( + gv_graph0( I, NewVTerms, SharedVAttrs, RankedVTerms, NewETerms, SharedEAttrs, - Directed, GAttrs5 + Directedness, GAttrs5 ) - ), + ), newline. -gv_graph1( +gv_graph0( I, NewVTerms, SharedVAttrs, RankedVTerms, NewETerms, SharedEAttrs, - Directed, GAttrs + Directedness, GAttrs ) --> newline, @@ -254,10 +254,10 @@ gv_graph1( }, % The rank edges. - '*'(gv_edge_statement(NewI, Directed, GAttrs), RankEdges), + '*'(gv_edge_statement(NewI, Directedness, GAttrs), RankEdges), % The non-rank edges. - '*'(gv_edge_statement(NewI, Directed, GAttrs), NewETerms), + '*'(gv_edge_statement(NewI, Directedness, GAttrs), NewETerms), % Note that we do not include a newline here. @@ -265,7 +265,7 @@ gv_graph1( indent(I). -%! gv_graph_type(+Directed:boolean)// . +%! gv_graph_type(+Directedness:boolean)// . % The type of graph that is represented. gv_graph_type(false) --> `graph`. diff --git a/gv_gif.pl b/gv_gif.pl index 908b9bc..4a3e75f 100644 --- a/gv_gif.pl +++ b/gv_gif.pl @@ -35,14 +35,25 @@ Support for creating GIF representations. pass_to(create_gif/4, 4) ]). :- predicate_options(create_gif/4, 4, [ - pass_to(vertex_term/3, 3), pass_to(edge_term/3, 3), - graph_label(+atom) + pass_to(graph_attributes/2, 2), + pass_to(vertex_term/3, 3) ]). :- predicate_options(edge_term/3, 3, [ ]). +:- predicate_options(graph_attributes/2, 2, [ + directedness(+boolean), + graph_colorscheme(+oneof([none,svg,x11]), + graph_label(+atom) + ]). + :- predicate_options(vertex_term/3, 3, [ - vertex_label(+atom) + vertex_color(+atom), + vertex_coordinates(+atom), + vertex_image(+atom), + vertex_label(+atom), + vertex_peripheries(+atom), + vertex_shape(+atom) ]). @@ -60,6 +71,8 @@ create_gif(Es, Gif, Options):- %! +Options:list(nvpair) %! ) is det. % The following options are supported: +% * =|graph_colorscheme(+oneof([none,svg,x11])) +% No default. % * =|graph_label(+LabelFunction)|= % The functions that assigns names to graphs. % No default. @@ -72,15 +85,7 @@ create_gif(Vs, Es, graph(VTerms,ETerms,GAttrs), Options):- maplist(\E^ETerm^edge_term(Vs, E, ETerm, Options), Es, ETerms), % Graph attributes. - ( - option(graph_label(LabelFunction), Options) - -> - call(LabelFunction, Graph, GraphLabel) - ; - true - ), - - merge_options([directed=true,label=GraphLabel], GAttrs). + graph_attributes(GAttrs, Options). %! edge_term( @@ -89,14 +94,69 @@ create_gif(Vs, Es, graph(VTerms,ETerms,GAttrs), Options):- %! -EdgeTerm:compound, %! +Options:list(nvpair) %! ) is det. +% The following options are supported: +% * =|edge_arrowhead(+atom)|= +% * =|edge_color(+atom)|= +% * =|edge_label(+atom)|= +% * =|edge_style(+atom)|= edge_term(Vs, E, edge(FromId,ToId,EAttrs), _):- edge_components(E, FromV, ToV), - nth0chk(FromId, Vs, FromV), nth0chk(ToId, Vs, ToV), - EAttrs = []. + % Arrowhead + if_option(edge_arrowhead(ArrowheadFunction), Options, + call(ArrowheadFunction, E, EArrowhead) + ), + + % Color. + if_option(edge_color(ColorFunction), Options, + call(ColorFunction, E, EColor) + ), + + % Label. + if_option(edge_label(LabelFunction), Options, + call(LabelFunction, E, ELabel) + ), + + % Style. + if_option(edge_style(StyleFunction), Options, + call(StyleFunction, E, EStyle) + ), + + EAttrs = [arrowHead=EArrowhead,color=EColor,label=ELabel,style=EStyle]. + + +%! graph_attributes( +%! -GraphAttributes:list(nvpair), +%! +Options:list(nvpair) +%! ) is det. +% The following options are supported: +% * =|directedness(+boolean)|= +% Whether the graph is directed (`true`) or undirected (`false`). +% Default: `false`. +% * =|graph_colorscheme(+oneof([none,svg,x11]))|= +% The colorscheme from which the color in this graph are taken. +% Default: `svg`. +% * =|graph_label(+atom)|= +% The graph label. +% No default. + +graph_attributes(GAttrs, Options):- + % Directedness. + option(directedness(Directedness), Options, false), + + % Colorscheme. + if_option(graph_colorscheme(Colorscheme), Options, true), + + % Label. + if_option(graph_label(GLabel), Options, true), + + merge_options( + [colorscheme=Colorscheme,directedness=Directedness,label=GLabel], + GAttrs + ). %! vertex_term( @@ -106,15 +166,66 @@ edge_term(Vs, E, edge(FromId,ToId,EAttrs), _):- %! +Options:list(nvpair) %! ) is det. % The following options are supported: +% * =|vertex_color(+ColorFunction)|= +% A function that assigns colors to vertices. +% No default. +% * =|vertex_coordinate(+CoordinateFunction)|= +% A function that assigns coordinates to vertices. +% No default. +% * =|vertex_image(+ImageFunction)|= +% A function that assinges images to vertices. +% No default. % * =|vertex_label(+LabelFunction)|= % A function that assigns labels to vertices. +% No default. +% * =|vertex_peripheries(+PeripheriesFunction)|= +% A function that assinges peripheries to vertices. +% No default. +% * =|vertex_shape(+ShapeFunction)|= +% A function that assinges shapes to vertices. +% No default. vertex_term(Vs, V, vertex(Id,V,VAttrs), Options):- nth0chk(Id, Vs, V), + % Color. + if_option(vertex_color(ColorFunction), Options, + call(ColorFunction, V, VColor) + ), + + % Coordinates. + %%%%if_option(vertex_coordinate(CoordinateFunction), Options, + %%%% call(CoordinateFunction, V, VCoordinates) + %%%%), + + % Image. + if_option(image(ImageFunction), Options, + call(ImageFunction, V, VImage) + ), + % Label. - option(vertex_label(LabelFunction), Options, =), - call(LabelFunction, V, VLabel), + if_option(vertex_label(LabelFunction), Options, + call(LabelFunction, V, VLabel) + ), + + % Peripheries. + if_option(vertex_peripheries(PeripheriesFunction), Options, + call(PeripheriesFunction, V, VPeripheries) + ), + + % Shape. + if_option(vertex_shape(ShapeFunction), Options, + call(ShapeFunction, V, VShape) + ), - VAttrs = [label=VLabel]. + merge_options( + [ + color=VColor, + image=VImage, + label=VLabel, + peripheries=VPeripheries, + shape=VShape + ], + VAttrs + ). ```

16: 正在比较变动前 fa364fc 和变动后 3c900f4

[back to content](#compare) ``` diff diff --git a/gv_gif.pl b/gv_gif.pl index 4a3e75f..ef2f7f2 100644 --- a/gv_gif.pl +++ b/gv_gif.pl @@ -43,7 +43,7 @@ Support for creating GIF representations. ]). :- predicate_options(graph_attributes/2, 2, [ directedness(+boolean), - graph_colorscheme(+oneof([none,svg,x11]), + graph_colorscheme(+oneof([none,svg,x11])), graph_label(+atom) ]). @@ -109,23 +109,23 @@ edge_term(Vs, E, edge(FromId,ToId,EAttrs), _):- if_option(edge_arrowhead(ArrowheadFunction), Options, call(ArrowheadFunction, E, EArrowhead) ), - % Color. if_option(edge_color(ColorFunction), Options, call(ColorFunction, E, EColor) ), - % Label. if_option(edge_label(LabelFunction), Options, call(LabelFunction, E, ELabel) ), - % Style. if_option(edge_style(StyleFunction), Options, call(StyleFunction, E, EStyle) ), - EAttrs = [arrowHead=EArrowhead,color=EColor,label=ELabel,style=EStyle]. + merge_options( + [arrowHead=EArrowhead,color=EColor,label=ELabel,style=EStyle], + EAttrs + ). %! graph_attributes( @@ -146,10 +146,8 @@ edge_term(Vs, E, edge(FromId,ToId,EAttrs), _):- graph_attributes(GAttrs, Options):- % Directedness. option(directedness(Directedness), Options, false), - % Colorscheme. if_option(graph_colorscheme(Colorscheme), Options, true), - % Label. if_option(graph_label(GLabel), Options, true), @@ -169,9 +167,6 @@ graph_attributes(GAttrs, Options):- % * =|vertex_color(+ColorFunction)|= % A function that assigns colors to vertices. % No default. -% * =|vertex_coordinate(+CoordinateFunction)|= -% A function that assigns coordinates to vertices. -% No default. % * =|vertex_image(+ImageFunction)|= % A function that assinges images to vertices. % No default. @@ -192,27 +187,18 @@ vertex_term(Vs, V, vertex(Id,V,VAttrs), Options):- if_option(vertex_color(ColorFunction), Options, call(ColorFunction, V, VColor) ), - - % Coordinates. - %%%%if_option(vertex_coordinate(CoordinateFunction), Options, - %%%% call(CoordinateFunction, V, VCoordinates) - %%%%), - % Image. if_option(image(ImageFunction), Options, call(ImageFunction, V, VImage) ), - % Label. if_option(vertex_label(LabelFunction), Options, call(LabelFunction, V, VLabel) ), - % Peripheries. if_option(vertex_peripheries(PeripheriesFunction), Options, call(PeripheriesFunction, V, VPeripheries) ), - % Shape. if_option(vertex_shape(ShapeFunction), Options, call(ShapeFunction, V, VShape) ```

17: 正在比较变动前 3c900f4 和变动后 65cc1c3

[back to content](#compare) ``` diff diff --git a/gv_gif.pl b/gv_gif.pl index ef2f7f2..6d78ac3 100644 --- a/gv_gif.pl +++ b/gv_gif.pl @@ -40,6 +40,10 @@ Support for creating GIF representations. pass_to(vertex_term/3, 3) ]). :- predicate_options(edge_term/3, 3, [ + edge_arrowhead(+atom), + edge_color(+atom), + edge_label(+atom), + edge_style(+atom) ]). :- predicate_options(graph_attributes/2, 2, [ directedness(+boolean), ```

18: 正在比较变动前 65cc1c3 和变动后 20e1f21

[back to content](#compare) ``` diff diff --git a/gv_file.pl b/gv_file.pl index 98cb0a2..25b0cd3 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -110,18 +110,14 @@ and GraphViz output files or SVG DOM structures. codes_to_gv_file(Codes, ToFile, Options):- access_file(ToFile, write), + absolute_file_name(data(tmp), TmpFile, [access(write),file_type(dot)]), setup_call_cleanup( - new_memory_file(MemFile), - ( - setup_call_cleanup( - open(MemFile, write, Write, [encoding(utf8),type(test)]), - put_codes(Write, Codes), - close(Write) - ), - file_to_gv(MemFile, ToFile, Options) - ), - free_memory_file(MemFile) - ). + open(TmpFile, write, Write, [encoding(utf8)]), + put_codes(Write, Codes), + close(Write) + ), + file_to_gv(TmpFile, ToFile, Options), + delete_file(TmpFile). %! file_to_gv(+FromFile:atom, +Options:list(nvpair)) is det. @@ -137,9 +133,6 @@ file_to_gv(FromFile, ToFile, Options):- option(to_file_type(dot), Options), !, rename_file(FromFile, ToFile). file_to_gv(FromFile, ToFile, Options):- - % The input file must be readable. - access_file(FromFile, read), - % The method option. option(method(Method), Options, dot), must_be(oneof([dot,sfdp]), Method), diff --git a/gv_gif.pl b/gv_gif.pl index 6d78ac3..e3a6933 100644 --- a/gv_gif.pl +++ b/gv_gif.pl @@ -84,10 +84,10 @@ create_gif(Es, Gif, Options):- create_gif(Vs, Es, graph(VTerms,ETerms,GAttrs), Options):- % Vertex terms. maplist(\V^VTerm^vertex_term(Vs, V, VTerm, Options), Vs, VTerms), - + % Edge terms. maplist(\E^ETerm^edge_term(Vs, E, ETerm, Options), Es, ETerms), - + % Graph attributes. graph_attributes(GAttrs, Options). @@ -104,11 +104,11 @@ create_gif(Vs, Es, graph(VTerms,ETerms,GAttrs), Options):- % * =|edge_label(+atom)|= % * =|edge_style(+atom)|= -edge_term(Vs, E, edge(FromId,ToId,EAttrs), _):- +edge_term(Vs, E, edge(FromId,ToId,EAttrs), Options):- edge_components(E, FromV, ToV), nth0chk(FromId, Vs, FromV), nth0chk(ToId, Vs, ToV), - + % Arrowhead if_option(edge_arrowhead(ArrowheadFunction), Options, call(ArrowheadFunction, E, EArrowhead) @@ -125,9 +125,9 @@ edge_term(Vs, E, edge(FromId,ToId,EAttrs), _):- if_option(edge_style(StyleFunction), Options, call(StyleFunction, E, EStyle) ), - + merge_options( - [arrowHead=EArrowhead,color=EColor,label=ELabel,style=EStyle], + [arrowhead=EArrowhead,color=EColor,label=ELabel,style=EStyle], EAttrs ). @@ -154,7 +154,7 @@ graph_attributes(GAttrs, Options):- if_option(graph_colorscheme(Colorscheme), Options, true), % Label. if_option(graph_label(GLabel), Options, true), - + merge_options( [colorscheme=Colorscheme,directedness=Directedness,label=GLabel], GAttrs @@ -186,7 +186,7 @@ graph_attributes(GAttrs, Options):- vertex_term(Vs, V, vertex(Id,V,VAttrs), Options):- nth0chk(Id, Vs, V), - + % Color. if_option(vertex_color(ColorFunction), Options, call(ColorFunction, V, VColor) @@ -207,7 +207,7 @@ vertex_term(Vs, V, vertex(Id,V,VAttrs), Options):- if_option(vertex_shape(ShapeFunction), Options, call(ShapeFunction, V, VShape) ), - + merge_options( [ color=VColor, ```

19: 正在比较变动前 20e1f21 和变动后 e2e9fc1

[back to content](#compare) ``` diff diff --git a/gv_file.pl b/gv_file.pl index 25b0cd3..2d2ed12 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -146,11 +146,8 @@ file_to_gv(FromFile, ToFile, Options):- ( var(ToFile) -> - absolute_file_name( - data(export), - ToFile, - [access(write),file_type(ToFileType)] - ) + user:prolog_file_type(ToExtension, ToFileType), + file_alternative(FromFile, _, _, ToExtension, ToFile) ; is_absolute_file_name(ToFile), % The given output file must match a certain file extension. ```

20: 正在比较变动前 e2e9fc1 和变动后 4b72d15

[back to content](#compare) ``` diff diff --git a/gv_file.pl b/gv_file.pl index 2d2ed12..9eaf66b 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -28,20 +28,16 @@ and GraphViz output files or SVG DOM structures. @version 2011-2013/09, 2013/11-2014/01, 2014/05, 2014/07 */ -:- use_module(library(memfile)). :- use_module(library(option)). :- use_module(library(process)). :- use_module(library(predicate_options)). % Declarations. :- use_module(generics(codes_ext)). :- use_module(generics(db_ext)). -:- use_module(generics(error_ext)). -:- use_module(generics(trees)). :- use_module(os(file_ext)). :- use_module(os(run_ext)). :- use_module(os(safe_file)). :- use_module(svg(svg_file)). -:- use_module(ugraph(ugraph_export)). :- use_module(plGraphViz(gv_dot)). diff --git a/gv_gif.pl b/gv_gif.pl index e3a6933..48ecd2f 100644 --- a/gv_gif.pl +++ b/gv_gif.pl @@ -27,7 +27,7 @@ Support for creating GIF representations. :- use_module(generics(list_ext)). :- use_module(generics(option_ext)). -:- use_module(graph_theory(graph_generic)). +:- use_module(graph_theory(graph_theory)). :- use_module(plRdf(rdf_name)). % Meta-DCG. ```

21: 正在比较变动前 4b72d15 和变动后 54248f7

[back to content](#compare) ``` diff diff --git a/gv_gif.pl b/gv_gif.pl index 48ecd2f..2fad4c4 100644 --- a/gv_gif.pl +++ b/gv_gif.pl @@ -105,7 +105,7 @@ create_gif(Vs, Es, graph(VTerms,ETerms,GAttrs), Options):- % * =|edge_style(+atom)|= edge_term(Vs, E, edge(FromId,ToId,EAttrs), Options):- - edge_components(E, FromV, ToV), + edge(E, FromV, ToV), nth0chk(FromId, Vs, FromV), nth0chk(ToId, Vs, ToV), ```

22: 正在比较变动前 54248f7 和变动后 3b9a773

[back to content](#compare) ``` diff diff --git a/gv_gif.pl b/gv_gif.pl index 2fad4c4..48ecd2f 100644 --- a/gv_gif.pl +++ b/gv_gif.pl @@ -105,7 +105,7 @@ create_gif(Vs, Es, graph(VTerms,ETerms,GAttrs), Options):- % * =|edge_style(+atom)|= edge_term(Vs, E, edge(FromId,ToId,EAttrs), Options):- - edge(E, FromV, ToV), + edge_components(E, FromV, ToV), nth0chk(FromId, Vs, FromV), nth0chk(ToId, Vs, ToV), ```

23: 正在比较变动前 3b9a773 和变动后 1e9a910

[back to content](#compare) ``` diff diff --git a/gv_gif.pl b/gv_gif.pl index 48ecd2f..d59e5f8 100644 --- a/gv_gif.pl +++ b/gv_gif.pl @@ -65,7 +65,7 @@ Support for creating GIF representations. %! create_gif(+Edges:ordset, -Gif:compound, +Options:list(nvpair)) is det. create_gif(Es, Gif, Options):- - edges_to_vertices(Es, Vs), + graph_theory:edges_to_vertices(Es, Vs), create_gif(Vs, Es, Gif, Options). %! create_gif( @@ -105,7 +105,7 @@ create_gif(Vs, Es, graph(VTerms,ETerms,GAttrs), Options):- % * =|edge_style(+atom)|= edge_term(Vs, E, edge(FromId,ToId,EAttrs), Options):- - edge_components(E, FromV, ToV), + graph_theory:edge_components(E, FromV, ToV), nth0chk(FromId, Vs, FromV), nth0chk(ToId, Vs, ToV), ```

24: 正在比较变动前 1e9a910 和变动后 6dc1cf5

[back to content](#compare) ``` diff diff --git a/.gitignore b/.gitignore index b25c15b..bd24270 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *~ +*# +*.db diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index a63cbff..0000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "Prolog-Library-Collection"] - path = Prolog-Library-Collection - url = https://github.com/wouterbeek/Prolog-Library-Collection.git -[submodule "plHtml"] - path = plHtml - url = https://github.com/wouterbeek/plHtml.git diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..c7b7798 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Wouter Beek + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection deleted file mode 160000 index 5b34b01..0000000 --- a/Prolog-Library-Collection +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5b34b01ab0cc82a56e6fd90fc26e75da22f5a0fe diff --git a/README.md b/README.md new file mode 100644 index 0000000..23a45db --- /dev/null +++ b/README.md @@ -0,0 +1,151 @@ +plGraphViz +========== + +This library allows you to easily export graphs represented as Prolog terms +using [GraphViz](http://www.graphviz.org/), an advanced graph drawing library. +The Prolog terms have the following form: + +~~~prolog +graph(Vertices, Edges, GraphAttrs) +~~~ + +`Vertices` and `Edges` are lists of compound terms of the following form: + +~~~prolog +vertex(Id, VertexAttrs) +edge(FromId, ToId, EdgeAttrs) +~~~ + +`Id` identifies a vertex and may or may not occur in any of the edges +(i.e., unconnected vertices are allowed). +`FromId` and `ToId` may occur in the list of vertices, +in order to draw an edge between vertices with set attributes. + +Attributes have the form `Name=Value`. +`GraphAttrs` are attributes of the graph. +`VertexAttrs` are attributes of the vertex. +`EdgeAttrs` are attributes of the edge. + +Attribute values are given as Prolog terms as well, +and are type-checked before exporting. +Many of the GraphViz attributes are supported. +New ones are added on an as-needed bases +(open an issue on Github if you want to see a specific feature added!). +HTML-like labels are supported, allowing complex tables to be shown +inside vertices. + +--- + +### Installation + +~~~shell +$ git clone https://github.com/wouterbeek/plGraphViz.git +$ cd plGraphViz +$ git submodule update --init +~~~ + +### Example + +~~~prolog +$ swipl run.pl +?- export_graph_to_gv_file( + graph([vertex(1,[]),vertex(2,[])],[edge(1,2,[])],[]), + File, + [method(sfdp),output(png)] + ). + File = 'PATH/plGraphViz/data/tmp.png' +~~~ + +![](https://raw.githubusercontent.com/wouterbeek/plGraphViz/master/example1.png "Example graph.") + +The graphic can be saved to a different file by instantiating +the `File` argument. + +--- + +### 'Method' option + +Option `method(+atom)` sets the drawing method that is used by GraphViz + to place the vertices and edges. +The following values are supported. + +| **Value** | **Description** | +| `circo` | Circular layout. | +| `dot` (default) | Directed graph. | +| `fdp` | Undirected graph. | +| `neato` | Undirected graph. | +| `osage` | Tree map. | +| `sfdp` | Large undirected graph. | +| `twopi` | Radical layouts. | + +--- + +### 'Output' option + +Option `output(+atom)` sets the type of file the graph is written to. +The following values are supported. + +| **Value** | **Description** | +|:---------------------:|:--------------------------------------| +| `bmp` | Windows Bitmap Format | +| `canon` | | +| `dot` | | +| `gv`, `xdot`, `xdot1.2`, `xdot1.4` | DOT | +| `cgimage` | CGImage bitmap format | +| `cmap` | Client-side imagemap (deprecated) | +| `eps` | Encapsulated PostScript | +| `exr` | OpenEXR | +| `fig` | | +| `gd`, `gd2` | GD/GD2 formats | +| `gif` | | +| `gtk` | GTK canvas | +| `ico` | Icon Image File Format | +| `imap` | | +| `cmapx` | Server-side and client-side imagemaps | +| `imap_np`, `cmapx_np` | Server-side and client-side imagemaps | +| `ismap` | Server-side imagemap (deprecated) | +| `jp2` | JPEG 2000 | +| `jpg`, `jpeg`, `jpe` | JPEG | +| `pct`, `pict` | PICT | +| `pdf` (default) | Portable Document Format (PDF) | +| `pic` | Kernighan's PIC graphics language | +| `plain`, `plain-ext` | Simple text format | +| `png` | Portable Network Graphics format | +| `pov` | POV-Ray markup language (prototype) | +| `ps` | PostScript | +| `ps2` | PostScript for PDF | +| `psd` | PSD | +| `sgi` | SGI | +| `svg`, `svgz` | Scalable Vector Graphics | +| `tga` | Truevision TGA | +| `tif`, `tiff` | TIFF (Tag Image File Format) | +| `tk` | TK graphics | +| `vml`, `vmlz` | Vector Markup Language (VML) | +| `vrml` | VRML | +| `wbmp` | Wireless BitMap format | +| `webp` | Image format for the Web | +| `xlib`, `x11` | Xlib canvas | + +--- + +### HTML-like labels + +Example of using HTML-like labels: + +~~~prolog +export_graph_to_gv_file( + graph( + [vertex(1,[]),vertex(2,[label=html(table([tr([td(a),td(b)]),tr([td(c),td(d)])]))])], + [edge(1,2,[label='From 1 to 2.'])], + [] + ), + File, + [] +). +~~~ + +![](https://raw.githubusercontent.com/wouterbeek/plGraphViz/master/example2.png "Example graph with HTML-like labels.") + +--- + +Developed during 2013-2014 by [Wouter Beek](http://www.wouterbeek.com). diff --git a/data/gv_attrs_scrape.pl b/data/gv_attrs_scrape.pl new file mode 100644 index 0000000..bcc7654 --- /dev/null +++ b/data/gv_attrs_scrape.pl @@ -0,0 +1,119 @@ +:- module( + gv_attrs_scrape, + [ + gv_attrs_scrape/1 % +File + ] +). + +/** GraphViz: Scrape attributes + +Writes compound terms of the following form to file: + +```prolog +gv_attr( + ?Name, + ?UsedBy:list(oneof([cluster,edge,graph,node,subgraph])), + ?Types:list(atom), + ?Default, + ?Minimum, + ?Notes +) is nondet. +``` + +@author Wouter Beek +@version 2015/10, 2016/07 +*/ + +:- use_module(library(apply)). +:- use_module(library(dcg/dcg_ext)). +:- use_module(library(debug)). +:- use_module(library(gv/gv_attr_type)). +:- use_module(library(http/http_download)). +:- use_module(library(lists)). +:- use_module(library(os/io)). +:- use_module(library(pl_term)). +:- use_module(library(print_ext)). +:- use_module(library(xpath)). +:- use_module(library(xpath/xpath_table)). +:- use_module(library(yall)). + + + + + +%! gv_attrs_scrape(+File) is det. + +gv_attrs_scrape(File):- + debug(gv, "Updating the GraphViz attributes table.", []), + call_to_stream(File, [In,Meta,Meta]>>gv_attrs_download(In)). + + +gv_attrs_download(Write):- + gv_attrs_iri(Iri), + html_download(Iri, Dom), + xpath_chk(Dom, //table(@align=lower_case(center)), TableDom), + xpath_table(TableDom, _, Rows), + maplist(write_attr_row(Write), Rows). + + +write_attr_row(Write, [Name,UsedBy1,Types1,Default1,Minimum,Notes]):- + atom_phrase(translate_usedby(UsedBy2), UsedBy1), + once(atom_phrase(translate_type(Types2), Types1)), + sort(UsedBy2, UsedBy3), + translate_default(Default1, Default2), + with_output_to( + Write, + write_fact(gv_attr(Name, UsedBy3, Types2, Default2, Minimum, Notes)) + ). + +gv_attrs_iri('http://www.graphviz.org/doc/info/attrs.html'). + + + + + +% HELPERS % + +%! translate_default(+Default1, -Default2) is det. + +% The empty string is represented by the empty atom. +translate_default('""', ''):- !. +% The absence of a default value is represented by an uninstantiated variable. +translate_default('', _):- !. +translate_default(Default, Default). + + + +%! translate_type(-Types:list(atom))// is det. + +translate_type([H|T]) --> + gv_attr_type(H), + whites, + translate_type(T). +translate_type([H]) --> + gv_attr_type(H). +translate_type([]) --> "". + + + +%! translated_usedby( +%! -UsedBy:list(oneof([cluster,edge,graph,node,subgraph])) +%! )// is det. + +translate_usedby([cluster|T]) --> + "C", !, + translate_usedby(T). +translate_usedby([edge|T]) --> + "E", !, + translate_usedby(T). +translate_usedby([graph|T]) --> + "G", !, + translate_usedby(T). +translate_usedby([node|T]) --> + "N", !, + translate_usedby(T). +translate_usedby([subgraph|T]) --> + "S", !, + translate_usedby(T). +translate_usedby([]) --> + "". diff --git a/data/gv_color_scrape.pl b/data/gv_color_scrape.pl new file mode 100644 index 0000000..102a02a --- /dev/null +++ b/data/gv_color_scrape.pl @@ -0,0 +1,52 @@ +:- module( + gv_color_scrape, + [ + gv_color_scrape/1 % +File + ] +). + +/** GraphViz: Scrape colors + +@author Wouter Beek +@version 2015/10, 2016/07 +*/ + +:- use_module(library(apply)). +:- use_module(library(debug)). +:- use_module(library(http/http_download)). +:- use_module(library(lists)). +:- use_module(library(os/io)). +:- use_module(library(pl_term)). +:- use_module(library(print_ext)). +:- use_module(library(xpath)). +:- use_module(library(xpath/xpath_table)). +:- use_module(library(yall)). + + + + + +%! gv_color_scrape(+File) is det. + +gv_color_scrape(File):- + debug(io, "Updating the GraphViz color table.", []), + call_to_stream(File, [In,Meta,Meta]>>gv_color_download(In)). + + +gv_color_download(Write):- + gv_color_iri(Iri), + html_download(Iri, Dom), + xpath_chk(Dom, //table(1), TableDom1), + xpath_chk(Dom, //table(2), TableDom2), + maplist(write_color_table(Write), [x11,svg], [TableDom1,TableDom2]). + + +write_color_table(Write, Colorscheme, TableDom):- + xpath_table(TableDom, _, Rows), + append(Rows, Cells), + forall( + member(Cell, Cells), + with_output_to(Write, write_fact(gv_color(Colorscheme, Cell))) + ). + +gv_color_iri('http://www.graphviz.org/doc/info/colors.html'). diff --git a/example1.png b/example1.png new file mode 100644 index 0000000..31e7ba6 Binary files /dev/null and b/example1.png differ diff --git a/example2.png b/example2.png new file mode 100644 index 0000000..6e44b16 Binary files /dev/null and b/example2.png differ diff --git a/gv_attr_type.pl b/gv_attr_type.pl deleted file mode 100644 index 7a64c82..0000000 --- a/gv_attr_type.pl +++ /dev/null @@ -1,417 +0,0 @@ -:- module( - gv_attr_type, - [ - gv_attr_type/1, % ?Type:atom - addDouble//1, % +Double:float - addPoint//1, % +Point:compound - arrowType//1, % +ArrowType:atom - bool//1, % +Boolean:boolean - clusterMode//1, % +ClusterMode:atom - dirType//1, % +DirectionType:oneof([back,both,forward,none]) - double//1, % +Double:float - doubleList//1, % +Doubles:list(float) - escString//1, - %layerList//1, - %layerRange//1, - lblString//1, - int//1, % +Integer:integer - outputMode//1, % +OutputMode:atom - %packMode//1, - pagedir//1, % +Pagedir:atom - point//1, % +Point:compound - pointList//1, % +Points:list(compound) - %portPos//1, - quadType//1, % +QuadType:atom - rankType//1, % +RankType:atom - rankdir//1, % +RankDirection:atom - rect//1, % +Rectangle:compound - shape//1, - smoothType//1, % +SmoothType:atom - %splineType//1, - %startType//1, - string//1, % ?Content:atom - style//2 % +Context:oneof([cluster,edge,node]) - % +Style:atom - %viewPort//1 - ] -). -:- reexport( - plGraphViz(gv_color), - [ - color//1, % +Color:compound - colorList//1 % +ColorList:list(compound) - ] -). - -/** GraphViz attribute types - -@author Wouter Beek -@version 2014/06 -*/ - -:- use_module(dcg(dcg_abnf)). -:- use_module(dcg(dcg_cardinal)). -:- use_module(dcg(dcg_content)). - -:- use_module(plGraphViz(gv_html)). - - - -%! gv_attr_type(?Type:atom) is nondet. - -gv_attr_type(addDouble). -gv_attr_type(addPoint). -gv_attr_type(arrowType). -gv_attr_type(bool). -gv_attr_type(color). -gv_attr_type(colorList). -gv_attr_type(clusterMode). -gv_attr_type(dirType). -gv_attr_type(double). -gv_attr_type(doubleList). -gv_attr_type(escString). -gv_attr_type(layerList). -gv_attr_type(layerRange). -gv_attr_type(lblString). -gv_attr_type(int). -gv_attr_type(outputMode). -gv_attr_type(packMode). -gv_attr_type(pagedir). -gv_attr_type(point). -gv_attr_type(pointList). -gv_attr_type(portPos). -gv_attr_type(quadType). -gv_attr_type(rankType). -gv_attr_type(rankdir). -gv_attr_type(rect). -gv_attr_type(shape). -gv_attr_type(smoothType). -gv_attr_type(splineType). -gv_attr_type(startType). -gv_attr_type(string). -gv_attr_type(style). -gv_attr_type(viewPort). - - -%! addDouble(+Float:float)// . -% An *addDouble* is represented by a Prolog float. - -addDouble(Float) --> - '?'(`+`), - double(Float). - - -%! addPoint(+Point:compound)// . -% An *addPoint* is represented by a compound of the following form: -% `point(X:float,Y:float,InputOnly:boolean)`. - -addPoint(Point) --> - '?'(`+`), - point(Point). - - -%! arrowType(+ArrowType:atom)// . - -arrowType(V) --> - {arrowType(V)}, - atom(V). - -arrowType(V):- - primitive_shape(V). -arrowType(V):- - derived(V). -arrowType(V):- - backwards_compatible(V). - -primitive_shape(box). -primitive_shape(crow). -primitive_shape(circle). -primitive_shape(diamond). -primitive_shape(dot). -primitive_shape(inv). -primitive_shape(none). -primitive_shape(normal). -primitive_shape(tee). -primitive_shape(vee). - -derived(odot). -derived(invdot). -derived(invodot). -derived(obox). -derived(odiamond). - -backwards_compatible(ediamond). -backwards_compatible(empty). -backwards_compatible(halfopen). -backwards_compatible(invempty). -backwards_compatible(open). - - -bool(false) --> `false`. -bool(false) --> `no`. -bool(true) --> `true`. -bool(true) --> `yes`. - - -%! clusterMode(+ClusterMode:atom)// . - -clusterMode(V) --> - {clusterMode(V)}, - atom(V). - -clusterMode(global). -clusterMode(local). -clusterMode(none). - - -%! dirType(+DirectionType:oneof([back,both,forward,none]))// . - -dirType(DirType) --> - {dirType(DirType)}, - atom(DirType). - -dirType(back). -dirType(both). -dirType(forward). -dirType(none). - - -double(Double1) --> - % float//1 will check for float type. - {Double2 is Double1 * 1.0}, - float(Double2). - - -doubleList([H|T]) --> - double(H), - '*'(doubleList1, T). - -doubleList1(Float) --> - `:`, - double(Float). - - -%! escString(+String:atom)// . -% @tbd Support for context-dependent replacements. - -escString(String) --> - atom(String). - - -% @tbd layerList - - -% @tbd layerRange - - -lblString(V) --> - escString(V). -lblString(V) --> - gv_html_like_label(V). - - -int(V) --> - integer(V). - - -outputMode(V) --> - {outputMode(V)}, - atom(V). - -outputMode(breadthfirst). -outputMode(edgesfirst). -outputMode(nodesfirst). - - -% @tbd packMode - - -pagedir(V) --> - {pagedir(V)}, - atom(V). - -pagedir('BL'). -pagedir('BR'). -pagedir('LB'). -pagedir('LT'). -pagedir('RB'). -pagedir('RT'). -pagedir('TL'). -pagedir('TR'). - - -%! point(+Point:compound)// . -% A *point* is represented by a compound of the following form: -% `point(X:float,Y:float,InputOnly:boolean)`. - -point(point(X,Y,InputOnly)) --> - float(X), - `,`, - float(Y), - input_only(InputOnly). - -input_only(false) --> []. -input_only(true) --> `!`. - - -pointList(Points) --> - '*'(point, Points). - - -% @tbd portPos - - -quadType(V) --> - {quadType(V)}, - atom(V). - -quadType(fast). -quadType(none). -quadType(normal). - - -rankType(V) --> - {rankType(V)}, - atom(V). - -rankType(max). -rankType(min). -rankType(same). -rankType(sink). -rankType(source). - - -rankdir(V) --> - {rankdir(V)}, - atom(V). - -rankdir('BT'). -rankdir('LR'). -rankdir('RL'). -rankdir('TB'). - - -rect(rect(LowerLeftX,LowerLeftY,UpperRightX,UpperRightY)) --> - float(LowerLeftX), `,`, - float(LowerLeftY), `,`, - float(UpperRightX), `,`, - float(UpperRightY). - - -shape(V) --> - {polygon_based_shape(V)}, - atom(V). - -polygon_based_shape(assembly). -polygon_based_shape(box). -polygon_based_shape(box3d). -polygon_based_shape(cds). -polygon_based_shape(circle). -polygon_based_shape(component). -polygon_based_shape(diamond). -polygon_based_shape(doublecircle). -polygon_based_shape(doubleoctagon). -polygon_based_shape(egg). -polygon_based_shape(ellipse). -polygon_based_shape(fivepoverhang). -polygon_based_shape(folder). -polygon_based_shape(hexagon). -polygon_based_shape(house). -polygon_based_shape(insulator). -polygon_based_shape(invhouse). -polygon_based_shape(invtrapezium). -polygon_based_shape(invtriangle). -polygon_based_shape(larrow). -polygon_based_shape(lpromoter). -polygon_based_shape('Mcircle'). -polygon_based_shape('Mdiamond'). -polygon_based_shape('Msquare'). -polygon_based_shape(none). -polygon_based_shape(note). -polygon_based_shape(noverhang). -polygon_based_shape(octagon). -polygon_based_shape(oval). -polygon_based_shape(parallelogram). -polygon_based_shape(pentagon). -polygon_based_shape(plaintext). -polygon_based_shape(point). -polygon_based_shape(polygon). -polygon_based_shape(primersite). -polygon_based_shape(promoter). -polygon_based_shape(proteasesite). -polygon_based_shape(proteinstab). -polygon_based_shape(rarrow). -polygon_based_shape(rect). -polygon_based_shape(rectangle). -polygon_based_shape(restrictionsite). -polygon_based_shape(ribosite). -polygon_based_shape(rnastab). -polygon_based_shape(rpromoter). -polygon_based_shape(septagon). -polygon_based_shape(signature). -polygon_based_shape(square). -polygon_based_shape(tab). -polygon_based_shape(terminator). -polygon_based_shape(threepoverhang). -polygon_based_shape(trapezium). -polygon_based_shape(triangle). -polygon_based_shape(tripleoctagon). -polygon_based_shape(utr). - - -smoothType(V) --> - {smoothType(V)}, - atom(V). - -smoothType(avg_dist). -smoothType(graph_dist). -smoothType(none). -smoothType(power_dist). -smoothType(rng). -smoothType(spring). -smoothType(triangle). - - -% @tbd splineType - - -% @tbd startType - - -%! string(?Content:atom)// . -% A GraphViz string. - -string(Content) --> - atom(Content). - - -%! style(?Context:oneof([cluster,edge,node]), ?Style:atom) is nondet. - -style(Context, Style) --> - {style(Context, Style)}, - atom(Style). - -style(cluster, bold). -style(cluster, dashed). -style(cluster, dotted). -style(cluster, filled). -style(cluster, rounded). -style(cluster, solid). -style(cluster, striped). -style(edge, bold). -style(edge, dashed). -style(edge, dotted). -style(edge, solid). -style(node, bold). -style(node, dashed). -style(node, diagonals). -style(node, dotted). -style(node, filled). -style(node, rounded). -style(node, solid). -style(node, striped). -style(node, wedged). - - -% @tbd viewPort - diff --git a/gv_attrs.pl b/gv_attrs.pl deleted file mode 100644 index dd0145a..0000000 --- a/gv_attrs.pl +++ /dev/null @@ -1,184 +0,0 @@ -:- module( - gv_attrs, - [ - gv_attr/3 % +Context:oneof([cluster,edge,graph,node,subgraph]) - % +Attr1:nvpair - % +Attr2:nvpair - ] -). - -/** GraphViz attributes v2 - -@author Wouter Beek -@version 2014/06 -*/ - -:- use_module(library(apply)). -:- use_module(library(persistency)). -:- use_module(library(xpath)). - -:- use_module(dcg(dcg_content)). -:- use_module(dcg(dcg_generic)). -:- use_module(generics(db_ext)). -:- use_module(os(file_ext)). - -:- use_module(plHtml(html)). -:- use_module(plHtml(html_table)). - -:- use_module(plGraphViz(gv_attr_type)). % DCGs implementing attribute types. - -:- db_add_novel(user:prolog_file_type(log, logging)). - -%! gv_attr( -%! ?Name:atom, -%! ?UsedBy:list(oneof([cluster,edge,graph,node,subgraph])), -%! ?Types:list(atom), -%! ?Default, -%! ?Minimum, -%! ?Notes:atom -%! ) is nondet. - -:- persistent( - gv_attr( - name:atom, - used_by:list(oneof([cluster,edge,graph,node,subgraph])), - types:list(atom), - default, - minimum, - notes:atom - ) -). - -:- initialization(gv_attrs_init). - - - -gv_attr(Context, N=V, N=V):- - var(V), !, - gv_attr(N, UsedBy, _, V, _, _), - memberchk(Context, UsedBy). -gv_attr(Context, N=V1, N=V2):- - gv_attr(N, UsedBy, Types, _, Minimum, _), - memberchk(Context, UsedBy), - member(Type, Types), - ( - Type == style - -> - Dcg =.. [Type,Context,V1] - ; - Dcg =.. [Type,V1] - ), - once(dcg_phrase(Dcg, V2)), - check_minimum(V1, Minimum). - -check_minimum(_, ''):- !. -check_minimum(V, Min1):- - atom_number(Min1, Min2), - Min2 =< V. - - - -% INITIALIZATION - -%! assert_gv_attr_row(+Row:list(atom)) is det. - -assert_gv_attr_row([Name,UsedBy1,Types1,Default1,Minimum,Notes]):- - dcg_phrase(translate_usedby(UsedBy2), UsedBy1), - once(dcg_phrase(translate_type(Types2), Types1)), - sort(UsedBy2, UsedBy3), - translate_default(Default1, Default2), - assert_gv_attr(Name, UsedBy3, Types2, Default2, Minimum, Notes). - - -%! gv_attrs_downloads is det. -% Downloads the table describing GraphViz attributes from `graphviz.org`. - -gv_attrs_download:- - gv_attrs_url(Url), - download_html(Url, Dom, [html_dialect(html4),verbose(silent)]), - - xpath(Dom, //table(@align=center), TableDom), - % @tbd This does not work, since in `record_name(Element, Name)`, - % `Element` is a signleton list whereas a compound term is expected. - %%%%xpath(Dom, /html/body/table, TableDom), - - html_to_table(TableDom, _, Rows), - maplist(assert_gv_attr_row, Rows). - - -%! gv_attrs_file(-File:atom) is det. - -gv_attrs_file(File):- - absolute_file_name( - data(gv_attrs), - File, - [access(write),file_type(logging)] - ). - - -%! gv_attrs_init is det. - -gv_attrs_init:- - gv_attrs_file(File), - safe_db_attach(File), - file_age(File, Age), - gv_attrs_update(Age). - - -%! gv_attrs_update(+Age:float) is det. - -% The persistent store is still fresh. -gv_attrs_update(Age):- - once(gv_attr(_, _, _, _, _, _)), - Age < 8640000, !. -% The persistent store has become stale, so refresh it. -gv_attrs_update(_):- - retractall_gv_attr(_, _, _, _, _, _), - gv_attrs_download. - - -%! gv_attrs_url(-Url:url) is det. - -gv_attrs_url('http://www.graphviz.org/doc/info/attrs.html'). - - -%! safe_db_attach(+File:atom) is det. - -safe_db_attach(File):- - exists_file(File), !, - db_attach(File, []). -safe_db_attach(File):- - touch_file(File), - safe_db_attach(File). - - -%! translate_default(+Default1:atom, -Default2:atom) is det. - -% The empty string is represented by the empty atom. -translate_default('""', ''):- !. -% The absence of a default value is represented by an uninstantiated variable. -translate_default('', _):- !. -translate_default(Default, Default). - - -%! translate_type(-Types:list(atom))// is det. - -translate_type([H|T]) --> - {gv_attr_type(H)}, - atom(H), - whites, - translate_type(T). -translate_type([]) --> !, []. - - -%! translated_usedby( -%! -UsedBy:list(oneof([cluster,edge,graph,node,subgraph])) -%! )// is det. - -translate_usedby([cluster|T]) --> `C`, !, translate_usedby(T). -translate_usedby([edge|T]) --> `E`, !, translate_usedby(T). -translate_usedby([graph|T]) --> `G`, !, translate_usedby(T). -translate_usedby([node|T]) --> `N`, !, translate_usedby(T). -translate_usedby([subgraph|T]) --> `S`, !, translate_usedby(T). -translate_usedby([]) --> []. - diff --git a/gv_color.pl b/gv_color.pl deleted file mode 100644 index 19d6e05..0000000 --- a/gv_color.pl +++ /dev/null @@ -1,151 +0,0 @@ -:- module( - gv_color, - [ - gv_color/2, % ?Colorscheme:oneof([svg,x11]) - % ?Color:atom - color//1, % +Color:compound - colorList//1 % +Pairs:list(pair(compound,float)) - ] -). - -/** GraphViz color - -@author Wouter Beek -@tbd Color value `transparent` is only available in the output formats - ps, svg, fig, vmrl, and the bitmap formats. -@version 2014/06 -*/ - -:- use_module(library(apply)). -:- use_module(library(lists)). -:- use_module(library(persistency)). -:- use_module(library(xpath)). - -:- use_module(dcg(dcg_abnf)). -:- use_module(dcg(dcg_cardinal)). -:- use_module(dcg(dcg_content)). -:- use_module(generics(db_ext)). -:- use_module(os(file_ext)). -:- use_module(sparql(sparql_char)). - -:- use_module(plHtml(html)). -:- use_module(plHtml(html_table)). - -:- db_add_novel(user:prolog_file_type(log, logging)). - -%! gv_color(?Colorscheme:oneof([svg,x11]), ?Color:atom) is nondet. - -:- persistent(gv_color(colorscheme:oneof([svg,x11]),color:atom)). - -:- initialization(gv_color_init). - - - -% color(+Color:compound)// . -% A *color* is represented by a compound term of one of the following forms: -% 1. `rgb(Red:nonneg,Green:nonneg,Blue:nonneg)` -% 2. `rgba(Red:nonneg,Green:nonneg,Blue:nonneg,Alpha:nonneg)` -% 3. `hsv(Hue:between(0.0,1.0),Saturation:between(0.0,1.0),Value:between(0.0,1.0))` - -color(rgb(Red,Green,Blue)) --> !, - `#`, - '#'(3, hex_color, [Red,Green,Blue]). -color(rgbs(Red,Green,Blue,Alpha)) --> !, - `#`, - '#'(4, hex_color, [Red,Green,Blue,Alpha]). -color(hsv(Hue,Saturation,Value)) --> !, - '#'(3, hsv_color, [Hue,Saturation,Value]). -color(Name) --> - {gv_color(_, Name)}, - atom(Name). - -hex_color(I) --> - {W1 is I / 16}, - 'HEX'(W1), - {W2 is I mod 16}, - 'HEX'(W2). - -hsv_color(D, Head, Tail):- - format(codes(Head,Tail), '~2f', [D]). - - -%! colorList(+Pairs:list(pair(compound,float)))// . - -colorList(Pairs) --> - '+'(wc, Pairs). - -wc(Color-Float) --> - color(Color), - '?'(wc_weight(Float)). - -wc_weight(Float) --> - `;`, - float(Float). - - - -% INITIALIZATION - -%! gv_color_download is det. - -gv_color_download:- - gv_color_url(Url), - download_html(Url, Dom, [html_dialect(html4),verbose(silent)]), - xpath(Dom, //table(1), TableDom1), - xpath(Dom, //table(2), TableDom2), - maplist(assert_color_table, [x11,svg], [TableDom1,TableDom2]). - -assert_color_table(Colorscheme, TableDom):- - html_to_table(TableDom, _, Rows), - append(Rows, Cells), - forall( - member(Cell, Cells), - assert_gv_color(Colorscheme, Cell) - ). - - -%! gv_color_file(-File:atom) is det. - -gv_color_file(File):- - absolute_file_name( - data(gv_color), - File, - [access(write),file_type(logging)] - ). - - -%! gv_color_init is det. - -gv_color_init:- - gv_color_file(File), - safe_db_attach(File), - file_age(File, Age), - gv_color_update(Age). - - -%! gv_color_update(+Age:float) is det. - -% The persistent store is still fresh. -gv_color_update(Age):- - once(gv_color(_, _)), - Age < 8640000, !. -% The persistent store has become stale, so refresh it. -gv_color_update(_):- - retractall_gv_color(_, _), - gv_color_download. - - -%! gv_color_url(-Url:url) is det. - -gv_color_url('http://www.graphviz.org/doc/info/colors.html'). - - -%! safe_db_attach(+File:atom) is det. - -safe_db_attach(File):- - exists_file(File), !, - db_attach(File, []). -safe_db_attach(File):- - touch_file(File), - safe_db_attach(File). - diff --git a/gv_dot.pl b/gv_dot.pl deleted file mode 100644 index 68443ba..0000000 --- a/gv_dot.pl +++ /dev/null @@ -1,496 +0,0 @@ -:- module( - gv_dot, - [ - gv_graph//1 % +GraphTerm:compound - ] -). - -/** GraphViz DOT generator - -DCG rules for GraphViz DOT file generation. - -Methods for writing to the GraphViz DOT format. - -In GraphViz vertices are called 'nodes'. - -@author Wouter Beek -@see http://www.graphviz.org/content/dot-language -@version 2013/07, 2013/09, 2014/03-2014/06 -*/ - -:- use_module(library(apply)). -:- use_module(library(lists)). -:- use_module(library(ordsets)). - -:- use_module(dcg(dcg_abnf)). -:- use_module(dcg(dcg_ascii)). -:- use_module(dcg(dcg_content)). -:- use_module(dcg(dcg_generic)). -:- use_module(dcg(dcg_meta)). -:- use_module(dcg(dcg_os)). - -:- use_module(plGraphViz(gv_attrs)). -:- use_module(plGraphViz(gv_html)). -:- use_module(plGraphViz(gv_numeral)). - - - -%! gv_attribute(+Attribute:nvpair)// is det. -% A single GraphViz attribute. -% We assume that the attribute has already been validated. - -gv_attribute(Name=Val) --> - gv_id(Name), `=`, gv_id(Val), `;`. - - -%! gv_attribute_list( -%! +Context:oneof([cluster,edge,graph,node,subgraph]), -%! +GraphAttributes:list(nvpair), -%! +Attributes:list(nvpair) -%! )// . -% ~~~{.abnf} -% attr_list = "[" [a_list] "]" [attr_list] -% a_list = ID "=" ID [","] [a_list] -% ~~~ - -% Attributes occur between square brackets. -gv_attribute_list(Context, _, Attrs1) --> - {maplist(gv_attr(Context), Attrs1, Attrs2)}, - bracketed(square, '*'(gv_attribute, Attrs2)). - - -%! gv_compass_pt(+Direction:oneof(['_',c,e,n,ne,nw,s,se,sw,w]))// . -% ~~~ -% compass_pt : (n | ne | e | se | s | sw | w | nw | c | _) -% ~~~ - -gv_compass_pt('_') --> `_`. -gv_compass_pt(c) --> `c`. -gv_compass_pt(e) --> `e`. -gv_compass_pt(n) --> `n`. -gv_compass_pt(ne) --> `ne`. -gv_compass_pt(nw) --> `nw`. -gv_compass_pt(s) --> `s`. -gv_compass_pt(se) --> `se`. -gv_compass_pt(sw) --> `sw`. -gv_compass_pt(w) --> `w`. - - -%! gv_edge_operator(+Directedness:boolean)// . -% The binary edge operator between two vertices. -% The operator that is used depends on whether the graph is directed or -% undirected. -% -% @arg Directedness Whether an edge is directed (operator `->`) or -% undirected (operator `--`). - -gv_edge_operator(false) --> !, `--`. -gv_edge_operator(true) --> arrow(right, 2). - - -%! gv_edge_statement( -%! +Indent:nonneg, -%! +Directedness:boolean, -%! +GraphAttributes:list(nvpair), -%! +EdgeTerm:compound -%! )// is det. -% A GraphViz statement describing an edge. -% -% @arg Indent The indentation level at which the edge statement is written. -% @arg Directedness Whether the graph is directed or not. -% @arg GraphAttributes The attributes of the graph. Some of these attributes -% may be used in the edge statement (e.g., the colorscheme). -% @arg EdgeTerm A compound term in the GIFormat, representing an edge. -% -% @tbd Instead of gv_node_id//1 we could have a gv_subgraph//1 -% at the from and/or to location. -% @tbd Add support for multiple, consecutive occurrences of gv_edge_rhs//2. - -gv_edge_statement(I, Directedness, GAttrs, edge(FromId,ToId,EAttrs)) --> - indent(I), - gv_node_id(FromId), ` `, - - gv_edge_operator(Directedness), ` `, - - gv_node_id(ToId), ` `, - - % We want `colorscheme/1` from the edges and - % `directionality/1` from the graph. - gv_attribute_list(edge, GAttrs, EAttrs), - newline. - - -%! gv_generic_attributes_statement( -%! +Kind:oneof([edge,graph,node]), -%! +Indent:integer, -%! +GraphAttributes:list(nvpair), -%! +CategoryAttributes:list(nvpair) -%! )// -% A GraphViz statement describing generic attributes for a category of items. -% -% @arg Kind The category of items for to the attributes apply. -% Possible values: `edge`, `graph`, and `node`. -% @arg Indent An integer indicating the number of tabs. -% @arg GraphAttributes A list of name-value pairs. -% @arg CategoryAttributes A list of name-value pairs. -% -% ~~~ -% attr_stmt = (graph / node / edge) attr_list -% ~~~ - -gv_generic_attributes_statement(_, _, _, []) --> [], !. -gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> - indent(I), - gv_kind(Kind), ` `, - gv_attribute_list(Kind, GraphAttrs, KindAttrs), newline. - - -%! gv_graph(+GraphTerm:compound)// -% The follow graph attributes are supported, -% beyond the GraphViz attributes for graphs: -% * `directedness(+boolean)` -% Whether the graph is directed (`true`) or undirected (`false`). -% Default: `false`. -% * `name(+GraphName:atom)` -% * `strict(+StrictGraph:boolean)` -% This forbids the creation of self-arcs and multi-edges; -% they are ignored in the input file. -% Only in combinattion with directionality `directed`. -% -% ~~~{.abnf} -% graph = ["strict"] ("graph" / "digraph") [ID] "{" stmt_list "}" -% ~~~ -% -% `GraphTerm` is a compound term of the following form: -% ~~~{.pl} -% graph(VertexTerms,RankedVertexTerms,EdgeTerms,GraphAttributes) -% ~~~ -% -% `RankedVertexTerms` is a list of compound terms of the following form: -% ~~~{.pl} -% rank(RankNode,ContentNodes) -% ~~~ -% -% @tbd Add support for subgraphs (arbitrary nesting). -% @tbd Add support for escape strings: -% http://www.graphviz.org/doc/info/attrs.html#k:escString -% @tbd Assert attributes that are generic with respect to a subgraph. -% @tbd Not all vertex and edge properties can be shared it seems (e.g., label). - -gv_graph(graph(VTerms, ETerms, GAttrs)) --> - gv_graph(graph(VTerms, [], ETerms, GAttrs)). - -gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> - { - shared_attributes(VTerms, SharedVAttrs, NewVTerms), - shared_attributes(ETerms, SharedEAttrs, NewETerms), - select_nvpair(strict=Strict, GAttrs1, GAttrs2, false), - select_nvpair(directedness=Directedness, GAttrs2, GAttrs3, true), - select_nvpair(name=GName, GAttrs3, GAttrs4, noname), - add_default_nvpair(GAttrs4, overlap, false, GAttrs5), - I = 0 - }, - - % The first statement in the GraphViz output. - % States that this file represents a graph according to the GraphViz format. - indent(I), - gv_strict(Strict), - gv_graph_type(Directedness), ` `, - gv_id(GName), ` `, - bracketed( - curly, - gv_graph0( - I, - NewVTerms, SharedVAttrs, RankedVTerms, - NewETerms, SharedEAttrs, - Directedness, GAttrs5 - ) - ), - newline. - -gv_graph0( - I, - NewVTerms, SharedVAttrs, RankedVTerms, - NewETerms, SharedEAttrs, - Directedness, GAttrs -) --> - newline, - - % The following lines are indented. - {NewI is I + 1}, - - % Attributes that apply to the graph as a whole. - gv_generic_attributes_statement(graph, NewI, GAttrs, GAttrs), - - % Attributes that are the same for all nodes. - gv_generic_attributes_statement(node, NewI, GAttrs, SharedVAttrs), - - % Attributes that are the same for all edges. - gv_generic_attributes_statement(edge, NewI, GAttrs, SharedEAttrs), - - % Only add a newline if some content was written in the previous three - % lines. - ({(GAttrs == [], SharedVAttrs == [], SharedEAttrs == [])} -> `` ; newline), - - % The list of GraphViz nodes. - '*'(gv_node_statement(NewI, GAttrs), NewVTerms), - ({NewVTerms == []} -> `` ; newline), - - % The ranked GraphViz nodes (displayed at the same height). - '*'(gv_ranked_node_collection(NewI, GAttrs), RankedVTerms), - ({RankedVTerms == []} -> `` ; newline), - - { - findall( - edge(FromId,ToId,[]), - ( - nth0(Index1, RankedVTerms, rank(vertex(FromId,_,_),_)), - nth0(Index2, RankedVTerms, rank(vertex(ToId,_,_),_)), - % We assume that the rank vertices are nicely ordered. - succ(Index1, Index2) - ), - RankEdges - ) - }, - - % The rank edges. - '*'(gv_edge_statement(NewI, Directedness, GAttrs), RankEdges), - - % The non-rank edges. - '*'(gv_edge_statement(NewI, Directedness, GAttrs), NewETerms), - - % Note that we do not include a newline here. - - % We want to indent the closing curly brace. - indent(I). - - -%! gv_graph_type(+Directedness:boolean)// . -% The type of graph that is represented. - -gv_graph_type(false) --> `graph`. -gv_graph_type(true) --> `digraph`. - - -%! gv_id(?Atom:atom)// is det. -% Parse a GraphViz identifier. -% There are 4 variants: -% 1. Any string of alphabetic (`[a-zA-Z'200-'377]`) characters, -% underscores (`_`) or digits (`[0-9]`), not beginning with a digit. -% 2. A numeral `[-]?(.[0-9]+ | [0-9]+(.[0-9]*)? )`. -% 3. Any double-quoted string (`"..."`) possibly containing -% escaped quotes (`\"`). -% In quoted strings in DOT, the only escaped character is -% double-quote (`"`). That is, in quoted strings, the dyad `\"` -% is converted to `"`. All other characters are left unchanged. -% In particular, `\\` remains `\\`. -% Layout engines may apply additional escape sequences. -% 4. An HTML string (`<...>`). -% -% @tbd Add support for HTML-like labels: -% http://www.graphviz.org/doc/info/shapes.html#html -% This requires an XML grammar! - -% HTML strings (variant 4). -gv_id(Atom) --> - dcg_atom_codes(gv_html_like_label, Atom), !. -% Alpha-numeric strings (variant 1). -gv_id(Atom) --> - {atom_codes(Atom, [H|T])}, - gv_id_first(H), - gv_id_rest(T), !, - % Variant 1 identifiers should not be (case-variants of) a - % GraphViz keyword. - {\+ gv_keyword([H|T])}. -% Numerals (variant 2) -gv_id(N) --> - {number(N)}, !, - gv_numeral(N). -% Double-quoted strings (variant 3). -% The quotes are already part of the given atom. -gv_id(Atom) --> - { - atom_codes(Atom, [H|T]), - append(S, [H], T) - }, - dcg_between(double_quote(H), gv_quoted_string(S)), !. -% Double-quoted strings (variant 3). -% The quotes are not in the given atom. They are written anyway. -gv_id(Atom) --> - quoted(double_quote, dcg_atom_codes(gv_quoted_string, Atom)), !. - -gv_id_first(X) --> ascii_letter(X). -gv_id_first(X) --> underscore(X). - -gv_id_rest([]) --> []. -gv_id_rest([H|T]) --> - (ascii_alpha_numeric(H) ; underscore(H)), - gv_id_rest(T). - - -%! gv_keyword(+Codes:list(code)) is semidet. -% Succeeds if the given codes for a GraphViz reserved keyword. - -gv_keyword(Codes):- - % Obviously, the keywords do not occur on the difference list input. - % So we must use phrase/[2,3]. - phrase(gv_keyword, Codes). - -%! gv_keyword// . -% GraphViz has reserved keywords that cannot be used as identifiers. -% GraphViz keywords are case-insensitive. - -gv_keyword --> `digraph`. -gv_keyword --> `edge`. -gv_keyword --> `graph`. -gv_keyword --> `node`. -gv_keyword --> `strict`. -gv_keyword --> `subgraph`. - - -%! gv_kind(+Kind:oneof([edge,graph,node]))// . - -gv_kind(edge) --> `edge`. -gv_kind(graph) --> `graph`. -gv_kind(node) --> `node`. - - -%! gv_node_id(+NodeId:atom)// . -% GraphViz node identifiers can be of the following two types: -% 1. A GraphViz identifier, see gv_id//1. -% 2. A GraphViz identifier plus a GraphViz port indicator, see gv_port//0. -% -% @tbd Add support for GraphViz port indicators -% inside GraphViz node identifiers. - -gv_node_id(Id) --> - gv_id(Id). -%gv_node_id(_) --> -% gv_id(_), -% gv_port. - - -%! gv_node_statement( -%! +Indent:integer, -%! +GraphAttributes, -%! +VertexTerm:compound -%! )// . -% A GraphViz statement describing a vertex (GraphViz calls vertices 'nodes'). - -gv_node_statement(I, GraphAttrs, vertex(Id,_,VAttrs)) --> - indent(I), - gv_node_id(Id), ` `, - gv_attribute_list(node, GraphAttrs, VAttrs), newline. - - -gv_port --> - gv_port_location, - '?'(gv_port_angle). -gv_port --> - gv_port_angle, - '?'(gv_port_location). -gv_port --> - `:`, - gv_compass_pt(_). - -gv_port_angle --> - `@`, - gv_id(_). - -gv_port_location --> - `:`, - gv_id(_). -gv_port_location --> - `:`, - bracketed( - round, - ( - gv_id(_), - `,`, - gv_id(_) - ) - ). - - -gv_quoted_string([]) --> []. -% Just to be sure, we do not allow the double quote -% that closes the string to be escaped. -gv_quoted_string([X]) --> - {X \== 92}, !, - [X]. -% A double quote is only allowed if it is escaped by a backslash. -gv_quoted_string([92,34|T]) --> !, - gv_quoted_string(T). -% Add the backslash escape character. -gv_quoted_string([34|T]) --> !, - `\\\"`, - gv_quoted_string(T). -% All other characters are allowed without escaping. -gv_quoted_string([H|T]) --> - [H], - gv_quoted_string(T). - - -gv_ranked_node_collection( - I, - GraphAttrs, - rank(Rank_V_Term,Content_V_Terms) -) --> - indent(I), - bracketed(curly, ( - newline, - - % The rank attribute. - {NewI is I + 1}, - indent(NewI), gv_attribute(rank=same), `;`, newline, - - '*'(gv_node_statement(NewI, GraphAttrs), [Rank_V_Term|Content_V_Terms]), - - % We want to indent the closing curly brace. - indent(I) - )), - newline. - - -%! gv_strict(+Strict:boolean)// is det. -% The keyword denoting that the graph is strict, i.e., has no self-arcs and -% no multi-edges. -% This only applies to directed graphs. - -gv_strict(false) --> []. -gv_strict(true) --> `strict `. - - - -% Helpers - -add_default_nvpair(Attrs1, N, Default, Attrs2):- - add_default_nvpair(Attrs1, N, Default, _, Attrs2). - -add_default_nvpair(Attrs, N, _, V, Attrs):- - memberchk(N=V, Attrs), !. -add_default_nvpair(Attrs1, N, Default, Default, Attrs2):- - ord_add_element(Attrs1, N=Default, Attrs2). - -select_nvpair(N=V, Attrs1, Attrs2, _):- - memberchk(N=V, Attrs1), !, - select(N=V, Attrs1, Attrs2). -select_nvpair(_=Default, Attrs, Attrs, Default). - - -extract_shared([], []):- !. -extract_shared(Argss, Shared):- - ord_intersection(Argss, Shared). - -remove_shared_attributes(Shared, Args1, Args2):- - ord_subtract(Args1, Shared, Args2). - -shared_attributes(Terms1, Shared, Terms2):- - maplist(term_components(Func), Terms1, Args1, Args2, Args3a), - extract_shared(Args3a, Shared), - maplist(remove_shared_attributes(Shared), Args3a, Args3b), - maplist(term_components(Func), Terms2, Args1, Args2, Args3b). - -term_components(Func, Term, Arg1, Arg2, Arg3):- - Term =.. [Func,Arg1,Arg2,Arg3]. - diff --git a/gv_file.pl b/gv_file.pl deleted file mode 100644 index 9eaf66b..0000000 --- a/gv_file.pl +++ /dev/null @@ -1,206 +0,0 @@ -:- module( - gv_file, - [ - file_to_gv/2, % +File:atom - % +Options:list(nvpair) - file_to_gv/3, % +FromFile:atom - % ?ToFile:atom - % +Options:list(nvpair) - gif_to_gv_file/3, % +GraphInterchangeFormat:compound - % +ToFile:atom - % +Options:list(nvpair) - gif_to_svg_dom/3, % +GraphInterchangeFormat:compound - % -SvgDom:list(compound) - % +Options:list(nvpair) - open_dot/1 % +File:file - ] -). - -/** GraphViz file - -Predicates for converting GIF-formatted terms -into GraphViz output files or SVG DOM structures. - -Also converts between GraphViz DOT formatted files -and GraphViz output files or SVG DOM structures. - -@author Wouter Beek -@version 2011-2013/09, 2013/11-2014/01, 2014/05, 2014/07 -*/ - -:- use_module(library(option)). -:- use_module(library(process)). -:- use_module(library(predicate_options)). % Declarations. - -:- use_module(generics(codes_ext)). -:- use_module(generics(db_ext)). -:- use_module(os(file_ext)). -:- use_module(os(run_ext)). -:- use_module(os(safe_file)). -:- use_module(svg(svg_file)). - -:- use_module(plGraphViz(gv_dot)). - -:- dynamic(user:file_type_program/2). -:- multifile(user:file_type_program/2). - -:- dynamic(user:module_uses/2). -:- multifile(user:module_uses/2). - -:- dynamic(user:prolog_file_type/2). -:- multifile(user:prolog_file_type/2). - -% Register DOT. -:- db_add_novel(user:prolog_file_type(dot, dot)). -:- db_add_novel(user:prolog_file_type(dot, graphviz)). -:- db_add_novel(user:file_type_program(dot, dotty)). -:- db_add_novel(user:file_type_program(dot, dotx)). -:- db_add_novel(user:module_uses(gv_file, file_type(dot))). - -% Register JPG/JPEG. -:- db_add_novel(user:prolog_file_type(jpeg, jpeg)). -:- db_add_novel(user:prolog_file_type(jpeg, graphviz_output)). -:- db_add_novel(user:prolog_file_type(jpg, jpeg)). -:- db_add_novel(user:prolog_file_type(jpg, graphviz_output)). - -% Register PDF. -:- db_add_novel(user:prolog_file_type(pdf, pdf)). -:- db_add_novel(user:prolog_file_type(pdf, graphviz_output)). - -% Register PNG. -:- db_add_novel(user:prolog_file_type(png, png)). -:- db_add_novel(user:prolog_file_type(png, graphviz_output)). - -% Register SVG. -:- db_add_novel(user:prolog_file_type(svg, graphviz_output)). -:- db_add_novel(user:prolog_file_type(svg, svg)). - -% Register XDOT. -:- db_add_novel(user:prolog_file_type(xdot, graphviz_output)). -:- db_add_novel(user:prolog_file_type(xdot, xdot)). - -:- predicate_options(codes_to_gv_file/3, 3, [ - pass_to(file_to_gv/3, 3) - ]). -:- predicate_options(file_to_gv/2, 2, [ - pass_to(file_to_gv/3, 3) - ]). -:- predicate_options(file_to_gv/3, 3, [ - method(+oneof([dot,sfdp])), - to_file_type(+oneof([dot,jpeg,pdf,svg,xdot])) - ]). -:- predicate_options(gif_to_svg_dom/3, 3, [ - pass_to(gif_to_gv_file/3, 3) - ]). -:- predicate_options(gif_to_gv_file/3, 3, [ - pass_to(codes_to_gv_file/3, 3) - ]). - - - -%! codes_to_gv_file( -%! +Codes:list(code), -%! +ToFile:atom, -%! +Options:list(nvpair) -%! ) is det. - -codes_to_gv_file(Codes, ToFile, Options):- - access_file(ToFile, write), - absolute_file_name(data(tmp), TmpFile, [access(write),file_type(dot)]), - setup_call_cleanup( - open(TmpFile, write, Write, [encoding(utf8)]), - put_codes(Write, Codes), - close(Write) - ), - file_to_gv(TmpFile, ToFile, Options), - delete_file(TmpFile). - - -%! file_to_gv(+FromFile:atom, +Options:list(nvpair)) is det. - -file_to_gv(FromFile, Options):- - file_to_gv(FromFile, _, Options). - -%! file_to_gv(+FromFile:atom, ?ToFile:atom, +Options:list(nvpair)) is det. -% Converts a GraphViz DOT file to an image file, using a specific -% visualization method. - -file_to_gv(FromFile, ToFile, Options):- - option(to_file_type(dot), Options), !, - rename_file(FromFile, ToFile). -file_to_gv(FromFile, ToFile, Options):- - % The method option. - option(method(Method), Options, dot), - must_be(oneof([dot,sfdp]), Method), - - % The file type option. - option(to_file_type(ToFileType), Options, pdf), - prolog_file_type(ToExtension, ToFileType), - prolog_file_type(ToExtension, graphviz_output), !, - - % The output file is either given or created. - ( - var(ToFile) - -> - user:prolog_file_type(ToExtension, ToFileType), - file_alternative(FromFile, _, _, ToExtension, ToFile) - ; - is_absolute_file_name(ToFile), - % The given output file must match a certain file extension. - file_name_extension(_, ToExtension, ToFile) - ), - % Now that we have the output file we can prevent the - % file type / file extension translation predicates from bakctracking. - !, - - % Run the GraphViz conversion command in the shell. - format(atom(OutputType), '-T~w', [ToExtension]), - process_create( - path(Method), - [OutputType,FromFile,'-o',ToFile], - [process(PID)] - ), - process_wait(PID, exit(ShellStatus)), - exit_code_handler('GraphViz', ShellStatus). - - -%! gif_to_gv_file(+Gif:compound, +ToFile:atom, +Options:list(nvpair)) is det. -% Returns a file containing a GraphViz visualization of the given graph. -% -% The following options are supported: -% * =|method(+Method:oneof([dot,sfdp])|= -% The algorithm used by GraphViz for positioning the tree nodes. -% Either =dot= (default) or =sfdp=. -% * =|to_file_type(+FileType:oneof([dot,jpeg,pdf,svg,xdot])|= -% The file type of the generated GraphViz file. -% Default: `pdf`. - -gif_to_gv_file(Gif, ToFile, Options):- - once(phrase(gv_graph(Gif), Codes)), - codes_to_gv_file(Codes, ToFile, Options). - - -%! gif_to_svg_dom( -%! +GraphInterchangeFormat:compound, -%! -SvgDom:list(compound), -%! +Options:list(nvpair) -%! ) is det. - -gif_to_svg_dom(Gif, SvgDom, Options1):- - % Make sure the file type of the output file is SvgDom. - merge_options([to_file_type=svg], Options1, Options2), - gif_to_gv_file(Gif, ToFile, Options2), - file_to_svg(ToFile, SvgDom), - safe_delete_file(ToFile). - - -%! open_dot(+File:atom) is det. -% Opens the given DOT file. -% -% @tbd Test support on Windows. -% @tbd Test support on OS-X. - -open_dot(File):- - once(find_program_by_file_type(dot, Program)), - run_program(Program, [File]). - diff --git a/gv_gif.pl b/gv_gif.pl deleted file mode 100644 index d59e5f8..0000000 --- a/gv_gif.pl +++ /dev/null @@ -1,221 +0,0 @@ -:- module( - gv_gif, - [ - create_gif/3, % +Edges:ordset - % -Gif:compound - % +Options:list(nvpair) - create_gif/4 % +Vertices:ordset - % +Edges:ordset - % -Gif:compound - % +Options:list(nvpair) - ] -). - -/** GraphViz Graph Interchange Format (GIF) - -Support for creating GIF representations. - -@author Wouter Beek -@version 2014/06-2014/07 -*/ - -:- use_module(library(apply)). -:- use_module(library(lambda)). -:- use_module(library(option)). -:- use_module(library(ordsets)). -:- use_module(library(predicate_options)). % Declarations. - -:- use_module(generics(list_ext)). -:- use_module(generics(option_ext)). -:- use_module(graph_theory(graph_theory)). - -:- use_module(plRdf(rdf_name)). % Meta-DCG. - -:- predicate_options(create_gif/3, 3, [ - pass_to(create_gif/4, 4) - ]). -:- predicate_options(create_gif/4, 4, [ - pass_to(edge_term/3, 3), - pass_to(graph_attributes/2, 2), - pass_to(vertex_term/3, 3) - ]). -:- predicate_options(edge_term/3, 3, [ - edge_arrowhead(+atom), - edge_color(+atom), - edge_label(+atom), - edge_style(+atom) - ]). -:- predicate_options(graph_attributes/2, 2, [ - directedness(+boolean), - graph_colorscheme(+oneof([none,svg,x11])), - graph_label(+atom) - ]). - -:- predicate_options(vertex_term/3, 3, [ - vertex_color(+atom), - vertex_coordinates(+atom), - vertex_image(+atom), - vertex_label(+atom), - vertex_peripheries(+atom), - vertex_shape(+atom) - ]). - - - -%! create_gif(+Edges:ordset, -Gif:compound, +Options:list(nvpair)) is det. - -create_gif(Es, Gif, Options):- - graph_theory:edges_to_vertices(Es, Vs), - create_gif(Vs, Es, Gif, Options). - -%! create_gif( -%! +Vertices:ordset, -%! +Edges:ordset, -%! -Gif:compound, -%! +Options:list(nvpair) -%! ) is det. -% The following options are supported: -% * =|graph_colorscheme(+oneof([none,svg,x11])) -% No default. -% * =|graph_label(+LabelFunction)|= -% The functions that assigns names to graphs. -% No default. - -create_gif(Vs, Es, graph(VTerms,ETerms,GAttrs), Options):- - % Vertex terms. - maplist(\V^VTerm^vertex_term(Vs, V, VTerm, Options), Vs, VTerms), - - % Edge terms. - maplist(\E^ETerm^edge_term(Vs, E, ETerm, Options), Es, ETerms), - - % Graph attributes. - graph_attributes(GAttrs, Options). - - -%! edge_term( -%! +Vertices:ordset, -%! +Edge:pair, -%! -EdgeTerm:compound, -%! +Options:list(nvpair) -%! ) is det. -% The following options are supported: -% * =|edge_arrowhead(+atom)|= -% * =|edge_color(+atom)|= -% * =|edge_label(+atom)|= -% * =|edge_style(+atom)|= - -edge_term(Vs, E, edge(FromId,ToId,EAttrs), Options):- - graph_theory:edge_components(E, FromV, ToV), - nth0chk(FromId, Vs, FromV), - nth0chk(ToId, Vs, ToV), - - % Arrowhead - if_option(edge_arrowhead(ArrowheadFunction), Options, - call(ArrowheadFunction, E, EArrowhead) - ), - % Color. - if_option(edge_color(ColorFunction), Options, - call(ColorFunction, E, EColor) - ), - % Label. - if_option(edge_label(LabelFunction), Options, - call(LabelFunction, E, ELabel) - ), - % Style. - if_option(edge_style(StyleFunction), Options, - call(StyleFunction, E, EStyle) - ), - - merge_options( - [arrowhead=EArrowhead,color=EColor,label=ELabel,style=EStyle], - EAttrs - ). - - -%! graph_attributes( -%! -GraphAttributes:list(nvpair), -%! +Options:list(nvpair) -%! ) is det. -% The following options are supported: -% * =|directedness(+boolean)|= -% Whether the graph is directed (`true`) or undirected (`false`). -% Default: `false`. -% * =|graph_colorscheme(+oneof([none,svg,x11]))|= -% The colorscheme from which the color in this graph are taken. -% Default: `svg`. -% * =|graph_label(+atom)|= -% The graph label. -% No default. - -graph_attributes(GAttrs, Options):- - % Directedness. - option(directedness(Directedness), Options, false), - % Colorscheme. - if_option(graph_colorscheme(Colorscheme), Options, true), - % Label. - if_option(graph_label(GLabel), Options, true), - - merge_options( - [colorscheme=Colorscheme,directedness=Directedness,label=GLabel], - GAttrs - ). - - -%! vertex_term( -%! +Vertices:ordset, -%! +Vertex, -%! -VertexTerm:compound, -%! +Options:list(nvpair) -%! ) is det. -% The following options are supported: -% * =|vertex_color(+ColorFunction)|= -% A function that assigns colors to vertices. -% No default. -% * =|vertex_image(+ImageFunction)|= -% A function that assinges images to vertices. -% No default. -% * =|vertex_label(+LabelFunction)|= -% A function that assigns labels to vertices. -% No default. -% * =|vertex_peripheries(+PeripheriesFunction)|= -% A function that assinges peripheries to vertices. -% No default. -% * =|vertex_shape(+ShapeFunction)|= -% A function that assinges shapes to vertices. -% No default. - -vertex_term(Vs, V, vertex(Id,V,VAttrs), Options):- - nth0chk(Id, Vs, V), - - % Color. - if_option(vertex_color(ColorFunction), Options, - call(ColorFunction, V, VColor) - ), - % Image. - if_option(image(ImageFunction), Options, - call(ImageFunction, V, VImage) - ), - % Label. - if_option(vertex_label(LabelFunction), Options, - call(LabelFunction, V, VLabel) - ), - % Peripheries. - if_option(vertex_peripheries(PeripheriesFunction), Options, - call(PeripheriesFunction, V, VPeripheries) - ), - % Shape. - if_option(vertex_shape(ShapeFunction), Options, - call(ShapeFunction, V, VShape) - ), - - merge_options( - [ - color=VColor, - image=VImage, - label=VLabel, - peripheries=VPeripheries, - shape=VShape - ], - VAttrs - ). - diff --git a/gv_html.pl b/gv_html.pl deleted file mode 100644 index b8d3190..0000000 --- a/gv_html.pl +++ /dev/null @@ -1,60 +0,0 @@ -:- module( - gv_html, - [ - gv_html_like_label//1 % +Codes:list(code) - ] -). - -/** GraphViz HTML - -@author Wouter Beek -@version 2013/07, 2013/09, 2014/03-2014/06 -*/ - -:- use_module(dcg(dcg_content)). - -:- use_module(plHtml(html_dcg)). - - - -%! gv_html_label(+Codes:list(code))// . -% -% @see http://www.graphviz.org/doc/info/shapes.html#html - -gv_html_label --> gv_html_text, !. -gv_html_label --> gv_html_table, !. -gv_html_label --> []. - -gv_html_like_label --> bracketed(angular, gv_html_label). - -gv_html_like_label(Content) --> bracketed(angular, html_dcg(Content)). - -gv_html_table --> html_element(table, _, gv_html_rows). -gv_html_table --> html_element(font, _, html_element(table, _, gv_html_rows)). - -gv_html_rows --> gv_html_row, gv_html_rows. -gv_html_rows --> gv_html_row, html_element(hr, _), gv_html_rows. -gv_html_rows --> gv_html_row. - -gv_html_row --> html_element(tr, _, gv_html_cells). - -gv_html_cell --> html_element(td, _, gv_html_label). -gv_html_cell --> html_element(td, _, html_element(img, _)). - -gv_html_cells --> gv_html_cell, gv_html_cells. -gv_html_cells --> gv_html_cell. -gv_html_cells --> gv_html_cell, html_element(vr, _), gv_html_cells. - -gv_html_text --> gv_html_textitem, gv_html_text. -gv_html_text --> gv_html_textitem. - -gv_html_textitem --> html_string, !. -gv_html_textitem --> html_entity, !. -gv_html_textitem --> html_element(br, _), !. -gv_html_textitem --> html_element(font, _, gv_html_text), !. -gv_html_textitem --> html_element(i, _, gv_html_text), !. -gv_html_textitem --> html_element(b, _, gv_html_text), !. -gv_html_textitem --> html_element(u, _, gv_html_text), !. -gv_html_textitem --> html_element(sub, _, gv_html_text), !. -gv_html_textitem --> html_element(sup, _, gv_html_text), !. - diff --git a/gv_numeral.pl b/gv_numeral.pl deleted file mode 100644 index 9b82fc0..0000000 --- a/gv_numeral.pl +++ /dev/null @@ -1,71 +0,0 @@ -:- module( - gv_numeral, - [ - gv_numeral//1 % ?Value:number - ] -). - -/** GraphViz numeral - -@author Wouter Beek -@version 2014/05-2014/06 -*/ - -:- use_module(dcg(dcg_abnf)). -:- use_module(dcg(dcg_cardinal)). -:- use_module(math(math_ext)). - - - -%! gv_numeral(?Value:number)// . -% ~~~{.bnf} -% ('-')? ( '.' [0-9]+ | [0-9]+ ( '.' [0-9]* )? ) -% ~~~ - -gv_numeral(N) --> - {nonvar(N)}, - {number_sign_parts(N, Sign, Abs)}, - ({Sign =:= -1} -> `-` ; ``), - gv_numeral_abs(Abs). -gv_numeral(N) --> - {var(N)}, - 'sign?'(Sign), - gv_numeral_abs(Abs), - {number_sign_parts(N, Sign, Abs)}. - - -gv_numeral_abs(N) --> - {nonvar(N)}, - {number_integer_parts(N, N1, N2)}, - ( - {N2 =:= 0} - -> - integer(N1) - ; - {N1 =:= 0} - -> - `.`, - integer(N2) - ; - integer(N1), - '?'((`.`, 'integer?'(N2))) - ). -gv_numeral_abs(N) --> - {var(N)}, - ( - `.`, - integer(N2) - -> - {N1 = 0} - ; - integer(N1), - ( - `.` - -> - 'integer?'(N2) - ; - {N2 = 0} - ) - ), - {number_integer_parts(N, N1, N2)}. - diff --git a/gv_tree.pl b/gv_tree.pl deleted file mode 100644 index afeb8f6..0000000 --- a/gv_tree.pl +++ /dev/null @@ -1,43 +0,0 @@ -:- module( - gv_tree, - [ - tree_to_gv_file/3 % +Tree:compound - % ?ToFile:atom - % +Options:list(nvpair) - ] -). - -/** GraphViz tree - -Export trees to GraphViz. - -@author Wouter Beek -@version 2014/06-2014/07 -*/ - -:- use_module(library(aggregate)). - -:- use_module(generics(trees)). - -:- use_module(plGraphViz(gv_file)). -:- use_module(plGraphViz(gv_gif)). - - -%! tree_to_gv_file( -%! +Tree:compound, -%! ?ToFile:atom, -%! +Options:list(nvpair) -%! ) is det. -% Stores the given tree term into a GraphViz file. -% -% Options are passed on to create_gif/3 and gif_to_gv_file/3. - -tree_to_gv_file(Tree, ToFile, Options):- - tree_to_gif(Tree, Gif, Options), - gif_to_gv_file(Gif, ToFile, Options). - - -tree_to_gif(H-T, Gif, Options):- - tree_to_vertices_edges(Tree, Vs, Es), - create_gif(Vs, Es, Gif, Options). - diff --git a/index.pl b/index.pl deleted file mode 100644 index 7461d13..0000000 --- a/index.pl +++ /dev/null @@ -1,2 +0,0 @@ -% Index of project plGraphViz (empty). - diff --git a/load.pl b/load.pl deleted file mode 100644 index 4b117d1..0000000 --- a/load.pl +++ /dev/null @@ -1,12 +0,0 @@ -% Load file for plGraphViz. - -:- dynamic(user:prolog/3). -:- multifile(user:prolog/3). - user:project(plGraphViz, 'GraphViz support for SWI-Prolog.', plGraphViz). - -:- use_module(load_project). -:- load_project(plGraphViz, [ - plc-'Prolog-Library-Collection', - plHtml -]). - diff --git a/load_project.pl b/load_project.pl deleted file mode 100644 index 5599b5e..0000000 --- a/load_project.pl +++ /dev/null @@ -1,120 +0,0 @@ -:- module( - load_project, - [ - load_project/2, % +Parent:atom - % +ChildProjects:list(or([atom,pair(atom)])) - load_subproject/2, % +ParentFileSearchPath:atom - % +Child:or([atom,pair(atom)]) - set_data_subdirectory/1 % +ParentDirectory:atom - ] -). - -/** Load project - -Generic code for loading a project: - * Create a subdirectory for data. - * Load the root of subprojects onto the file search path. - * Load the index of subprojects onto the file search path. - -@author Wouter Beek -@version 2014/06/14 -*/ - -:- use_module(library(ansi_term)). % Colorized terminal messages. -:- use_module(library(apply)). - -:- dynamic(user:project/2). -:- multifile(user:project/2). -:- dynamic(user:project/3). -:- multifile(user:project/3). - - - -load_project(Parent, ChildProjects):- - parent_alias(Parent, ParentFsp), - - % Entry point. - source_file(load_project(_,_), ThisFile), - file_directory_name(ThisFile, ThisDir), - assert(user:file_search_path(ParentFsp, ThisDir)), - assert(user:file_search_path(project, ThisDir)), - - % Set the data subdirectory. - set_data_subdirectory(ThisDir), - - % Load the root of submodules onto the file search path. - maplist(load_subproject(ParentFsp), ChildProjects), - - % Load the index into the file search path. - load_project_index(ParentFsp). - - - -%! load_subproject( -%! +ParentFileSearchPath:atom, -%! +Child:or([atom,pair(atom)]) -%! ) is det. - -load_subproject(ParentFsp, ChildFsp-ChildDir):- !, - load_subproject_file_search_path(ParentFsp, ChildFsp, ChildDir), - load_project_index(ChildFsp). -load_subproject(ParentFsp, Child):- - load_subproject(ParentFsp, Child-Child). - - -%! load_subproject_file_search_path( -%! +ParentFileSearchPath:atom, -%! +ChildFileSearchPath:atom, -%! +ChildDirectory:atom -%! ) is det. - -% The file search path for the subproject has already been set. -load_subproject_file_search_path(_, ChildFsp, _):- - user:file_search_path(ChildFsp, _). -load_subproject_file_search_path(ParentFsp, ChildFsp, ChildDir):- - Spec =.. [ParentFsp,ChildDir], - absolute_file_name(Spec, _, [access(read),file_type(directory)]), !, - assert(user:file_search_path(ChildFsp, Spec)). -load_subproject_file_search_path(_, ChildFsp, ChildDir):- - print_message(warning, missing_subproject_directory(ChildFsp,ChildDir)). - - -%! load_project_index(+FileSearchPath:atom) is det. - -load_project_index(Fsp):- - Spec =.. [Fsp,index], - absolute_file_name( - Spec, - File, - [access(read),file_errors(fail),file_type(prolog)] - ), !, - ensure_loaded(File). -load_project_index(_). - - -%! parent_alias(+Parent:atom, -ParentFsp:atom) is det. - -parent_alias(Parent, ParentFsp):- - user:project(Parent, _, ParentFsp), !. -parent_alias(Parent, Parent). - - -%! set_data_subdirectory(+ParentDirectory:atom) is det. - -set_data_subdirectory(ParentDir):- - directory_file_path(ParentDir, data, DataDir), - make_directory_path(DataDir), - assert(user:file_search_path(data, DataDir)). - - - -:- multifile(prolog:message//1). - -prolog:message(missing_subproject_directory(ChildFsp,ChildDir)) --> - [ - 'The ~a submodule is not present.'-[ChildFsp], nl, - 'Check whether subdirectory ~a is present in your project directory:'-[ChildDir], nl, - ' git submodule init', nl, - ' git submodule update' - ]. - diff --git a/pack.pl b/pack.pl new file mode 100644 index 0000000..989108a --- /dev/null +++ b/pack.pl @@ -0,0 +1,9 @@ +author('Wouter Beek', 'me@wouterbeek.com'). +download('https://github.com/wouterbeek/plGraphViz/release/*.zip'). +home('https://github.com/wouterbeek/plGraphViz'). +maintainer('Wouter Beek', 'me@wouterbeek.com'). +name(plGraphViz). +packager('Wouter Beek', 'me@wouterbeek.com'). +requires('Prolog-Library-Collection'). +title(plGraphViz). +version('0.0.1'). diff --git a/plHtml b/plHtml deleted file mode 160000 index 08480c4..0000000 --- a/plHtml +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 08480c40acaee5f70bfb21e3c641bef1e7d258bd diff --git a/prolog/fca/fca_viz.pl b/prolog/fca/fca_viz.pl new file mode 100644 index 0000000..083dbb2 --- /dev/null +++ b/prolog/fca/fca_viz.pl @@ -0,0 +1,101 @@ +:- module( + fca_viz, + [ + fca_export_graph/2, % +Context, -ExportGraph + fca_export_graph/3, % +Context, -ExportGraph, :Opts + fca_viz/2, % +Context, ?File + fca_viz/3 % +Context, ?File, :Opts + ] +). + +/** FCA visualization + +@author Wouter Beek +@version 2015/11-2016/01 +*/ + +:- use_module(library(aggregate)). +:- use_module(library(dcg/dcg_ext)). +:- use_module(library(dcg/dcg_pl)). +:- use_module(library(fca/fca)). +:- use_module(library(graph/build_export_graph)). +:- use_module(library(graph/s/s_graph)). +:- use_module(library(gv/gv_file)). +:- use_module(library(option)). +:- use_module(library(ordsets)). + +:- meta_predicate(fca_export_graph(+,?,:)). +:- meta_predicate(fca_viz(+,?,:)). + +:- predicate_options(fca_export_graph/3, 3, [ + concept_label(+callable) + ]). +:- predicate_options(fca_viz/3, 3, [ + pass_to(fca_export_graph/3, 3), + pass_to(graph_viz/3, 3) + ]). + +is_meta(concept_label). + + + + + +%! fca_export_graph(+Context:compound, -ExportGraph:compound) is det. +% Wrapper around fca_export_graph/3 with default options. + +fca_export_graph(Context, ExportG):- + fca_export_graph(Context, ExportG, []). + + +%! fca_export_graph( +%! +Context:compound, +%! -ExportGraph:compound, +%! :Options:list(compound) +%! ) is det. +% The following optios are supported: +% * concept_label(+callable) +% DCG writing the labels for individual concepts. + +fca_export_graph(Context, ExportG, Opts1):- + fca_hasse(Context, Hasse), + meta_options(is_meta, Opts1, Opts2), + option(concept_label(Label_3), Opts2, concept_label), + merge_options( + [ + vertex_label(Label_3), + vertex_rank(fca:concept_cardinality) + ], + Opts2, + Opts3 + ), + build_export_graph(Hasse, ExportG, Opts3). + + + +%! fca_viz(+Context:compound, ?File:atom) is det. +% Wrapper around fca_viz/3 with default options. + +fca_viz(Context, File):- + fca_viz(Context, File, []). + + +%! fca_viz(+Context:compound, ?File:atom, :Options:list(compound)) is det. + +fca_viz(Context, File, Opts1):- + meta_options(is_meta, Opts1, Opts2), + statistics(process_cputime, Time1), + fca_export_graph(Context, ExportG, Opts2), + ExportG = graph(_,_,Es,_), + aggregate_all(max(N), (member(edge(V1,V2,_), Es), (N = V1 ; N = V2)), N), + ignore(option(number_of_vertices(N), Opts2)), + statistics(process_cputime, Time2), + Time is Time2 - Time1, + ignore(option(process_cputime(Time), Opts2)), + graph_viz(ExportG, File, Opts2). + + + +%! concept_label(+Concept:compound)// is det. + +concept_label(concept(Os,As)) --> set(Os), " / ", set(As). diff --git a/prolog/graph/build_export_graph.pl b/prolog/graph/build_export_graph.pl new file mode 100644 index 0000000..5134069 --- /dev/null +++ b/prolog/graph/build_export_graph.pl @@ -0,0 +1,369 @@ +:- module( + build_export_graph, + [ + build_export_graph/2, % +Graph, -ExportGraph + build_export_graph/3 % +Graph + % -ExportGraph:compound + % +Options:list(compound) + ] +). + +/** Build graph representation for exporting + +Support for building GIF representations. + +# Graph Intermediate Format (GIF) + +## Graph + +```prolog +graph(Vs:ordset(compound),Ranks,Es:compound,Attributes:list(compound)) +``` + +### Edge + +```prolog +edge(FromVertexId,ToVertexId,Attributes:list(compound)) +``` + +### Rank + +```prolog +RankVertex:compound-ContentVertices:ordset(compound) +``` + +### Vertex + +```prolog +vertex(Id,Attributes:list(compound)) +``` + +# Property functions + +Edge label: + 1. [[graph_edge]] edge_label/2 + +Vertex coordinates: + 1. [[circle_coords]] circular_coord/4 + 2. [[random_coords]] random_coord/4 + +--- + +@author Wouter Beek +@version 2015/07, 2015/09-2016/01 +*/ + +:- use_module(library(apply)). +:- use_module(library(dcg/dcg_ext)). +:- use_module(library(graph/s/s_graph)). +:- use_module(library(list_ext)). +:- use_module(library(option_ext)). +:- use_module(library(ordsets)). +:- use_module(library(pairs)). + +:- predicate_options(build_export_graph/4, 4, [ + pass_to(edge_term/3, 3), + pass_to(graph_attributes/2, 2), + pass_to(vertex_term/3, 3) + ]). +:- predicate_options(edge_term/3, 3, [ + edge_arrowhead(+callable), + edge_color(+callable), + edge_id(+callable), + edge_label(+callable), + edge_penwidth(+callable), + edge_style(+callable) + ]). +:- predicate_options(graph_attributes/2, 2, [ + graph_charset(+oneof(['iso-8859-1','Latin1','UTF-8'])), + graph_colorscheme(+oneof([none,svg,x11])), + graph_directed(+boolean), + graph_fontsize(+float), + graph_label(+atom), + graph_overlap(+boolean) + ]). +:- predicate_options(vertex_term/3, 3, [ + vertex_color(+callable), + vertex_id(+callable), + vertex_image(+callable), + vertex_label(+callable), + vertex_peripheries(+callable), + vertex_position(+callable), + vertex_rank(+callable), + vertex_shape(+callable), + vertex_uri(+callable) + ]). + +:- meta_predicate(build_export_graph(+,-,:)). + +is_meta(edge_arrowhead). +is_meta(edge_color). +is_meta(edge_id). +is_meta(edge_label). +is_meta(edge_penwidth). +is_meta(edge_style). +is_meta(vertex_color). +is_meta(vertex_id). +is_meta(vertex_image). +is_meta(vertex_label). +is_meta(vertex_peripheries). +is_meta(vertex_position). +is_meta(vertex_rank). +is_meta(vertex_shape). +is_meta(vertex_uri). + + + + + +%! build_export_graph(+Graph, -ExportGraph:compound) is det. +% Wrapper around build_export_graph/3 with default options. + +build_export_graph(G, ExportG):- + build_export_graph(G, ExportG, []). + + +%! build_export_graph( +%! +Graph, +%! -ExportGraph:compound, +%! +Options:list(compound) +%! ) is det. +% Graph is either: +% * a coumpound term `graph(Vs,Es)`, or +% * an unlabeled graph as defined by `library(ugraph)`. +% +% The following options are supported: +% * `vertex_rank(:RankFunction)` +% Assigns a non-negative integer to each vertex. +% No default. + +build_export_graph(G, graph(VTerms2,VRanks,ETerms,GAttrs), Opts1):- + graph_components(G, Vs, Es), + meta_options(is_meta, Opts1, Opts2), + maplist(vertex_term0(Vs, Opts2), Vs, VTerms1), + build_export_ranks(Vs, VTerms1, VRanks, VTerms2, Opts2), + maplist(edge_term0(Vs, Opts2), Es, ETerms), + graph_attributes(GAttrs, Opts2). + +vertex_term0(Vs, Opts, V, VTerm) :- vertex_term(Vs, V, VTerm, Opts). + +edge_term0(Vs, Opts, E, ETerm) :- edge_term(Vs, E, ETerm, Opts). + +graph_components(graph(Vs,Es), Vs, Es):- !. +graph_components(G, Vs, Es):- + s_graph_components(G, Vs, Es). + +build_export_ranks(Vs, VTerms, VRanks, [], Opts):- + option(vertex_rank(VRank_2), Opts), !, + maplist(VRank_2, Vs, Ranks), + pairs_keys_values(Pairs, Ranks, VTerms), + group_pairs_by_key(Pairs, GroupedPairs), + build_export_rank_terms(GroupedPairs, VRanks). +build_export_ranks(_, VTerms, [], VTerms, _). + +build_export_rank_terms([N-VTerms|T1], [RankTerm-VTerms|T2]):- !, + build_export_rank_term(N, RankTerm), + build_export_rank_terms(T1, T2). +build_export_rank_terms([], []). + +build_export_rank_term(N, vertex(Id,[label(""),shape(none)])):- + format(atom(Id), "r~d", [N]). + + + +%! edge_term( +%! +Vertices:ordset(compound), +%! +Edge:compound, +%! -EdgeTerm:compound, +%! +Options:list(compound) +%! ) is det. +% The following options are supported: +% * `edge_arrowhead(+callable)` +% No default. +% * `edge_color(+callable)` +% No default. +% * `edge_id(+callable)` +% Function that assignes the unique identifiers for an edge's +% incident vertices. +% * `edge_label(+callable)` +% No default. +% * `edge_penwidth(+callable)` +% No default. +% * `edge_style(+callable)` +% No default. + +edge_term(Vs, E, edge(FromId,ToId,EAttrs), Opts):- + % Arrowhead + if_option(edge_arrowhead(Arrowhead_2), Opts, + call(Arrowhead_2, E, EArrowhead) + ), + + % Color. + if_option(edge_color(ColorFunction), Opts, call(ColorFunction, E, EColor)), + + % Id. + ( option(edge_id(Id_2), Opts) + -> call(Id_2, E, FromId, ToId) + ; edge_components(E, FromV, ToV), + nth0chk(FromId, Vs, FromV), + nth0chk(ToId, Vs, ToV) + ), + + % Label. + if_option(edge_label(ELabel_3), Opts, string_phrase(dcg_call(ELabel_3, E), ELabel)), + + % Penwidth. + if_option(edge_penwidth(Penwidth_2), Opts, call(Penwidth_2, E, EPenwidth)), + + % Style. + if_option(edge_style(Style_2), Opts, call(Style_2, E, EStyle)), + + exclude( + option_has_var_value, + [ + arrowhead(EArrowhead), + color(EColor), + label(ELabel), + penwidth(EPenwidth), + style(EStyle) + ], + EAttrs + ). + + + +%! graph_attributes( +%! -GraphAttributes:list(compound), +%! +Options:list(compound) +%! ) is det. +% The following options are supported: +% * `graph_charset(+oneof(['iso-8859-1','Latin1','UTF-8']))` +% The name of the character set that is used to encode text in the graph. +% Default: `UTF-8`. +% * `graph_colorscheme(+oneof([none,svg,x11]))` +% The colorscheme from which the color in this graph are taken. +% Default: `x11`. +% * `graph_directed(+boolean)` +% Whether the graph is directed (`true`) or undirected (`false`). +% Default: `false`. +% * `graph_fontsize(+float)` +% The font size of text in the graph. +% Default: `11.0`. +% * `graph_label(+atom)` +% The graph label. +% No default. +% * `graph_overlap(+boolean)` +% Whether the vertices are allowed to overlap. +% Default: `false`. + +graph_attributes(GAttrs, Opts):- + % Characer set. + option(graph_charset(Charset), Opts, 'UTF-8'), + % Colorscheme. + option(graph_colorscheme(Colorscheme), Opts, x11), + % Directed. + option(graph_directed(Directed), Opts, false), + % Fontsize. + option(graph_fontsize(Fontsize), Opts, 11.0), + % Label. + % Defaults to the empty string. + option(graph_label(GLabel), Opts, '""'), + % Overlap. + option(graph_overlap(Overlap), Opts, false), + exclude( + option_has_var_value, + [ + charset(Charset), + colorscheme(Colorscheme), + directed(Directed), + fontsize(Fontsize), + label(GLabel), + overlap(Overlap) + ], + GAttrs + ). + + + +%! vertex_term( +%! +Vertices:ordset(compound), +%! +Vertex:compound, +%! -VertexTerm:compound, +%! +Options:list(compound) +%! ) is det. +% The following options are supported: +% * `vertex_color(:ColorFunction)` +% A function that assigns colors to vertices. +% No default. +% * `vertex_id(:ColorFunction)` +% A functions that assigns unique identifiers to vertices. +% * `vertex_image(:ImageFunction)` +% A function that assigns images to vertices. +% No default. +% * `vertex_label(:LabelFunction)` +% A function that assigns labels to vertices. +% No default. +% * `vertex_peripheries(:PeripheriesFunction)` +% A function that assinges peripheries to vertices. +% No default. +% * `vertex_position(:PositionFunction)` +% No default. +% * `vertex_shape(:ShapeFunction)` +% A function that assinges shapes to vertices. +% No default. +% * `vertex_uri(:UriFunction)` + +vertex_term(Vs, V, vertex(VId,VAttrs), Opts):- + % Color. + if_option(vertex_color(Color_2), Opts, call(Color_2, V, VColor)), + + % Id. + (option(vertex_id(Id_2), Opts) -> call(Id_2, V, VId) ; nth0chk(VId, Vs, V)), + + % Image. + ignore(if_option(vertex_image(Image_2), Opts, call(Image_2, V, VImage))), + + % Label. + if_option(vertex_label(VLabel_2), Opts, string_phrase(dcg_call(VLabel_2, V), VLabel)), + + % Peripheries. + if_option(vertex_peripheries(Peripheries_2), Opts, + call(Peripheries_2, V, VPeripheries) + ), + + % Position. + if_option(vertex_position(Position_4), Opts, + call(Position_4, Vs, Opts, V, VPosition) + ), + + % Shape. + if_option(vertex_shape(Shape_2), Opts, call(Shape_2, V, VShape)), + + % URI + if_option(vertex_uri(Uri_2), Opts, call(Uri_2, V, VUri)), + + exclude( + option_has_var_value, + [ + color(VColor), + image(VImage), + label(VLabel), + peripheries(VPeripheries), + pos(VPosition), + shape(VShape), + 'URL'(VUri) + ], + VAttrs + ). + + + + + +% HELPERS % + +%! edge_components(+Edge:compound, -FromV, -ToV) is det. + +edge_components(edge(FromV,_,ToV), FromV, ToV):- !. +edge_components(edge(FromV,ToV), FromV, ToV):- !. +edge_components(FromV-ToV, FromV, ToV):- !. diff --git a/prolog/gv/gv_attr_type.pl b/prolog/gv/gv_attr_type.pl new file mode 100644 index 0000000..f55fce5 --- /dev/null +++ b/prolog/gv/gv_attr_type.pl @@ -0,0 +1,421 @@ +:- module( + gv_attr_type, + [ + gv_attr_type//1, % ?Type:atom + addDouble//1, % +Double:float + addPoint//1, % +Point:compound + arrowType//1, % +ArrowType:atom + bool//1, % +Boolean:boolean + clusterMode//1, % +ClusterMode:atom + dirType//1, % +DirectionType:oneof([back,both,forward,none]) + double//1, % +Double:float + doubleList//1, % +Doubles:list(float) + escString//1, + %layerList//1, + %layerRange//1, + lblString//1, + int//1, % +Integer:integer + outputMode//1, % +OutputMode:atom + %packMode//1, + pagedir//1, % +Pagedir:atom + point//1, % +Point:compound + pointList//1, % +Points:list(compound) + %portPos//1, + quadType//1, % +QuadType:atom + rankType//1, % +RankType:atom + rankdir//1, % +RankDirection:atom + rect//1, % +Rectangle:compound + shape//1, + smoothType//1, % +SmoothType:atom + %splineType//1, + %startType//1, + string//1, % ?Content:atom + style//2 % +Context:oneof([cluster,edge,node]) + % +Style:atom + %viewPort//1 + ] +). +:- reexport( + library(gv/gv_color), + [ + color//1, % +Color:compound + colorList//1 % +ColorList:list(compound) + ] +). + +/** GraphViz attribute types + +@author Wouter Beek +@version 2015/07, 2015/11, 2016/02 +*/ + +:- use_module(library(dcg/dcg_ext), except([string//1])). +:- use_module(library(gv/gv_html)). + + + + + +%! gv_attr_type(?Type:atom) is nondet. + +gv_attr_type(addDouble) --> "addDouble". +gv_attr_type(addPoint) --> "addPoint". +gv_attr_type(arrowType) --> "arrowType". +gv_attr_type(bool) --> "bool". +gv_attr_type(color) --> "color". +gv_attr_type(colorList) --> "colorList". +gv_attr_type(clusterMode) --> "clusterMode". +gv_attr_type(dirType) --> "dirType". +gv_attr_type(double) --> "double". +gv_attr_type(doubleList) --> "doubleList". +gv_attr_type(escString) --> "escString". +gv_attr_type(layerList) --> "layerList". +gv_attr_type(layerRange) --> "layerRange". +gv_attr_type(lblString) --> "lblString". +gv_attr_type(int) --> "int". +gv_attr_type(outputMode) --> "outputMode". +gv_attr_type(packMode) --> "packMode". +gv_attr_type(pagedir) --> "pagedir". +gv_attr_type(point) --> "point". +gv_attr_type(pointList) --> "pointList". +gv_attr_type(portPos) --> "portPos". +gv_attr_type(quadType) --> "quadType". +gv_attr_type(rankType) --> "rankType". +gv_attr_type(rankdir) --> "rankdir". +gv_attr_type(rect) --> "rect". +gv_attr_type(shape) --> "shape". +gv_attr_type(smoothType) --> "smoothType". +gv_attr_type(splineType) --> "splineType". +gv_attr_type(startType) --> "startType". +gv_attr_type(string) --> "string". +gv_attr_type(style) --> "style". +gv_attr_type(viewPort) --> "viewPort". + + + +%! addDouble(+Float:float)// . +% An *addDouble* is represented by a Prolog float. + +addDouble(N) --> ("+", ! ; ""), float(N). + + + +%! addPoint(+Point:compound)// . +% An *addPoint* is represented by a compound of the following form: +% `point(X:float,Y:float,InputOnly:boolean)`. + +addPoint(Point) --> ("+", ! ; ""), point(Point). + + + +%! arrowType(+ArrowType:atom)// . + +arrowType(V) --> primitive_shape(V). +arrowType(V) --> derived(V). +arrowType(V) --> backwards_compatible(V). + +primitive_shape(box) --> "box". +primitive_shape(crow) --> "crow". +primitive_shape(circle) --> "circle". +primitive_shape(diamond) --> "diamond". +primitive_shape(dot) --> "dot". +primitive_shape(inv) --> "inv". +primitive_shape(none) --> "none". +primitive_shape(normal) --> "normal". +primitive_shape(tee) --> "tee". +primitive_shape(vee) --> "vee". + +derived(odot) --> "odot". +derived(invdot) --> "invdot". +derived(invodot) --> "invodot". +derived(obox) --> "obox". +derived(odiamond) --> "odiamond". + +backwards_compatible(ediamond) --> "ediamond". +backwards_compatible(empty) --> "empty". +backwards_compatible(halfopen) --> "halfopen". +backwards_compatible(invempty) --> "invempty". +backwards_compatible(open) --> "open". + + + +%! bool(+Value:boolean)// . + +bool(false) --> "false". +bool(false) --> "no". +bool(true) --> "true". +bool(true) --> "yes". + + + +%! clusterMode(+ClusterMode:atom)// . + +clusterMode(global) --> "global". +clusterMode(local) --> "local". +clusterMode(none) --> "none". + + + +%! dirType(+DirectionType:oneof([back,both,forward,none]))// . + +dirType(back) --> "back". +dirType(both) --> "both". +dirType(forward) --> "forward". +dirType(none) --> "none". + + + +%! double(+Double:float)// . + +double(N) --> float(N). + + + +%! doubleList(+Doubles:list(float))// . + +doubleList([H|T]) --> double(H), (":", !, doubleList(T) ; {T = []}). + + + +%! escString(+String:or([atom,string]))// . +% @tbd Support for context-dependent replacements. + +escString(S1) --> + {( string(S1) + -> string_phrase(escape_double_quotes, S1, S2) + ; atom_phrase(escape_double_quotes, S1, S2) + )}, + "\"", atom(S2), "\"". + +escape_double_quotes, [0'\\,0'"] --> [0'"], !, escape_double_quotes. +escape_double_quotes, [X] --> [X], !, escape_double_quotes. +escape_double_quotes --> "". + + + +% @tbd layerList + + + +% @tbd layerRange + + + +%! lblString(+String:compound)// . + +lblString(html_like_label(V)) --> gv_html_like_label(V). +lblString(V) --> escString(V). + + + +%! int(+Integer:integer)// . + +int(V) --> integer(V). + + + +%! outputMode(+OutputMode:atom)// . + +outputMode(breadthfirst) --> "breadthfirst". +outputMode(edgesfirst) --> "edgesfirst". +outputMode(nodesfirst) --> "nodesfirst". + + + +% @tbd packMode + + + +%! pagedir(+PageDirection:atom)// . + +pagedir('BL') --> "BL". +pagedir('BR') --> "BR". +pagedir('LB') --> "LB". +pagedir('LT') --> "LT". +pagedir('RB') --> "RB". +pagedir('RT') --> "RT". +pagedir('TL') --> "TL". +pagedir('TR') --> "TR". + + + +%! point(+Point:compound)// . +% A *point* is represented by a compound of the following form: +% `point(X:float,Y:float,Changeable:boolean)`. + +point(point(X,Y,Changeable)) --> + float(X), ",", float(Y), + input_changeable(Changeable). + +input_changeable(false) --> "". +input_changeable(true) --> "!". + + + +%! pointList(+Points:list(compound))// . + +pointList(Points) --> + *(point, Points). + + + +% @tbd portPos + + + +%! quadType(+QuadType:atom)// . + +quadType(fast) --> "fast". +quadType(none) --> "none". +quadType(normal) --> "normal". + + + +%! rankType(+RankType:atom)// . + +rankType(max) --> "max". +rankType(min) --> "min". +rankType(same) --> "same". +rankType(sink) --> "sink". +rankType(source) --> "source". + + + +%! rankdir(+RankDirection:oneof(['BT','LR','RL','TB']))// . + +rankdir('BT') --> "BT". +rankdir('LR') --> "LR". +rankdir('RL') --> "RL". +rankdir('TB') --> "TB". + + + +%! rect(+Rectangle:compound)// . + +rect(rect(LowerLeftX,LowerLeftY,UpperRightX,UpperRightY)) --> + float(LowerLeftX), ",", + float(LowerLeftY), ",", + float(UpperRightX), ",", + float(UpperRightY). + + + +%! shape(+Shape:atom)// . + +shape(V) --> {polygon_based_shape(V)}, atom(V). + +polygon_based_shape(assembly). +polygon_based_shape(box). +polygon_based_shape(box3d). +polygon_based_shape(cds). +polygon_based_shape(circle). +polygon_based_shape(component). +polygon_based_shape(diamond). +polygon_based_shape(doublecircle). +polygon_based_shape(doubleoctagon). +polygon_based_shape(egg). +polygon_based_shape(ellipse). +polygon_based_shape(fivepoverhang). +polygon_based_shape(folder). +polygon_based_shape(hexagon). +polygon_based_shape(house). +polygon_based_shape(insulator). +polygon_based_shape(invhouse). +polygon_based_shape(invtrapezium). +polygon_based_shape(invtriangle). +polygon_based_shape(larrow). +polygon_based_shape(lpromoter). +polygon_based_shape('Mcircle'). +polygon_based_shape('Mdiamond'). +polygon_based_shape('Msquare'). +polygon_based_shape(none). +polygon_based_shape(note). +polygon_based_shape(noverhang). +polygon_based_shape(octagon). +polygon_based_shape(oval). +polygon_based_shape(parallelogram). +polygon_based_shape(pentagon). +polygon_based_shape(plaintext). +polygon_based_shape(point). +polygon_based_shape(polygon). +polygon_based_shape(primersite). +polygon_based_shape(promoter). +polygon_based_shape(proteasesite). +polygon_based_shape(proteinstab). +polygon_based_shape(rarrow). +polygon_based_shape(rect). +polygon_based_shape(rectangle). +polygon_based_shape(restrictionsite). +polygon_based_shape(ribosite). +polygon_based_shape(rnastab). +polygon_based_shape(rpromoter). +polygon_based_shape(septagon). +polygon_based_shape(signature). +polygon_based_shape(square). +polygon_based_shape(tab). +polygon_based_shape(terminator). +polygon_based_shape(threepoverhang). +polygon_based_shape(trapezium). +polygon_based_shape(triangle). +polygon_based_shape(tripleoctagon). +polygon_based_shape(utr). + + + +%! smoothType(+SmoothType:atom)// . + +smoothType(V) --> {smoothType(V)}, atom(V). + +smoothType(avg_dist). +smoothType(graph_dist). +smoothType(none). +smoothType(power_dist). +smoothType(rng). +smoothType(spring). +smoothType(triangle). + + + +% @tbd splineType + + + +% @tbd startType + + + +%! string(?String:atom)// . +% A GraphViz string. + +string(Content) --> "\"", atom(Content), "\"". + + + +%! style(?Context:oneof([cluster,edge,node]), ?Style:atom) is nondet. + +style(Context, Style) --> {style(Context, Style)}, atom(Style). + +style(cluster, bold). +style(cluster, dashed). +style(cluster, dotted). +style(cluster, filled). +style(cluster, rounded). +style(cluster, solid). +style(cluster, striped). +style(edge, bold). +style(edge, dashed). +style(edge, dotted). +style(edge, solid). +style(node, bold). +style(node, dashed). +style(node, diagonals). +style(node, dotted). +style(node, filled). +style(node, rounded). +style(node, solid). +style(node, striped). +style(node, wedged). + + + +% @tbd viewPort diff --git a/prolog/gv/gv_attrs.data b/prolog/gv/gv_attrs.data new file mode 100644 index 0000000..95fc680 --- /dev/null +++ b/prolog/gv/gv_attrs.data @@ -0,0 +1,169 @@ +gv_attr('Damping',[graph],[double],'0.99','0.0','neato only'). +gv_attr('K',[cluster,graph],[double],'0.3','0','sfdp, fdp only'). +gv_attr('URL',[cluster,edge,graph,node],[escString],_G59448,'','svg, postscript, map only'). +gv_attr('_background',[graph],[string],_G59644,'',''). +gv_attr(area,[cluster,node],[double],'1.0','>0','patchwork only'). +gv_attr(arrowhead,[edge],[arrowType],normal,'',''). +gv_attr(arrowsize,[edge],[double],'1.0','0.0',''). +gv_attr(arrowtail,[edge],[arrowType],normal,'',''). +gv_attr(bb,[graph],[rect],'','','write only'). +gv_attr(bgcolor,[cluster,graph],[color,colorList],_G60571,'',''). +gv_attr(center,[graph],[bool],false,'',''). +gv_attr(charset,[graph],[string],'"UTF-8"','',''). +gv_attr(clusterrank,[graph],[clusterMode],local,'','dot only'). +gv_attr(color,[cluster,edge,node],[color,colorList],black,'',''). +gv_attr(colorscheme,[cluster,edge,graph,node],[string],'','',''). +gv_attr(comment,[edge,graph,node],[string],'','',''). +gv_attr(compound,[graph],[bool],false,'','dot only'). +gv_attr(concentrate,[graph],[bool],false,'',''). +gv_attr(constraint,[edge],[bool],true,'','dot only'). +gv_attr(decorate,[edge],[bool],false,'',''). +gv_attr(defaultdist,[graph],[double],'1+(avg. len)*sqrt(|V|)',epsilon,'neato only'). +gv_attr(dim,[graph],[int],'2','2','sfdp, fdp, neato only'). +gv_attr(dimen,[graph],[int],'2','2','sfdp, fdp, neato only'). +gv_attr(dir,[edge],[dirType],'forward(directed)none(undirected)','',''). +gv_attr(diredgeconstraints,[graph],[string,bool],false,'','neato only'). +gv_attr(distortion,[node],[double],'0.0','-100.0',''). +gv_attr(dpi,[graph],[double],'96.00.0','','svg, bitmap output only'). +gv_attr(edgeURL,[edge],[escString],'','','svg, map only'). +gv_attr(edgehref,[edge],[escString],'','','svg, map only'). +gv_attr(edgetarget,[edge],[escString],_G63711,'','svg, map only'). +gv_attr(edgetooltip,[edge],[escString],'','','svg, cmap only'). +gv_attr(epsilon,[graph],[double],'.0001 * # nodes(mode == KK).0001(mode == major)','','neato only'). +gv_attr(esep,[graph],[addDouble,addPoint],'+3','','not dot'). +gv_attr(fillcolor,[cluster,edge,node],[color,colorList],'lightgrey(nodes)black(clusters)','',''). +gv_attr(fixedsize,[node],[bool,string],false,'',''). +gv_attr(fontcolor,[cluster,edge,graph,node],[color],black,'',''). +gv_attr(fontname,[cluster,edge,graph,node],[string],'"Times-Roman"','',''). +gv_attr(fontnames,[graph],[string],'','','svg only'). +gv_attr(fontpath,[graph],[string],'system-dependent','',''). +gv_attr(fontsize,[cluster,edge,graph,node],[double],'14.0','1.0',''). +gv_attr(forcelabels,[graph],[bool],true,'',''). +gv_attr(gradientangle,[cluster,graph,node],[int],'','',''). +gv_attr(group,[node],[string],'','','dot only'). +gv_attr(headURL,[edge],[escString],'','','svg, map only'). +gv_attr(head_lp,[edge],[point],'','','write only'). +gv_attr(headclip,[edge],[bool],true,'',''). +gv_attr(headhref,[edge],[escString],'','','svg, map only'). +gv_attr(headlabel,[edge],[lblString],'','',''). +gv_attr(headport,[edge],[portPos],center,'',''). +gv_attr(headtarget,[edge],[escString],_G4892,'','svg, map only'). +gv_attr(headtooltip,[edge],[escString],'','','svg, cmap only'). +gv_attr(height,[node],[double],'0.5','0.02',''). +gv_attr(href,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only'). +gv_attr(id,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only'). +gv_attr(image,[node],[string],'','',''). +gv_attr(imagepath,[graph],[string],'','',''). +gv_attr(imagescale,[node],[bool,string],false,'',''). +gv_attr(inputscale,[graph],[double],_G6250,'','fdp, neato only'). +gv_attr(label,[cluster,edge,graph,node],[lblString],'"\\N" (nodes)"" (otherwise)','',''). +gv_attr(labelURL,[edge],[escString],'','','svg, map only'). +gv_attr(label_scheme,[graph],[int],'0','0','sfdp only'). +gv_attr(labelangle,[edge],[double],'-25.0','-180.0',''). +gv_attr(labeldistance,[edge],[double],'1.0','0.0',''). +gv_attr(labelfloat,[edge],[bool],false,'',''). +gv_attr(labelfontcolor,[edge],[color],black,'',''). +gv_attr(labelfontname,[edge],[string],'"Times-Roman"','',''). +gv_attr(labelfontsize,[edge],[double],'14.0','1.0',''). +gv_attr(labelhref,[edge],[escString],'','','svg, map only'). +gv_attr(labeljust,[cluster,graph],[string],'"c"','',''). +gv_attr(labelloc,[cluster,graph,node],[string],'"t"(clusters)"b"(root graphs)"c"(nodes)','',''). +gv_attr(labeltarget,[edge],[escString],_G8276,'','svg, map only'). +gv_attr(labeltooltip,[edge],[escString],'','','svg, cmap only'). +gv_attr(landscape,[graph],[bool],false,'',''). +gv_attr(layer,[cluster,edge,node],[layerRange],'','',''). +gv_attr(layerlistsep,[graph],[string],'","','',''). +gv_attr(layers,[graph],[layerList],'','',''). +gv_attr(layerselect,[graph],[layerRange],'','',''). +gv_attr(layersep,[graph],[string],'" :\\t"','',''). +gv_attr(layout,[graph],[string],'','',''). +gv_attr(len,[edge],[double],'1.0(neato)0.3(fdp)','','fdp, neato only'). +gv_attr(levels,[graph],[int],'MAXINT','0.0','sfdp only'). +gv_attr(levelsgap,[graph],[double],'0.0','','neato only'). +gv_attr(lhead,[edge],[string],'','','dot only'). +gv_attr(lheight,[cluster,graph],[double],'','','write only'). +gv_attr(lp,[cluster,edge,graph],[point],'','','write only'). +gv_attr(ltail,[edge],[string],'','','dot only'). +gv_attr(lwidth,[cluster,graph],[double],'','','write only'). +gv_attr(margin,[cluster,graph,node],[double,point],'','',''). +gv_attr(maxiter,[graph],[int],'100 * # nodes(mode == KK)200(mode == major)600(fdp)','','fdp, neato only'). +gv_attr(mclimit,[graph],[double],'1.0','','dot only'). +gv_attr(mindist,[graph],[double],'1.0','0.0','circo only'). +gv_attr(minlen,[edge],[int],'1','0','dot only'). +gv_attr(mode,[graph],[string],major,'','neato only'). +gv_attr(model,[graph],[string],shortpath,'','neato only'). +gv_attr(mosek,[graph],[bool],false,'','neato only'). +gv_attr(nodesep,[graph],[double],'0.25','0.02',''). +gv_attr(nojustify,[cluster,edge,graph,node],[bool],false,'',''). +gv_attr(normalize,[graph],[double,bool],false,'','not dot'). +gv_attr(notranslate,[graph],[bool],false,'','neato only'). +gv_attr(nslimitnslimit1,[graph],[double],'','','dot only'). +gv_attr(ordering,[graph,node],[string],'','','dot only'). +gv_attr(orientation,[node],[double],'0.0','360.0',''). +gv_attr(orientation,[graph],[string],'','',''). +gv_attr(outputorder,[graph],[outputMode],breadthfirst,'',''). +gv_attr(overlap,[graph],[string,bool],true,'','not dot'). +gv_attr(overlap_scaling,[graph],[double],'-4','-1.0e10','prism only'). +gv_attr(overlap_shrink,[graph],[bool],true,'','prism only'). +gv_attr(pack,[graph],[bool,int],false,'',''). +gv_attr(packmode,[graph],[packMode],node,'',''). +gv_attr(pad,[graph],[double,point],'0.0555 (4 points)','',''). +gv_attr(page,[graph],[double,point],'','',''). +gv_attr(pagedir,[graph],[pagedir],'BL','',''). +gv_attr(pencolor,[cluster],[color],black,'',''). +gv_attr(penwidth,[cluster,edge,node],[double],'1.0','0.0',''). +gv_attr(peripheries,[cluster,node],[int],'shape default(nodes)1(clusters)','0',''). +gv_attr(pin,[node],[bool],false,'','fdp, neato only'). +gv_attr(pos,[edge,node],[point,splineType],'','',''). +gv_attr(quadtree,[graph],[quadType,bool],normal,'','sfdp only'). +gv_attr(quantum,[graph],[double],'0.0','0.0',''). +gv_attr(rank,[subgraph],[rankType],'','','dot only'). +gv_attr(rankdir,[graph],[rankdir],'TB','','dot only'). +gv_attr(ranksep,[graph],[double,doubleList],'0.5(dot)1.0(twopi)','0.02','twopi, dot only'). +gv_attr(ratio,[graph],[double,string],'','',''). +gv_attr(rects,[node],[rect],'','','write only'). +gv_attr(regular,[node],[bool],false,'',''). +gv_attr(remincross,[graph],[bool],true,'','dot only'). +gv_attr(repulsiveforce,[graph],[double],'1.0','0.0','sfdp only'). +gv_attr(resolution,[graph],[double],'96.00.0','','svg, bitmap output only'). +gv_attr(root,[graph,node],[string,bool],'(graphs)false(nodes)','','circo, twopi only'). +gv_attr(rotate,[graph],[int],'0','',''). +gv_attr(rotation,[graph],[double],'0','','sfdp only'). +gv_attr(samehead,[edge],[string],'','','dot only'). +gv_attr(sametail,[edge],[string],'','','dot only'). +gv_attr(samplepoints,[node],[int],'8(output)20(overlap and image maps)','',''). +gv_attr(scale,[graph],[double,point],'','','not dot'). +gv_attr(searchsize,[graph],[int],'30','','dot only'). +gv_attr(sep,[graph],[addDouble,addPoint],'+4','','not dot'). +gv_attr(shape,[node],[shape],ellipse,'',''). +gv_attr(shapefile,[node],[string],'','',''). +gv_attr(showboxes,[edge,graph,node],[int],'0','0','dot only'). +gv_attr(sides,[node],[int],'4','0',''). +gv_attr(size,[graph],[double,point],'','',''). +gv_attr(skew,[node],[double],'0.0','-100.0',''). +gv_attr(smoothing,[graph],[smoothType],'"none"','','sfdp only'). +gv_attr(sortv,[cluster,graph,node],[int],'0','0',''). +gv_attr(splines,[graph],[bool,string],'','',''). +gv_attr(start,[graph],[startType],'','','fdp, neato only'). +gv_attr(style,[cluster,edge,graph,node],[style],'','',''). +gv_attr(stylesheet,[graph],[string],'','','svg only'). +gv_attr(tailURL,[edge],[escString],'','','svg, map only'). +gv_attr(tail_lp,[edge],[point],'','','write only'). +gv_attr(tailclip,[edge],[bool],true,'',''). +gv_attr(tailhref,[edge],[escString],'','','svg, map only'). +gv_attr(taillabel,[edge],[lblString],'','',''). +gv_attr(tailport,[edge],[portPos],center,'',''). +gv_attr(tailtarget,[edge],[escString],_G21528,'','svg, map only'). +gv_attr(tailtooltip,[edge],[escString],'','','svg, cmap only'). +gv_attr(target,[cluster,edge,graph,node],[escString,string],_G21878,'','svg, map only'). +gv_attr(tooltip,[cluster,edge,node],[escString],'','','svg, cmap only'). +gv_attr(truecolor,[graph],[bool],'','','bitmap output only'). +gv_attr(vertices,[node],[pointList],'','','write only'). +gv_attr(viewport,[graph],[viewPort],'','',''). +gv_attr(voro_margin,[graph],[double],'0.05','0.0','not dot'). +gv_attr(weight,[edge],[int,double],'1','0(dot,twopi)1(neato,fdp)',''). +gv_attr(width,[node],[double],'0.75','0.01',''). +gv_attr(xdotversion,[graph],[string],'','','xdot only'). +gv_attr(xlabel,[edge,node],[lblString],'','',''). +gv_attr(xlp,[edge,node],[point],'','','write only'). +gv_attr(z,[node],[double],'0.0','-MAXFLOAT-1000',''). diff --git a/prolog/gv/gv_attrs.pl b/prolog/gv/gv_attrs.pl new file mode 100644 index 0000000..4a92d5b --- /dev/null +++ b/prolog/gv/gv_attrs.pl @@ -0,0 +1,76 @@ +:- module( + gv_attrs, + [ + gv_attr_value//2 % +Context:oneof([cluster,edge,graph,node,subgraph]) + % +Attr + ] +). +:- ensure_loaded(library('gv/gv_attrs.data')). + +/** GraphViz attributes + +@author Wouter Beek +@version 2015/07-2015/08, 2015/10, 2016/03 +*/ + +:- use_module(library(apply)). +:- use_module(library(dcg/dcg_ext)). +:- use_module(library(error)). +:- use_module(library(gv/gv_attr_type), [gv_attr_type//1]). +:- use_module(library(lists)). +:- use_module(library(os/file_ext)). + + + + + +%! gv_attr_value(+Context, +Attr)// is det. +% Uses the default value in case Value is uninstantiated. +% Otherwise, performs a typecheck and converts the given value. +% +% Context can be either `cluster`, `edge`, `graph`, `node` or `subgraph`. + +% Use the default if no value is given. +gv_attr_value(Context, Name=Value) --> + { + var(Value), + gv_attr(Name, UsedBy, _, DefaultValue, _, _), + % Check validity of context. + memberchk(Context, UsedBy) + }, !, + gv_attr_value(Context, Name=DefaultValue). +gv_attr_value(Context, Name=Value) --> + { + % Check the validity of the context argument. + gv_attr(Name, UsedBy, Types, _, Minimum, _), + memberchk(Context, UsedBy), + + % Pick a value type non-deterministically. + member(Type, Types), + + % The `style` type is the only one that requires the context argument. + ( Type == style + -> Dcg =.. [Type,Context] + ; Dcg =.. [Type] + ), + + % Check validity of Value w.r.t. minimum value -- if available. + check_minimum(Value, Minimum) + }, !, + dcg_call(gv_attr_type:Dcg, Value). +gv_attr_value(_, Name=_) --> + {existence_error(gv_attr, Name)}. + + + + + +% HELPERS % + +%! check_minimum(+Value:atom, +Minimum:number) is semidet. +% Trivially succeeds if no minimum value is available for a given attribute. + +check_minimum(_, ''):- !. +check_minimum(V, Min1):- + atom_number(Min1, Min2), + Min2 =< V. diff --git a/prolog/gv/gv_color.data b/prolog/gv/gv_color.data new file mode 100644 index 0000000..166b13c --- /dev/null +++ b/prolog/gv/gv_color.data @@ -0,0 +1,802 @@ +gv_color(x11,aliceblue). +gv_color(x11,antiquewhite). +gv_color(x11,antiquewhite1). +gv_color(x11,antiquewhite2). +gv_color(x11,antiquewhite3). +gv_color(x11,antiquewhite4). +gv_color(x11,aquamarine). +gv_color(x11,aquamarine1). +gv_color(x11,aquamarine2). +gv_color(x11,aquamarine3). +gv_color(x11,aquamarine4). +gv_color(x11,azure). +gv_color(x11,azure1). +gv_color(x11,azure2). +gv_color(x11,azure3). +gv_color(x11,azure4). +gv_color(x11,beige). +gv_color(x11,bisque). +gv_color(x11,bisque1). +gv_color(x11,bisque2). +gv_color(x11,bisque3). +gv_color(x11,bisque4). +gv_color(x11,black). +gv_color(x11,blanchedalmond). +gv_color(x11,blue). +gv_color(x11,blue1). +gv_color(x11,blue2). +gv_color(x11,blue3). +gv_color(x11,blue4). +gv_color(x11,blueviolet). +gv_color(x11,brown). +gv_color(x11,brown1). +gv_color(x11,brown2). +gv_color(x11,brown3). +gv_color(x11,brown4). +gv_color(x11,burlywood). +gv_color(x11,burlywood1). +gv_color(x11,burlywood2). +gv_color(x11,burlywood3). +gv_color(x11,burlywood4). +gv_color(x11,cadetblue). +gv_color(x11,cadetblue1). +gv_color(x11,cadetblue2). +gv_color(x11,cadetblue3). +gv_color(x11,cadetblue4). +gv_color(x11,chartreuse). +gv_color(x11,chartreuse1). +gv_color(x11,chartreuse2). +gv_color(x11,chartreuse3). +gv_color(x11,chartreuse4). +gv_color(x11,chocolate). +gv_color(x11,chocolate1). +gv_color(x11,chocolate2). +gv_color(x11,chocolate3). +gv_color(x11,chocolate4). +gv_color(x11,coral). +gv_color(x11,coral1). +gv_color(x11,coral2). +gv_color(x11,coral3). +gv_color(x11,coral4). +gv_color(x11,cornflowerblue). +gv_color(x11,cornsilk). +gv_color(x11,cornsilk1). +gv_color(x11,cornsilk2). +gv_color(x11,cornsilk3). +gv_color(x11,cornsilk4). +gv_color(x11,crimson). +gv_color(x11,cyan). +gv_color(x11,cyan1). +gv_color(x11,cyan2). +gv_color(x11,cyan3). +gv_color(x11,cyan4). +gv_color(x11,darkgoldenrod). +gv_color(x11,darkgoldenrod1). +gv_color(x11,darkgoldenrod2). +gv_color(x11,darkgoldenrod3). +gv_color(x11,darkgoldenrod4). +gv_color(x11,darkgreen). +gv_color(x11,darkkhaki). +gv_color(x11,darkolivegreen). +gv_color(x11,darkolivegreen1). +gv_color(x11,darkolivegreen2). +gv_color(x11,darkolivegreen3). +gv_color(x11,darkolivegreen4). +gv_color(x11,darkorange). +gv_color(x11,darkorange1). +gv_color(x11,darkorange2). +gv_color(x11,darkorange3). +gv_color(x11,darkorange4). +gv_color(x11,darkorchid). +gv_color(x11,darkorchid1). +gv_color(x11,darkorchid2). +gv_color(x11,darkorchid3). +gv_color(x11,darkorchid4). +gv_color(x11,darksalmon). +gv_color(x11,darkseagreen). +gv_color(x11,darkseagreen1). +gv_color(x11,darkseagreen2). +gv_color(x11,darkseagreen3). +gv_color(x11,darkseagreen4). +gv_color(x11,darkslateblue). +gv_color(x11,darkslategray). +gv_color(x11,darkslategray1). +gv_color(x11,darkslategray2). +gv_color(x11,darkslategray3). +gv_color(x11,darkslategray4). +gv_color(x11,darkslategrey). +gv_color(x11,darkturquoise). +gv_color(x11,darkviolet). +gv_color(x11,deeppink). +gv_color(x11,deeppink1). +gv_color(x11,deeppink2). +gv_color(x11,deeppink3). +gv_color(x11,deeppink4). +gv_color(x11,deepskyblue). +gv_color(x11,deepskyblue1). +gv_color(x11,deepskyblue2). +gv_color(x11,deepskyblue3). +gv_color(x11,deepskyblue4). +gv_color(x11,dimgray). +gv_color(x11,dimgrey). +gv_color(x11,dodgerblue). +gv_color(x11,dodgerblue1). +gv_color(x11,dodgerblue2). +gv_color(x11,dodgerblue3). +gv_color(x11,dodgerblue4). +gv_color(x11,firebrick). +gv_color(x11,firebrick1). +gv_color(x11,firebrick2). +gv_color(x11,firebrick3). +gv_color(x11,firebrick4). +gv_color(x11,floralwhite). +gv_color(x11,forestgreen). +gv_color(x11,gainsboro). +gv_color(x11,ghostwhite). +gv_color(x11,gold). +gv_color(x11,gold1). +gv_color(x11,gold2). +gv_color(x11,gold3). +gv_color(x11,gold4). +gv_color(x11,goldenrod). +gv_color(x11,goldenrod1). +gv_color(x11,goldenrod2). +gv_color(x11,goldenrod3). +gv_color(x11,goldenrod4). +gv_color(x11,gray). +gv_color(x11,gray0). +gv_color(x11,gray1). +gv_color(x11,gray10). +gv_color(x11,gray100). +gv_color(x11,gray11). +gv_color(x11,gray12). +gv_color(x11,gray13). +gv_color(x11,gray14). +gv_color(x11,gray15). +gv_color(x11,gray16). +gv_color(x11,gray17). +gv_color(x11,gray18). +gv_color(x11,gray19). +gv_color(x11,gray2). +gv_color(x11,gray20). +gv_color(x11,gray21). +gv_color(x11,gray22). +gv_color(x11,gray23). +gv_color(x11,gray24). +gv_color(x11,gray25). +gv_color(x11,gray26). +gv_color(x11,gray27). +gv_color(x11,gray28). +gv_color(x11,gray29). +gv_color(x11,gray3). +gv_color(x11,gray30). +gv_color(x11,gray31). +gv_color(x11,gray32). +gv_color(x11,gray33). +gv_color(x11,gray34). +gv_color(x11,gray35). +gv_color(x11,gray36). +gv_color(x11,gray37). +gv_color(x11,gray38). +gv_color(x11,gray39). +gv_color(x11,gray4). +gv_color(x11,gray40). +gv_color(x11,gray41). +gv_color(x11,gray42). +gv_color(x11,gray43). +gv_color(x11,gray44). +gv_color(x11,gray45). +gv_color(x11,gray46). +gv_color(x11,gray47). +gv_color(x11,gray48). +gv_color(x11,gray49). +gv_color(x11,gray5). +gv_color(x11,gray50). +gv_color(x11,gray51). +gv_color(x11,gray52). +gv_color(x11,gray53). +gv_color(x11,gray54). +gv_color(x11,gray55). +gv_color(x11,gray56). +gv_color(x11,gray57). +gv_color(x11,gray58). +gv_color(x11,gray59). +gv_color(x11,gray6). +gv_color(x11,gray60). +gv_color(x11,gray61). +gv_color(x11,gray62). +gv_color(x11,gray63). +gv_color(x11,gray64). +gv_color(x11,gray65). +gv_color(x11,gray66). +gv_color(x11,gray67). +gv_color(x11,gray68). +gv_color(x11,gray69). +gv_color(x11,gray7). +gv_color(x11,gray70). +gv_color(x11,gray71). +gv_color(x11,gray72). +gv_color(x11,gray73). +gv_color(x11,gray74). +gv_color(x11,gray75). +gv_color(x11,gray76). +gv_color(x11,gray77). +gv_color(x11,gray78). +gv_color(x11,gray79). +gv_color(x11,gray8). +gv_color(x11,gray80). +gv_color(x11,gray81). +gv_color(x11,gray82). +gv_color(x11,gray83). +gv_color(x11,gray84). +gv_color(x11,gray85). +gv_color(x11,gray86). +gv_color(x11,gray87). +gv_color(x11,gray88). +gv_color(x11,gray89). +gv_color(x11,gray9). +gv_color(x11,gray90). +gv_color(x11,gray91). +gv_color(x11,gray92). +gv_color(x11,gray93). +gv_color(x11,gray94). +gv_color(x11,gray95). +gv_color(x11,gray96). +gv_color(x11,gray97). +gv_color(x11,gray98). +gv_color(x11,gray99). +gv_color(x11,green). +gv_color(x11,green1). +gv_color(x11,green2). +gv_color(x11,green3). +gv_color(x11,green4). +gv_color(x11,greenyellow). +gv_color(x11,grey). +gv_color(x11,grey0). +gv_color(x11,grey1). +gv_color(x11,grey10). +gv_color(x11,grey100). +gv_color(x11,grey11). +gv_color(x11,grey12). +gv_color(x11,grey13). +gv_color(x11,grey14). +gv_color(x11,grey15). +gv_color(x11,grey16). +gv_color(x11,grey17). +gv_color(x11,grey18). +gv_color(x11,grey19). +gv_color(x11,grey2). +gv_color(x11,grey20). +gv_color(x11,grey21). +gv_color(x11,grey22). +gv_color(x11,grey23). +gv_color(x11,grey24). +gv_color(x11,grey25). +gv_color(x11,grey26). +gv_color(x11,grey27). +gv_color(x11,grey28). +gv_color(x11,grey29). +gv_color(x11,grey3). +gv_color(x11,grey30). +gv_color(x11,grey31). +gv_color(x11,grey32). +gv_color(x11,grey33). +gv_color(x11,grey34). +gv_color(x11,grey35). +gv_color(x11,grey36). +gv_color(x11,grey37). +gv_color(x11,grey38). +gv_color(x11,grey39). +gv_color(x11,grey4). +gv_color(x11,grey40). +gv_color(x11,grey41). +gv_color(x11,grey42). +gv_color(x11,grey43). +gv_color(x11,grey44). +gv_color(x11,grey45). +gv_color(x11,grey46). +gv_color(x11,grey47). +gv_color(x11,grey48). +gv_color(x11,grey49). +gv_color(x11,grey5). +gv_color(x11,grey50). +gv_color(x11,grey51). +gv_color(x11,grey52). +gv_color(x11,grey53). +gv_color(x11,grey54). +gv_color(x11,grey55). +gv_color(x11,grey56). +gv_color(x11,grey57). +gv_color(x11,grey58). +gv_color(x11,grey59). +gv_color(x11,grey6). +gv_color(x11,grey60). +gv_color(x11,grey61). +gv_color(x11,grey62). +gv_color(x11,grey63). +gv_color(x11,grey64). +gv_color(x11,grey65). +gv_color(x11,grey66). +gv_color(x11,grey67). +gv_color(x11,grey68). +gv_color(x11,grey69). +gv_color(x11,grey7). +gv_color(x11,grey70). +gv_color(x11,grey71). +gv_color(x11,grey72). +gv_color(x11,grey73). +gv_color(x11,grey74). +gv_color(x11,grey75). +gv_color(x11,grey76). +gv_color(x11,grey77). +gv_color(x11,grey78). +gv_color(x11,grey79). +gv_color(x11,grey8). +gv_color(x11,grey80). +gv_color(x11,grey81). +gv_color(x11,grey82). +gv_color(x11,grey83). +gv_color(x11,grey84). +gv_color(x11,grey85). +gv_color(x11,grey86). +gv_color(x11,grey87). +gv_color(x11,grey88). +gv_color(x11,grey89). +gv_color(x11,grey9). +gv_color(x11,grey90). +gv_color(x11,grey91). +gv_color(x11,grey92). +gv_color(x11,grey93). +gv_color(x11,grey94). +gv_color(x11,grey95). +gv_color(x11,grey96). +gv_color(x11,grey97). +gv_color(x11,grey98). +gv_color(x11,grey99). +gv_color(x11,honeydew). +gv_color(x11,honeydew1). +gv_color(x11,honeydew2). +gv_color(x11,honeydew3). +gv_color(x11,honeydew4). +gv_color(x11,hotpink). +gv_color(x11,hotpink1). +gv_color(x11,hotpink2). +gv_color(x11,hotpink3). +gv_color(x11,hotpink4). +gv_color(x11,indianred). +gv_color(x11,indianred1). +gv_color(x11,indianred2). +gv_color(x11,indianred3). +gv_color(x11,indianred4). +gv_color(x11,indigo). +gv_color(x11,invis). +gv_color(x11,ivory). +gv_color(x11,ivory1). +gv_color(x11,ivory2). +gv_color(x11,ivory3). +gv_color(x11,ivory4). +gv_color(x11,khaki). +gv_color(x11,khaki1). +gv_color(x11,khaki2). +gv_color(x11,khaki3). +gv_color(x11,khaki4). +gv_color(x11,lavender). +gv_color(x11,lavenderblush). +gv_color(x11,lavenderblush1). +gv_color(x11,lavenderblush2). +gv_color(x11,lavenderblush3). +gv_color(x11,lavenderblush4). +gv_color(x11,lawngreen). +gv_color(x11,lemonchiffon). +gv_color(x11,lemonchiffon1). +gv_color(x11,lemonchiffon2). +gv_color(x11,lemonchiffon3). +gv_color(x11,lemonchiffon4). +gv_color(x11,lightblue). +gv_color(x11,lightblue1). +gv_color(x11,lightblue2). +gv_color(x11,lightblue3). +gv_color(x11,lightblue4). +gv_color(x11,lightcoral). +gv_color(x11,lightcyan). +gv_color(x11,lightcyan1). +gv_color(x11,lightcyan2). +gv_color(x11,lightcyan3). +gv_color(x11,lightcyan4). +gv_color(x11,lightgoldenrod). +gv_color(x11,lightgoldenrod1). +gv_color(x11,lightgoldenrod2). +gv_color(x11,lightgoldenrod3). +gv_color(x11,lightgoldenrod4). +gv_color(x11,lightgoldenrodyellow). +gv_color(x11,lightgray). +gv_color(x11,lightgrey). +gv_color(x11,lightpink). +gv_color(x11,lightpink1). +gv_color(x11,lightpink2). +gv_color(x11,lightpink3). +gv_color(x11,lightpink4). +gv_color(x11,lightsalmon). +gv_color(x11,lightsalmon1). +gv_color(x11,lightsalmon2). +gv_color(x11,lightsalmon3). +gv_color(x11,lightsalmon4). +gv_color(x11,lightseagreen). +gv_color(x11,lightskyblue). +gv_color(x11,lightskyblue1). +gv_color(x11,lightskyblue2). +gv_color(x11,lightskyblue3). +gv_color(x11,lightskyblue4). +gv_color(x11,lightslateblue). +gv_color(x11,lightslategray). +gv_color(x11,lightslategrey). +gv_color(x11,lightsteelblue). +gv_color(x11,lightsteelblue1). +gv_color(x11,lightsteelblue2). +gv_color(x11,lightsteelblue3). +gv_color(x11,lightsteelblue4). +gv_color(x11,lightyellow). +gv_color(x11,lightyellow1). +gv_color(x11,lightyellow2). +gv_color(x11,lightyellow3). +gv_color(x11,lightyellow4). +gv_color(x11,limegreen). +gv_color(x11,linen). +gv_color(x11,magenta). +gv_color(x11,magenta1). +gv_color(x11,magenta2). +gv_color(x11,magenta3). +gv_color(x11,magenta4). +gv_color(x11,maroon). +gv_color(x11,maroon1). +gv_color(x11,maroon2). +gv_color(x11,maroon3). +gv_color(x11,maroon4). +gv_color(x11,mediumaquamarine). +gv_color(x11,mediumblue). +gv_color(x11,mediumorchid). +gv_color(x11,mediumorchid1). +gv_color(x11,mediumorchid2). +gv_color(x11,mediumorchid3). +gv_color(x11,mediumorchid4). +gv_color(x11,mediumpurple). +gv_color(x11,mediumpurple1). +gv_color(x11,mediumpurple2). +gv_color(x11,mediumpurple3). +gv_color(x11,mediumpurple4). +gv_color(x11,mediumseagreen). +gv_color(x11,mediumslateblue). +gv_color(x11,mediumspringgreen). +gv_color(x11,mediumturquoise). +gv_color(x11,mediumvioletred). +gv_color(x11,midnightblue). +gv_color(x11,mintcream). +gv_color(x11,mistyrose). +gv_color(x11,mistyrose1). +gv_color(x11,mistyrose2). +gv_color(x11,mistyrose3). +gv_color(x11,mistyrose4). +gv_color(x11,moccasin). +gv_color(x11,navajowhite). +gv_color(x11,navajowhite1). +gv_color(x11,navajowhite2). +gv_color(x11,navajowhite3). +gv_color(x11,navajowhite4). +gv_color(x11,navy). +gv_color(x11,navyblue). +gv_color(x11,none). +gv_color(x11,oldlace). +gv_color(x11,olivedrab). +gv_color(x11,olivedrab1). +gv_color(x11,olivedrab2). +gv_color(x11,olivedrab3). +gv_color(x11,olivedrab4). +gv_color(x11,orange). +gv_color(x11,orange1). +gv_color(x11,orange2). +gv_color(x11,orange3). +gv_color(x11,orange4). +gv_color(x11,orangered). +gv_color(x11,orangered1). +gv_color(x11,orangered2). +gv_color(x11,orangered3). +gv_color(x11,orangered4). +gv_color(x11,orchid). +gv_color(x11,orchid1). +gv_color(x11,orchid2). +gv_color(x11,orchid3). +gv_color(x11,orchid4). +gv_color(x11,palegoldenrod). +gv_color(x11,palegreen). +gv_color(x11,palegreen1). +gv_color(x11,palegreen2). +gv_color(x11,palegreen3). +gv_color(x11,palegreen4). +gv_color(x11,paleturquoise). +gv_color(x11,paleturquoise1). +gv_color(x11,paleturquoise2). +gv_color(x11,paleturquoise3). +gv_color(x11,paleturquoise4). +gv_color(x11,palevioletred). +gv_color(x11,palevioletred1). +gv_color(x11,palevioletred2). +gv_color(x11,palevioletred3). +gv_color(x11,palevioletred4). +gv_color(x11,papayawhip). +gv_color(x11,peachpuff). +gv_color(x11,peachpuff1). +gv_color(x11,peachpuff2). +gv_color(x11,peachpuff3). +gv_color(x11,peachpuff4). +gv_color(x11,peru). +gv_color(x11,pink). +gv_color(x11,pink1). +gv_color(x11,pink2). +gv_color(x11,pink3). +gv_color(x11,pink4). +gv_color(x11,plum). +gv_color(x11,plum1). +gv_color(x11,plum2). +gv_color(x11,plum3). +gv_color(x11,plum4). +gv_color(x11,powderblue). +gv_color(x11,purple). +gv_color(x11,purple1). +gv_color(x11,purple2). +gv_color(x11,purple3). +gv_color(x11,purple4). +gv_color(x11,red). +gv_color(x11,red1). +gv_color(x11,red2). +gv_color(x11,red3). +gv_color(x11,red4). +gv_color(x11,rosybrown). +gv_color(x11,rosybrown1). +gv_color(x11,rosybrown2). +gv_color(x11,rosybrown3). +gv_color(x11,rosybrown4). +gv_color(x11,royalblue). +gv_color(x11,royalblue1). +gv_color(x11,royalblue2). +gv_color(x11,royalblue3). +gv_color(x11,royalblue4). +gv_color(x11,saddlebrown). +gv_color(x11,salmon). +gv_color(x11,salmon1). +gv_color(x11,salmon2). +gv_color(x11,salmon3). +gv_color(x11,salmon4). +gv_color(x11,sandybrown). +gv_color(x11,seagreen). +gv_color(x11,seagreen1). +gv_color(x11,seagreen2). +gv_color(x11,seagreen3). +gv_color(x11,seagreen4). +gv_color(x11,seashell). +gv_color(x11,seashell1). +gv_color(x11,seashell2). +gv_color(x11,seashell3). +gv_color(x11,seashell4). +gv_color(x11,sienna). +gv_color(x11,sienna1). +gv_color(x11,sienna2). +gv_color(x11,sienna3). +gv_color(x11,sienna4). +gv_color(x11,skyblue). +gv_color(x11,skyblue1). +gv_color(x11,skyblue2). +gv_color(x11,skyblue3). +gv_color(x11,skyblue4). +gv_color(x11,slateblue). +gv_color(x11,slateblue1). +gv_color(x11,slateblue2). +gv_color(x11,slateblue3). +gv_color(x11,slateblue4). +gv_color(x11,slategray). +gv_color(x11,slategray1). +gv_color(x11,slategray2). +gv_color(x11,slategray3). +gv_color(x11,slategray4). +gv_color(x11,slategrey). +gv_color(x11,snow). +gv_color(x11,snow1). +gv_color(x11,snow2). +gv_color(x11,snow3). +gv_color(x11,snow4). +gv_color(x11,springgreen). +gv_color(x11,springgreen1). +gv_color(x11,springgreen2). +gv_color(x11,springgreen3). +gv_color(x11,springgreen4). +gv_color(x11,steelblue). +gv_color(x11,steelblue1). +gv_color(x11,steelblue2). +gv_color(x11,steelblue3). +gv_color(x11,steelblue4). +gv_color(x11,tan). +gv_color(x11,tan1). +gv_color(x11,tan2). +gv_color(x11,tan3). +gv_color(x11,tan4). +gv_color(x11,thistle). +gv_color(x11,thistle1). +gv_color(x11,thistle2). +gv_color(x11,thistle3). +gv_color(x11,thistle4). +gv_color(x11,tomato). +gv_color(x11,tomato1). +gv_color(x11,tomato2). +gv_color(x11,tomato3). +gv_color(x11,tomato4). +gv_color(x11,transparent). +gv_color(x11,turquoise). +gv_color(x11,turquoise1). +gv_color(x11,turquoise2). +gv_color(x11,turquoise3). +gv_color(x11,turquoise4). +gv_color(x11,violet). +gv_color(x11,violetred). +gv_color(x11,violetred1). +gv_color(x11,violetred2). +gv_color(x11,violetred3). +gv_color(x11,violetred4). +gv_color(x11,wheat). +gv_color(x11,wheat1). +gv_color(x11,wheat2). +gv_color(x11,wheat3). +gv_color(x11,wheat4). +gv_color(x11,white). +gv_color(x11,whitesmoke). +gv_color(x11,yellow). +gv_color(x11,yellow1). +gv_color(x11,yellow2). +gv_color(x11,yellow3). +gv_color(x11,yellow4). +gv_color(x11,yellowgreen). +gv_color(svg,aliceblue). +gv_color(svg,antiquewhite). +gv_color(svg,aqua). +gv_color(svg,aquamarine). +gv_color(svg,azure). +gv_color(svg,beige). +gv_color(svg,bisque). +gv_color(svg,black). +gv_color(svg,blanchedalmond). +gv_color(svg,blue). +gv_color(svg,blueviolet). +gv_color(svg,brown). +gv_color(svg,burlywood). +gv_color(svg,cadetblue). +gv_color(svg,chartreuse). +gv_color(svg,chocolate). +gv_color(svg,coral). +gv_color(svg,cornflowerblue). +gv_color(svg,cornsilk). +gv_color(svg,crimson). +gv_color(svg,cyan). +gv_color(svg,darkblue). +gv_color(svg,darkcyan). +gv_color(svg,darkgoldenrod). +gv_color(svg,darkgray). +gv_color(svg,darkgreen). +gv_color(svg,darkgrey). +gv_color(svg,darkkhaki). +gv_color(svg,darkmagenta). +gv_color(svg,darkolivegreen). +gv_color(svg,darkorange). +gv_color(svg,darkorchid). +gv_color(svg,darkred). +gv_color(svg,darksalmon). +gv_color(svg,darkseagreen). +gv_color(svg,darkslateblue). +gv_color(svg,darkslategray). +gv_color(svg,darkslategrey). +gv_color(svg,darkturquoise). +gv_color(svg,darkviolet). +gv_color(svg,deeppink). +gv_color(svg,deepskyblue). +gv_color(svg,dimgray). +gv_color(svg,dimgrey). +gv_color(svg,dodgerblue). +gv_color(svg,firebrick). +gv_color(svg,floralwhite). +gv_color(svg,forestgreen). +gv_color(svg,fuchsia). +gv_color(svg,gainsboro). +gv_color(svg,ghostwhite). +gv_color(svg,gold). +gv_color(svg,goldenrod). +gv_color(svg,gray). +gv_color(svg,grey). +gv_color(svg,green). +gv_color(svg,greenyellow). +gv_color(svg,honeydew). +gv_color(svg,hotpink). +gv_color(svg,indianred). +gv_color(svg,indigo). +gv_color(svg,ivory). +gv_color(svg,khaki). +gv_color(svg,lavender). +gv_color(svg,lavenderblush). +gv_color(svg,lawngreen). +gv_color(svg,lemonchiffon). +gv_color(svg,lightblue). +gv_color(svg,lightcoral). +gv_color(svg,lightcyan). +gv_color(svg,lightgoldenrodyellow). +gv_color(svg,lightgray). +gv_color(svg,lightgreen). +gv_color(svg,lightgrey). +gv_color(svg,lightpink). +gv_color(svg,lightsalmon). +gv_color(svg,lightseagreen). +gv_color(svg,lightskyblue). +gv_color(svg,lightslategray). +gv_color(svg,lightslategrey). +gv_color(svg,lightsteelblue). +gv_color(svg,lightyellow). +gv_color(svg,lime). +gv_color(svg,limegreen). +gv_color(svg,linen). +gv_color(svg,magenta). +gv_color(svg,maroon). +gv_color(svg,mediumaquamarine). +gv_color(svg,mediumblue). +gv_color(svg,mediumorchid). +gv_color(svg,mediumpurple). +gv_color(svg,mediumseagreen). +gv_color(svg,mediumslateblue). +gv_color(svg,mediumspringgreen). +gv_color(svg,mediumturquoise). +gv_color(svg,mediumvioletred). +gv_color(svg,midnightblue). +gv_color(svg,mintcream). +gv_color(svg,mistyrose). +gv_color(svg,moccasin). +gv_color(svg,navajowhite). +gv_color(svg,navy). +gv_color(svg,oldlace). +gv_color(svg,olive). +gv_color(svg,olivedrab). +gv_color(svg,orange). +gv_color(svg,orangered). +gv_color(svg,orchid). +gv_color(svg,palegoldenrod). +gv_color(svg,palegreen). +gv_color(svg,paleturquoise). +gv_color(svg,palevioletred). +gv_color(svg,papayawhip). +gv_color(svg,peachpuff). +gv_color(svg,peru). +gv_color(svg,pink). +gv_color(svg,plum). +gv_color(svg,powderblue). +gv_color(svg,purple). +gv_color(svg,red). +gv_color(svg,rosybrown). +gv_color(svg,royalblue). +gv_color(svg,saddlebrown). +gv_color(svg,salmon). +gv_color(svg,sandybrown). +gv_color(svg,seagreen). +gv_color(svg,seashell). +gv_color(svg,sienna). +gv_color(svg,silver). +gv_color(svg,skyblue). +gv_color(svg,slateblue). +gv_color(svg,slategray). +gv_color(svg,slategrey). +gv_color(svg,snow). +gv_color(svg,springgreen). +gv_color(svg,steelblue). +gv_color(svg,tan). +gv_color(svg,teal). +gv_color(svg,thistle). +gv_color(svg,tomato). +gv_color(svg,turquoise). +gv_color(svg,violet). +gv_color(svg,wheat). +gv_color(svg,white). +gv_color(svg,whitesmoke). +gv_color(svg,yellow). +gv_color(svg,yellowgreen). diff --git a/prolog/gv/gv_color.pl b/prolog/gv/gv_color.pl new file mode 100644 index 0000000..ac319dc --- /dev/null +++ b/prolog/gv/gv_color.pl @@ -0,0 +1,68 @@ +:- module( + gv_color, + [ + gv_color/2, % ?Colorscheme:oneof([svg,x11]) + % ?Color:atom + color//1, % +Color:compound + colorList//1 % +Pairs:list(pair(compound,float)) + ] +). +:- ensure_loaded(library('gv/gv_color.data')). + +/** GraphViz color + +@author Wouter Beek +@tbd Color value `transparent` is only available in the output formats + ps, svg, fig, vmrl, and the bitmap formats. +@version 2015/08, 2015/10, 2016/02 +*/ + +:- use_module(library(apply)). +:- use_module(library(dcg/dcg_ext)). +:- use_module(library(lists)). +:- use_module(library(os/file_ext)). + + + + + +% color(+Color:compound)// . +% A *color* is represented by a compound term of one of the following forms: +% 1. `rgb(Red:nonneg,Green:nonneg,Blue:nonneg)` +% 2. `rgba(Red:nonneg,Green:nonneg,Blue:nonneg,Alpha:nonneg)` +% 3. `hsv(Hue:between(0.0,1.0),Saturation:between(0.0,1.0),Value:between(0.0,1.0))` + +color(rgb(Red,Green,Blue)) --> !, + "#", + #(3, hex_color, [Red,Green,Blue]). +color(rgbs(Red,Green,Blue,Alpha)) --> !, + color(rgb(Red,Green,Blue)), + hex_color(Alpha). +color(hsv(Hue,Saturation,Value)) --> !, + #(3, hsv_color, [Hue,Saturation,Value]). +color(Name) --> + {gv_color(_, Name)}, + atom(Name). + +hex_color(I) --> + xinteger(I). + +hsv_color(D, Head, Tail):- + format(codes(Head,Tail), '~2f', [D]). + + + +%! colorList(+Pairs:list(pair(compound,float)))// . + +colorList(L) --> + '+'(wc, L). + +wc(Color-Float) --> + color(Color), + ( wc_weight(Float) + ; "" + ). + +wc_weight(Float) --> + ";", + float(Float). diff --git a/prolog/gv/gv_dom.pl b/prolog/gv/gv_dom.pl new file mode 100644 index 0000000..30c4263 --- /dev/null +++ b/prolog/gv/gv_dom.pl @@ -0,0 +1,29 @@ +:- module( + gv_dom, + [ + gv_dom/3 % +ExportG, -Dom, +Opts + ] +). + +/** GraphViz DOM + +@author Wouter Beek +@version 2015/07, 2016/01 +*/ + +:- use_module(library(gv/gv_file)). +:- use_module(library(option)). +:- use_module(library(svg/svg_ext)). + + + + + +%! gv_dom(+ExportG, -Dom, +Opts) is det. + +gv_dom(ExportG, Dom, Opts1):- + % Make sure the file type of the output file is SvgDom. + merge_options([output(svg)], Opts1, Opts2), + graph_viz(ExportG, ToFile, Opts2), + svg_dom(ToFile, Dom), + delete_file(ToFile). diff --git a/prolog/gv/gv_file.pl b/prolog/gv/gv_file.pl new file mode 100644 index 0000000..993fcee --- /dev/null +++ b/prolog/gv/gv_file.pl @@ -0,0 +1,175 @@ +:- module( + gv_file, + [ + graph_viz/2, % +ExportG, ?File + graph_viz/3 % +ExportG, ?File, +Opts + ] +). + +/** GraphViz file + +@author Wouter Beek +@version 2015/07, 2015/10-2015/11, 2016/01 +*/ + +:- use_module(library(code_ext)). +:- use_module(library(error)). +:- use_module(library(gv/gv_graph)). +:- use_module(library(option)). +:- use_module(library(os/external_program)). +:- use_module(library(os/process_ext)). +:- use_module(library(string_ext)). + +:- predicate_options(graph_viz/3, 3, [ + pass_to(file_to_gv/3, 3) + ]). +:- predicate_options(file_to_gv/3, 3, [ + method(+oneof([circo,dot,fdp,neato,osage,sfdp,twopi])), + output(+atom) + ]). + +:- dynamic(user:module_uses/2). +:- multifile(user:module_uses/2). + +user:module_uses(gv_file, program(dot)). + + + + + +%! graph_viz(+ExportGraph:compound, ?File:atom) is det. +%! graph_viz(+ExportGraph:compound, ?File:atom, +Options:list(compound)) is det. +% Returns a file containing a GraphViz visualization of the given graph. +% +% The following options are supported: +% * method(+oneof([circo,dot,fdp,neato,osage,sfdp,twopi]) +% The algorithm used by GraphViz for positioning the tree nodes. +% Default is `dot'. +% For possible values see gv_method/1. +% * output(+atom)` +% The file type of the generated GraphViz file. +% Default is `pdf`. +% For possible values see gv_output_type/1. + +graph_viz(ExportG, File):- + graph_viz(ExportG, File, []). +graph_viz(ExportG, File, Opts):- + once(phrase(gv_graph(ExportG), Cs)), + + % Be thread-safe. + thread_self(Id), + string_list_concat(["gv_file",Id], "_", ThreadName), + absolute_file_name(ThreadName, TmpFile, [access(write),extensions([dot])]), + setup_call_cleanup( + open(TmpFile, write, Write, [encoding(utf8)]), + with_output_to(Write, put_codes(Cs)), + close(Write) + ), + file_to_gv(TmpFile, File, Opts). + + +%! file_to_gv( +%! +InputFile:atom, +%! ?OutputFile:atom, +%! +Options:list(compound) +%! ) is det. +% Converts a GraphViz DOT file to an image file, using a specific +% visualization method. + +file_to_gv(InputFile, OutputFile, Opts):- + var(OutputFile), !, + option(output(Ext), Opts, pdf), + file_name_extension(out, Ext, LocalName), + absolute_file_name(LocalName, OutputFile, Opts), + file_to_gv(InputFile, OutputFile, Opts). +file_to_gv(InputFile, OutputFile, Opts):- + option(output(dot), Opts), !, + ( var(OutputFile) + -> OutputFile = InputFile + ; rename_file(InputFile, OutputFile) + ). +file_to_gv(InputFile, OutputFile, Opts):- + % Typecheck for `method` option. + option(method(Method), Opts, dot), + findall(Method0, gv_method(Method0), Methods), + must_be(oneof(Methods), Method), + + % Typecheck for `output` option. + option(output(OutputType), Opts, pdf), + findall(OutputType0, gv_output_type(OutputType0), OutputTypes), + must_be(oneof(OutputTypes), OutputType), + + % Run the GraphViz conversion command in the shell. + format(atom(OutputTypeFlag), "-T~a", [OutputType]), + format(atom(OutputFileFlag), "-o~a", [OutputFile]), + run_process( + Method, + [OutputTypeFlag,file(InputFile),OutputFileFlag] + ). + + + + + +% HELPERS % + +gv_method(circo). +gv_method(dot). +gv_method(fdp). +gv_method(neato). +gv_method(osage). +gv_method(sfdp). +gv_method(twopi). + + +gv_output_type(bmp). +gv_output_type(canon). +gv_output_type(dot). +gv_output_type(gv). +gv_output_type(xdot). +gv_output_type('xdot1.2'). +gv_output_type('xdot1.4'). +gv_output_type(cgimage). +gv_output_type(cmap). +gv_output_type(eps). +gv_output_type(exr). +gv_output_type(fig). +gv_output_type(gd). +gv_output_type(gd2). +gv_output_type(gif). +gv_output_type(gtk). +gv_output_type(ico). +gv_output_type(imap). +gv_output_type(cmapx). +gv_output_type(imap_np). +gv_output_type(cmapx_np). +gv_output_type(ismap). +gv_output_type(jp2). +gv_output_type(jpg). +gv_output_type(jpeg). +gv_output_type(jpe). +gv_output_type(pct). +gv_output_type(pict). +gv_output_type(pdf). +gv_output_type(pic). +gv_output_type(plain). +gv_output_type('plain-ext'). +gv_output_type(png). +gv_output_type(pov). +gv_output_type(ps). +gv_output_type(ps2). +gv_output_type(psd). +gv_output_type(sgi). +gv_output_type(svg). +gv_output_type(svgz). +gv_output_type(tga). +gv_output_type(tif). +gv_output_type(tiff). +gv_output_type(tk). +gv_output_type(vml). +gv_output_type(vmlz). +gv_output_type(vrml). +gv_output_type(wbmp). +gv_output_type(webp). +gv_output_type(xlib). +gv_output_type(x11). diff --git a/prolog/gv/gv_graph.pl b/prolog/gv/gv_graph.pl new file mode 100644 index 0000000..c95c9cc --- /dev/null +++ b/prolog/gv/gv_graph.pl @@ -0,0 +1,252 @@ +:- module( + gv_graph, + [ + gv_graph//1 % +Graph:compound + ] +). + +/** GraphViz graph + +Generates GraphViz graphs in the DOT format based on +a Prolog representation of a graph. + +In GraphViz vertices are called 'nodes'. + +--- + +@author Wouter Beek +@version 2015/07, 2015/12 +*/ + +:- use_module(library(apply)). +:- use_module(library(dcg/dcg_ext)). +:- use_module(library(gv/gv_graph_comp)). +:- use_module(library(lists)). +:- use_module(library(option)). + + + + + +%! gv_graph(+Graph:compound)// is det. +% Wrapper around gv_graph//2 with no indentation. + +gv_graph(G) --> gv_graph(G, 0). + + +%! gv_graph(+Graph:compound, +Indent:nonneg)// is det. +% The follow graph attributes are supported, +% beyond the GraphViz attributes for graphs: +% * `directed(+boolean)` +% Whether the graph is directed (`true`) or undirected (`false`). +% Default: `false`. +% * `name(+GraphName:atom)` +% * `strict(+StrictGraph:boolean)` +% This forbids the creation of self-arcs and multi-edges; +% they are ignored in the input file. +% Only in combinattion with directionality `directed`. +% +% ```abnf +% graph = ["strict"] ("graph" / "digraph") [ID] "{" stmt_list "}" +% ``` +% +% `GraphTerm` is a compound term of the following form: +% ```prolog +% graph(VertexTerms,RankedVertexTerms,EdgeTerms,GraphAttributes) +% ``` +% +% `RankedVertexTerms` is a list of compound terms of the following form: +% ```prolog +% RankVertex-ContentVertices +% ``` +% +% @tbd Add support for subgraphs (arbitrary nesting). +% @tbd Add support for escape strings: +% http://www.graphviz.org/doc/info/attrs.html#k:escString +% @tbd Assert attributes that are generic with respect to a subgraph. +% @tbd Not all vertex and edge properties can be shared it seems (e.g., label). + +gv_graph(G1, I) --> + { + include_ranks(G1, G2), + G2 = graph(VTerms,RankedVTerms,ETerms,GAttrs1), + shared_attributes(VTerms, SharedVAttrs, NewVTerms), + shared_attributes(ETerms, SharedEAttrs, NewETerms), + add_default(GAttrs1, overlap(false), GAttrs2), + I = 0 + }, + + % The first statement in the GraphViz output. + % States that this file represents a graph according to the GraphViz format. + tab(I), + + % Strictness. + {select_option(strict(Strict), GAttrs2, GAttrs3, false)}, + gv_strict(Strict), + + % Directedness. + {select_option(directed(Directed), GAttrs3, GAttrs4, true)}, + gv_graph_type(Directed), + " ", + + % Graph name. + ( {select_option(name(GName), GAttrs4, GAttrs5)} + -> gv_id(GName), + " " + ; {GAttrs5 = GAttrs4} + ), + + % The body of the DOT file appears between curly braces. + "{\n", + + % The following lines are indented. + {NewI is I + 1}, + + % Attributes that apply to the graph as a whole. + gv_generic_attributes_statement(graph, NewI, GAttrs5), + + % Attributes that are the same for all nodes. + gv_generic_attributes_statement(node, NewI, SharedVAttrs), + + % Attributes that are the same for all edges. + gv_generic_attributes_statement(edge, NewI, SharedEAttrs), + + % Only add a line_feed if some content was already written + % and some content is about to be written. + ( % Succeeds if no content was written. + {(GAttrs5 == [], SharedVAttrs == [], SharedEAttrs == [])} + -> "" + ; % Succeeds if no content is about to be written. + {(NewVTerms == [], RankedVTerms == [])} + -> "" + ; "\n" + ), + + % The list of GraphViz nodes. + gv_node_statements(NewI, NewVTerms), + ({NewVTerms == []} -> "" ; "\n"), + + % The ranked GraphViz nodes (displayed at the same height). + gv_ranked_node_collections(NewI, RankedVTerms), + ({RankedVTerms == []} -> "" ; "\n"), + + { + findall( + edge(FromId,ToId,[]), + ( + nth0(J1, RankedVTerms, rank(vertex(FromId,_),_)), + nth0(J2, RankedVTerms, rank(vertex(ToId,_),_)), + % We assume that the rank vertices are nicely ordered. + succ(J1, J2) + ), + RankEdges + ) + }, + + % The rank edges. + gv_edge_statements(NewI, Directed, RankEdges), + + % The non-rank edges. + gv_edge_statements(NewI, Directed, NewETerms), + + % Note that we do not include a line_feed here. + + % We want to indent the closing curly brace. + tab(I), + "}\n". + + + +%! gv_edge_statements( +%! +Indent:nonneg, +%! +Directed:boolean, +%! +Statements:list(compound) +%! )// is det. + +gv_edge_statements(I, Dir, L) --> *(gv_edge_statement(I, Dir), L). + + + +%! gv_edge_statements(+Indent:nonneg, +Statements:list(compound))// is det. + +gv_node_statements(I, L) --> *(gv_node_statement(I), L). + + + +%! gv_ranked_node_collections(+Indent:nonneg, +Collections:list)// is det. + +gv_ranked_node_collections(I, L) --> *(gv_ranked_node_collection(I), L). + + + + + +% HELPERS % + +%! add_default_option( +%! +Options:list(compound), +%! +Default:compound, +%! -NewOptions:list(compound) +%! ) is det. + +add_default(L1, Opt, L2):- + Opt =.. [N,_Value], + Opt0 =.. [N,_FreshVar], + ( option(Opt0, L1) + -> L2 = L1 + ; L2 = [Opt|L1] + ). + + + +%! gv_graph_type(+Directed:boolean)// is det. +% The type of graph that is represented. + +gv_graph_type(false) --> !, "graph". +gv_graph_type(true) --> "digraph". + + + +%! gv_strict(+Strict:boolean)// is det. +% The keyword denoting that the graph is strict, i.e., has no self-arcs and +% no multi-edges. +% This only applies to directed graphs. + +gv_strict(false) --> !, "". +gv_strict(true) --> "strict ". + + + +%! invlude_ranges(+Graph:compound, -GraphWithRanks:compound) is det. +% Ensures that there is a ranks components in +% the graph-denoting compound term. + +include_ranks(graph(Vs,Rs,Es,L), graph(Vs,Rs,Es,L)):- !. +include_ranks(graph(Vs,Es,L), graph(Vs,[],Es,L)). + + + +%! shared_attributes( +%! +Terms:list(compound), +%! -SharedAttributes:list(compound), +%! -NewTerms:list(compound) +%! ) is det. + +shared_attributes(Ts1, Shared, Ts2):- + maplist(term_to_attrs, Ts1, L1), + extract_shared(L1, Shared), + maplist(remove_shared_attributes(Shared), L1, L2), + maplist(term_change_attrs, Ts1, L2, Ts2). + +term_to_attrs(edge(_,_,A), A). +term_to_attrs(vertex(_,A), A). + +extract_shared([], []):- !. +extract_shared(Argss, Shared):- + ord_intersection(Argss, Shared). + +remove_shared_attributes(Shared, Args1, Args2):- + ord_subtract(Args1, Shared, Args2). + +term_change_attrs(edge(From,To,_), A, edge(From,To,A)). +term_change_attrs(vertex(Id,_), A, vertex(Id,A)). diff --git a/prolog/gv/gv_graph_comp.pl b/prolog/gv/gv_graph_comp.pl new file mode 100644 index 0000000..30ea9c5 --- /dev/null +++ b/prolog/gv/gv_graph_comp.pl @@ -0,0 +1,309 @@ +:- module( + gv_graph_comp, + [ + gv_edge_statement//3, % +Indent:nonneg + % +Directed:boolean + % +Edge:compound + gv_generic_attributes_statement//3, % +Kind:oneof([edge,graph,node]) + % +Indent:nonneg + % +CategoryAttributes:list(compound) + gv_id//1, % +Name:compound + gv_node_statement//2, % +Indent:nonneg + % +Vertex:compound + gv_ranked_node_collection//2 % +Indent:nonneg + % +Rank + ] +). + +/** GraphViz graph components + +```abnf +attr_list = "[" [a_list] "]" [attr_list] +a_list = ID "=" ID [","] [a_list] +``` + +@author Wouter Beek +@see http://www.graphviz.org/content/dot-language +@version 2015/07-2015/08, 2015/10-2016/01 +*/ + +:- use_module(library(apply)). +:- use_module(library(dcg/dcg_ext)). +:- use_module(library(gv/gv_attrs)). +:- use_module(library(gv/gv_html)). +:- use_module(library(error)). +:- use_module(library(lists)). +:- use_module(library(ordsets)). + + + + + +%! gv_edge_statement( +%! +Indent:nonneg, +%! +Directed:boolean, +%! +Edge:compound +%! )// is det. +% A GraphViz statement describing an edge. +% +% @arg Indent The indentation level at which the edge statement is written. +% @arg Directed Whether the graph is directed or not. +% @arg GraphAttributes The attributes of the graph. Some of these attributes +% may be used in the edge statement (e.g., the colorscheme). +% @arg Edge A compound term in the GIFormat, representing an edge. +% +% @tbd Instead of gv_node_id//1 we could have a gv_subgraph//1 +% at the from and/or to location. +% @tbd Add support for multiple, consecutive occurrences of gv_edge_rhs//2. + +gv_edge_statement(I, Dir, edge(From,To,Attrs)) --> + tab(I), + + gv_node_id(From), " ", + gv_edge_operator(Dir), " ", + gv_node_id(To), " ", + + % We want `colorscheme/1` from the edges and + % `directionality/1` from the graph. + gv_attrs(edge, Attrs), + "\n". + +%! gv_edge_operator(+Directed:boolean)// . +% The binary edge operator between two vertices. +% The operator that is used depends on whether the graph is directed or +% undirected. +% +% @arg Directed Whether an edge is directed (operator `->`) or +% undirected (operator `--`). + +gv_edge_operator(Dir) --> + {must_be(boolean, Dir)}, + ({Dir == false} -> "--" ; {Dir == true} -> "->"). + + + +%! gv_generic_attributes_statement( +%! +Kind:oneof([edge,graph,node]), +%! +Indent:nonneg, +%! +CategoryAttrs +%! )// +% A GraphViz statement describing generic attributes for a category of items. +% +% @arg Kind The category of items for to the attributes apply. +% Possible values: `edge`, `graph`, and `node`. +% @arg Indent An integer indicating the number of tabs. +% @arg GraphAttributes A list of name-value pairs. +% @arg CategoryAttributes A list of name-value pairs. +% +% ``` +% attr_stmt = (graph / node / edge) attr_list +% ``` + +gv_generic_attributes_statement(_, _, []) --> !, "". +gv_generic_attributes_statement(Kind, I, Attrs) --> + tab(I), + gv_kind(Kind), " ", + gv_attrs(Kind, Attrs), + "\n", !. + + + +%! gv_kind(+Kind:oneof([edge,graph,node]))// . + +gv_kind(Kind) --> {must_be(oneof([edge,graph,node]), Kind)}, atom(Kind). + + + +%! gv_node_statement(+Indent:nonneg, +Vertex:compound)// is det. +% A GraphViz statement describing a vertex (GraphViz calls vertices 'nodes'). + +gv_node_statement(I, vertex(Id,Attrs)) --> + tab(I), + gv_node_id(Id), + gv_attrs(node, Attrs), + "\n". + + + +%! gv_ranked_node_collection(+Indent:nonneg, Rank:pair)// is det. + +gv_ranked_node_collection(I, RankVTerm-VTerms) --> + tab(I), + "{\n", + + % The rank attribute. + {NewI is I + 1}, + tab(NewI), + gv_attr(subgraph, rank(same)), + "\n", + + % Vertice statements. + *(gv_node_statement(NewI), [RankVTerm|VTerms]), + + % We want to indent the closing curly brace. + tab(I), + "\n}". + + + + + +% HELPERS % + +%! gv_attrs( +%! +Kind:oneof([edge,graph,node]), +%! +Attributes:list(compound) +%! )// is det. + +gv_attrs(Kind, L) --> "[", *(gv_attr(Kind), L), "]". + + +%! gv_attr(+Context:oneof([edge,graph,node]), +Attribute:compound)// is det. +% A single GraphViz attribute. +% We assume that the attribute has already been validated. + +gv_attr(Context, Attr) --> + {Attr =.. [N,V]}, + gv_id(N), "=", gv_attr_value(Context, N=V), ";". + + + +%! gv_id(+Id:compound)// is det. +% Parse a GraphViz identifier. +% There are 4 variants: +% 1. Any string of alphabetic (`[a-zA-Z'200-'377]`) characters, +% underscores (`_`) or digits (`[0-9]`), not beginning with a digit. +% 2. A numeral `[-]?(.[0-9]+ | [0-9]+(.[0-9]*)? )`. +% 3. Any double-quoted string (`"..."`) possibly containing +% escaped quotes (`\"`). +% In quoted strings in DOT, the only escaped character is +% double-quote (`"`). That is, in quoted strings, the dyad `\"` +% is converted to `"`. All other characters are left unchanged. +% In particular, `\\` remains `\\`. +% Layout engines may apply additional escape sequences. +% Represented by a Prolog term of the form `double_quoted_string(ATOM)`. +% 4. An HTML string (`<...>`). +% Represented by a Prolog term of the form `html_like_label(COMPOUND)`. +% +% @tbd Add support for HTML-like labels: +% http://www.graphviz.org/doc/info/shapes.html#html +% This requires an XML grammar! + +% HTML strings (assumed to be the same as HTML-like labels). +gv_id(html_like_label(Content)) --> !, + gv_html_like_label(Content). +% Double-quoted strings. +% The quotes are already part of the given atom. +gv_id(double_quoted_string(Atom)) --> !, + "\"", atom(Atom), "\"". +% Numerals. +gv_id(N) --> + {number(N)}, !, + {number_codes(N, Cs)}, + Cs. +% Alpha-numeric strings. +gv_id(Atom) --> + {atom_codes(Atom, [H|T])}, + gv_id_first(H), + gv_id_rest(T), !, + % Variant 1 identifiers should not be (case-variants of) a + % GraphViz keyword. + {\+ gv_keyword([H|T])}. + + +%! gv_id_first(+First:code)// is det. +% Generates the first character of a GraphViz identifier. + +gv_id_first(C) --> alpha(C), !. +gv_id_first(0'_) --> "_". + + +%! gv_id_rest(+NonFirst:code)// is det. +% Generates a non-first character of a GraphViz identifier. + +gv_id_rest([H|T]) --> alphadigit(H), !, gv_id_rest(T). +gv_id_rest([0'_|T]) --> "_", !, gv_id_rest(T). +gv_id_rest([]) --> "". + + + +%! gv_keyword(+Codes:list(code)) is semidet. +% Succeeds if the given codes for a GraphViz reserved keyword. + +gv_keyword(Cs):- + % Obviously, the keywords do not occur on the difference list input. + % So we must use phrase/[2,3]. + phrase(gv_keyword, Cs). + + +%! gv_keyword// . +% GraphViz has reserved keywords that cannot be used as identifiers. +% GraphViz keywords are case-insensitive. + +gv_keyword --> "digraph". +gv_keyword --> "edge". +gv_keyword --> "graph". +gv_keyword --> "node". +gv_keyword --> "strict". +gv_keyword --> "subgraph". + + + +%! gv_node_id(+NodeId:compound)// . +% GraphViz node identifiers can be of the following two types: +% 1. A GraphViz identifier, see gv_id//1. +% 2. A GraphViz identifier plus a GraphViz port indicator, see gv_port//0. +% +% @tbd Add support for GraphViz port indicators +% inside GraphViz node identifiers. + +gv_node_id(Id) --> gv_id(Id), !. +%gv_node_id(_) --> gv_id(_), gv_port. +gv_node_id(Id) --> {type_error(gv_node_id, Id)}. + + + +%! gv_numeral(-Number)// is det. +% ```bnf +% ('-')? ( '.' [0-9]+ | [0-9]+ ( '.' [0-9]* )? ) +% ``` + +gv_numeral(N) --> + ("-" -> {Sg = -1} ; {Sg = 1}), + ( "." + -> {I = 0}, +(digit, Ds), {pos_frac(Ds, Frac)} + ; +(digit, Ds1), {pos_sum(Ds1, I)}, + ("." -> *(digit, Ds2), {pos_frac(Ds2, Frac)} ; {Frac = 0.0}) + ), + {N is Sg * (I + Frac)}. + + + +%! gv_port// is det. + +gv_port --> gv_port_location, (gv_port_angle ; ""). +gv_port --> gv_port_angle, (gv_port_location ; ""). +gv_port --> ":", gv_compass_pt(_). + +gv_port_angle --> "@", gv_id(_). + +gv_port_location --> ":", gv_id(_). +gv_port_location --> ":[", gv_id(_), ",", gv_id(_), "]". + + + +%! gv_compass_pt(+Direction:oneof(['_',c,e,n,ne,nw,s,se,sw,w]))// . +% ``` +% compass_pt : ( n | ne | e | se | s | sw | w | nw | c | _ ) +% ``` + +gv_compass_pt('_') --> "_". +gv_compass_pt(c) --> "c". +gv_compass_pt(e) --> "e". +gv_compass_pt(n) --> "n". +gv_compass_pt(ne) --> "ne". +gv_compass_pt(nw) --> "nw". +gv_compass_pt(s) --> "s". +gv_compass_pt(se) --> "se". +gv_compass_pt(sw) --> "sw". +gv_compass_pt(w) --> "w". diff --git a/prolog/gv/gv_html.pl b/prolog/gv/gv_html.pl new file mode 100644 index 0000000..b5c1368 --- /dev/null +++ b/prolog/gv/gv_html.pl @@ -0,0 +1,255 @@ +:- module( + gv_html, + [ + gv_html_like_label//1 % +Content:compound + ] +). + +/** GraphViz: HTML-like labels + +Grammar taken from the GraphViz Web site: + +``` +label : text + | table +text : textitem + | text textitem +textitem : string + |
+ | text + | text + | text + | text + | text + | text + | text + | text +table : [ ] rows
[
] +rows : row + | rows row + | rows
row +row: cells +cells : cell + | cells cell + | cells cell +cell: label + | +``` + +--- + +@author Wouter Beek +@see http://www.graphviz.org/content/node-shapes#html +@version 2015/07, 2015/12 +*/ + +:- use_module(library(dcg/dcg_ext)). +:- use_module(library(html/html_dcg)). + + + + + +%! gv_html_like_label(+Content:compound)// is det. + +gv_html_like_label(Content) --> "<", label(Content), ">". + + + +%! cell(+Contents:compound)// is det. +% Supported attributes for `TD`: +% - `ALIGN="CENTER|LEFT|RIGHT|TEXT"` +% - `BALIGN="CENTER|LEFT|RIGHT"` +% - `BGCOLOR="color"` +% - `BORDER="value"` +% - `CELLPADDING="value"` +% - `CELLSPACING="value"` +% - `COLOR="color"` +% - `COLSPAN="value"` +% - `FIXEDSIZE="FALSE|TRUE"` +% - `GRADIENTANGLE="value"` +% - `HEIGHT="value"` +% - `HREF="value"` +% - `ID="value"` +% - `PORT="portName"` +% - `ROWSPAN="value"` +% - `SIDES="value"` +% - `STYLE="value"` +% - `TARGET="value"` +% - `TITLE="value"` +% - `TOOLTIP="value"` +% - `VALIGN="MIDDLE|BOTTOM|TOP"` +% - `WIDTH="value"` +% +% Supported attributes for `IMG`: +% - `SCALE="FALSE|TRUE|WIDTH|HEIGHT|BOTH"` +% - `SRC="value"` + +cell(td(Contents)) --> !, + cell(td([],Contents)). +cell(td(Attrs1,Image)) --> + {(Image =.. [img,Attrs2] -> true ; Image == img -> Attrs2 = [])}, !, + html_element(td, Attrs1, html_element(img,Attrs2)). +cell(td(Attrs,Contents)) --> + html_element(td, Attrs, label(Contents)). + + + +%! cells(+Contents:list(compound))// is det. + +cells([H,vr|T]) --> !, cell(H), html_element(vr), cells(T). +cells([H|T]) --> !, cell(H), cells(T). +cells([]) --> "". + + + +%! label(+Content:compound)// is det. +% GraphViz HTML-like label. + +label(Content) --> table(Content), !. +label(Content) --> text(Content). + + + +%! row(+Contents:compound)// is det. + +row(tr(Contents)) --> html_element(tr, [], cells(Contents)). + + + +%! rows(+Contents:list)// is det. + +rows([hr|T]) --> !, html_element(hr), rows(T). +rows([H|T]) --> row(H), !, rows(T). +rows([]) --> "". + + + +%! table(+Contents:compound)// is det. +% ``` +% table : [ ] rows
[
] +% ``` +% +% Supported attributes for `TABLE`: +% - `ALIGN="CENTER|LEFT|RIGHT"` +% - `BGCOLOR="color"` +% - `BORDER="value"` +% - `CELLBORDER="value"` +% - `CELLPADDING="value"` +% - `CELLSPACING="value"` +% - `COLOR="color"` +% - `COLUMNS="value"` +% - `FIXEDSIZE="FALSE|TRUE"` +% - `GRADIENTANGLE="value"` +% - `HEIGHT="value"` +% - `HREF="value"` +% - `ID="value"` +% - `PORT="portName"` +% - `ROWS="value"` +% - `SIDES="value"` +% - `STYLE="value"` +% - `TARGET="value"` +% - `TITLE="value"` +% - `TOOLTIP="value"` +% - `VALIGN="MIDDLE|BOTTOM|TOP"` +% - `WIDTH="value"` +% +% Supported attributes for `FONT`: +% - `COLOR="color"` +% Sets the color of the font within the scope of `...`, +% or the border color of the table or cell within the scope of +% `...
`, or `...`. +% This color can be overridden by a `COLOR` attribute in descendents. +% By default, the font color is determined by the `fontcolor` attribute +% of the corresponding node, edge or graph, and the border color is +% determined by the color attribute of the corresponding node, edge or +% graph. +% - `FACE="fontname"` +% - `POINT-SIZE="value"` + +table(table(Contents)) --> !, + table(table([],Contents)). +table(table(Attrs,Contents)) --> !, + html_element(table, Attrs, rows(Contents)). +table(font(Table)) --> !, + table(font([],Table)). +table(font(Attrs1,Table)) --> + {( Table =.. [table,Attrs2,Contents] + -> true + ; Table =.. [table,Contents] + -> Attrs2 = [] + )}, + html_element(font, Attrs1, table(table(Attrs2,Contents))). + + + +%! text(+Contents:list)// . +% ``` +% text : textitem +% | text textitem +% ``` + +text(Contents) --> {is_list(Contents)}, !, '+'(textitem, Contents). +text(Content) --> text([Content]). + + + +%! textitem(+Content:compound)// . +% ``` +% textitem : string +% |
+% | text +% | text +% | text +% | text +% | text +% | text +% | text +% | text +% ``` +% +% Supported attributes for BR: +% * `ALIGN="CENTER|LEFT|RIGHT"` +% +% Supported attributes for FONT: +% * COLOR="color" +% * FACE="fontname" +% * POINT-SIZE="value" + +textitem(br(Attrs)) --> !, + html_element(br, Attrs). +% Compound term: parser. +textitem(Compound) --> + {var(Compound)}, !, + html_element(Name, _, text(Content)), + { + supported_html_element(Name), + Compound =.. [Name,Content] + }. +% Compound term: generator. +textitem(Compound) --> + { + Compound =.. [Name,Content], !, + supported_html_element(Name) + }, + html_element(Name, _, text(Content)). +textitem(String) --> + html_string(String). + + + + + +% HELPERS % + +%! supported_html_element(+Name:atom) is semidet. +%! supported_html_element(-Name:atom) is multi. + +supported_html_element(b). +supported_html_element(font). +supported_html_element(i). +supported_html_element(o). +supported_html_element(s). +supported_html_element(sub). +supported_html_element(sup). +supported_html_element(u). diff --git a/prolog/tree/tree_viz.pl b/prolog/tree/tree_viz.pl new file mode 100644 index 0000000..4382aa6 --- /dev/null +++ b/prolog/tree/tree_viz.pl @@ -0,0 +1,65 @@ +:- module( + tree_viz, + [ + tree_export_graph/2, % +Tree, ExportG + tree_export_graph/3, % +Tree, ExportG, +Opts + tree_viz/2, % +Tree, ?File + tree_viz/3 % +Tree, ?File, +Opts + ] +). + +/** Tree visualization + +Export trees to GraphViz. + +@author Wouter Beek +@version 2016/01-2016/02 +*/ + +:- use_module(library(graph/build_export_graph)). +:- use_module(library(gv/gv_file)). +:- use_module(library(ordsets)). +:- use_module(library(tree/l_tree)). +:- use_module(library(tree/s_tree)). + +:- predicate_options(tree_export_graph/3, 3, [ + pass_to(build_export_graph/4, 4) + ]). +:- predicate_options(tree_viz/3, 3, [ + pass_to(graph_viz/3, 3), + pass_to(tree_to_graph/3, 3) + ]). + + + + + +%! tree_export_graph(+Tree, -ExportG) is det. +%! tree_export_graph(+Tree, -ExportG, +Opts) is det. +% Opts are passed to build_export_graph/4. + +tree_export_graph(Tree, ExportG) :- + tree_export_graph(Tree, ExportG, []). + +tree_export_graph(Tree, ExportG, Opts) :- + ( is_s_tree(Tree) + -> tree_to_graph(Tree, G) + ; is_l_tree(Tree) + -> l_tree_to_graph(Tree, G) + ), + build_export_graph(G, ExportG, Opts). + + + +%! tree_viz(+Tree, ?File) is det. +%! tree_viz(+Tree, ?File, +Opts) is det. +% Stores the given tree term into a GraphViz file. +% +% Options are passed to export_graph_to_gv_file/3, tree_to_graph/3. + +tree_viz(Tree, File) :- + tree_viz(Tree, File, []). + +tree_viz(Tree, File, Opts) :- + tree_export_graph(Tree, ExportG, Opts), + graph_viz(ExportG, File, Opts). diff --git a/test/gv_attrs.log b/test/gv_attrs.log new file mode 100644 index 0000000..a9c6010 --- /dev/null +++ b/test/gv_attrs.log @@ -0,0 +1,169 @@ +assert(gv_attr('Damping',[graph],[double],'0.99','0.0','neato only')). +assert(gv_attr('K',[cluster,graph],[double],'0.3','0','sfdp, fdp only')). +assert(gv_attr('URL',[cluster,edge,graph,node],[escString],_,'','svg, postscript, map only')). +assert(gv_attr('_background',[graph],[string],_,'','')). +assert(gv_attr(area,[cluster,node],[double],'1.0','>0','patchwork only')). +assert(gv_attr(arrowhead,[edge],[arrowType],normal,'','')). +assert(gv_attr(arrowsize,[edge],[double],'1.0','0.0','')). +assert(gv_attr(arrowtail,[edge],[arrowType],normal,'','')). +assert(gv_attr(bb,[graph],[rect],'','','write only')). +assert(gv_attr(bgcolor,[cluster,graph],[color,colorList],_,'','')). +assert(gv_attr(center,[graph],[bool],false,'','')). +assert(gv_attr(charset,[graph],[string],'"UTF-8"','','')). +assert(gv_attr(clusterrank,[graph],[clusterMode],local,'','dot only')). +assert(gv_attr(color,[cluster,edge,node],[color,colorList],black,'','')). +assert(gv_attr(colorscheme,[cluster,edge,graph,node],[string],'','','')). +assert(gv_attr(comment,[edge,graph,node],[string],'','','')). +assert(gv_attr(compound,[graph],[bool],false,'','dot only')). +assert(gv_attr(concentrate,[graph],[bool],false,'','')). +assert(gv_attr(constraint,[edge],[bool],true,'','dot only')). +assert(gv_attr(decorate,[edge],[bool],false,'','')). +assert(gv_attr(defaultdist,[graph],[double],'1+(avg. len)*sqrt(|V|)',epsilon,'neato only')). +assert(gv_attr(dim,[graph],[int],'2','2','sfdp, fdp, neato only')). +assert(gv_attr(dimen,[graph],[int],'2','2','sfdp, fdp, neato only')). +assert(gv_attr(dir,[edge],[dirType],'forward(directed)none(undirected)','','')). +assert(gv_attr(diredgeconstraints,[graph],[string,bool],false,'','neato only')). +assert(gv_attr(distortion,[node],[double],'0.0','-100.0','')). +assert(gv_attr(dpi,[graph],[double],'96.00.0','','svg, bitmap output only')). +assert(gv_attr(edgeURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(edgehref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(edgetarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(edgetooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(epsilon,[graph],[double],'.0001 * # nodes(mode == KK).0001(mode == major)','','neato only')). +assert(gv_attr(esep,[graph],[addDouble,addPoint],'+3','','not dot')). +assert(gv_attr(fillcolor,[cluster,edge,node],[color,colorList],'lightgrey(nodes)black(clusters)','','')). +assert(gv_attr(fixedsize,[node],[bool,string],false,'','')). +assert(gv_attr(fontcolor,[cluster,edge,graph,node],[color],black,'','')). +assert(gv_attr(fontname,[cluster,edge,graph,node],[string],'"Times-Roman"','','')). +assert(gv_attr(fontnames,[graph],[string],'','','svg only')). +assert(gv_attr(fontpath,[graph],[string],'system-dependent','','')). +assert(gv_attr(fontsize,[cluster,edge,graph,node],[double],'14.0','1.0','')). +assert(gv_attr(forcelabels,[graph],[bool],true,'','')). +assert(gv_attr(gradientangle,[cluster,graph,node],[int],'','','')). +assert(gv_attr(group,[node],[string],'','','dot only')). +assert(gv_attr(headURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(head_lp,[edge],[point],'','','write only')). +assert(gv_attr(headclip,[edge],[bool],true,'','')). +assert(gv_attr(headhref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(headlabel,[edge],[lblString],'','','')). +assert(gv_attr(headport,[edge],[portPos],center,'','')). +assert(gv_attr(headtarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(headtooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(height,[node],[double],'0.5','0.02','')). +assert(gv_attr(href,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only')). +assert(gv_attr(id,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only')). +assert(gv_attr(image,[node],[string],'','','')). +assert(gv_attr(imagepath,[graph],[string],'','','')). +assert(gv_attr(imagescale,[node],[bool,string],false,'','')). +assert(gv_attr(inputscale,[graph],[double],_,'','fdp, neato only')). +assert(gv_attr(label,[cluster,edge,graph,node],[lblString],'"\\N" (nodes)"" (otherwise)','','')). +assert(gv_attr(labelURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(label_scheme,[graph],[int],'0','0','sfdp only')). +assert(gv_attr(labelangle,[edge],[double],'-25.0','-180.0','')). +assert(gv_attr(labeldistance,[edge],[double],'1.0','0.0','')). +assert(gv_attr(labelfloat,[edge],[bool],false,'','')). +assert(gv_attr(labelfontcolor,[edge],[color],black,'','')). +assert(gv_attr(labelfontname,[edge],[string],'"Times-Roman"','','')). +assert(gv_attr(labelfontsize,[edge],[double],'14.0','1.0','')). +assert(gv_attr(labelhref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(labeljust,[cluster,graph],[string],'"c"','','')). +assert(gv_attr(labelloc,[cluster,graph,node],[string],'"t"(clusters)"b"(root graphs)"c"(nodes)','','')). +assert(gv_attr(labeltarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(labeltooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(landscape,[graph],[bool],false,'','')). +assert(gv_attr(layer,[cluster,edge,node],[layerRange],'','','')). +assert(gv_attr(layerlistsep,[graph],[string],'","','','')). +assert(gv_attr(layers,[graph],[layerList],'','','')). +assert(gv_attr(layerselect,[graph],[layerRange],'','','')). +assert(gv_attr(layersep,[graph],[string],'" :\\t"','','')). +assert(gv_attr(layout,[graph],[string],'','','')). +assert(gv_attr(len,[edge],[double],'1.0(neato)0.3(fdp)','','fdp, neato only')). +assert(gv_attr(levels,[graph],[int],'MAXINT','0.0','sfdp only')). +assert(gv_attr(levelsgap,[graph],[double],'0.0','','neato only')). +assert(gv_attr(lhead,[edge],[string],'','','dot only')). +assert(gv_attr(lheight,[cluster,graph],[double],'','','write only')). +assert(gv_attr(lp,[cluster,edge,graph],[point],'','','write only')). +assert(gv_attr(ltail,[edge],[string],'','','dot only')). +assert(gv_attr(lwidth,[cluster,graph],[double],'','','write only')). +assert(gv_attr(margin,[cluster,graph,node],[double,point],'','','')). +assert(gv_attr(maxiter,[graph],[int],'100 * # nodes(mode == KK)200(mode == major)600(fdp)','','fdp, neato only')). +assert(gv_attr(mclimit,[graph],[double],'1.0','','dot only')). +assert(gv_attr(mindist,[graph],[double],'1.0','0.0','circo only')). +assert(gv_attr(minlen,[edge],[int],'1','0','dot only')). +assert(gv_attr(mode,[graph],[string],major,'','neato only')). +assert(gv_attr(model,[graph],[string],shortpath,'','neato only')). +assert(gv_attr(mosek,[graph],[bool],false,'','neato only')). +assert(gv_attr(nodesep,[graph],[double],'0.25','0.02','')). +assert(gv_attr(nojustify,[cluster,edge,graph,node],[bool],false,'','')). +assert(gv_attr(normalize,[graph],[double,bool],false,'','not dot')). +assert(gv_attr(notranslate,[graph],[bool],false,'','neato only')). +assert(gv_attr('nslimit nslimit1',[graph],[double],'','','dot only')). +assert(gv_attr(ordering,[graph,node],[string],'','','dot only')). +assert(gv_attr(orientation,[node],[double],'0.0','360.0','')). +assert(gv_attr(orientation,[graph],[string],'','','')). +assert(gv_attr(outputorder,[graph],[outputMode],breadthfirst,'','')). +assert(gv_attr(overlap,[graph],[string,bool],true,'','not dot')). +assert(gv_attr(overlap_scaling,[graph],[double],'-4','-1.0e10','prism only')). +assert(gv_attr(overlap_shrink,[graph],[bool],true,'','prism only')). +assert(gv_attr(pack,[graph],[bool,int],false,'','')). +assert(gv_attr(packmode,[graph],[packMode],node,'','')). +assert(gv_attr(pad,[graph],[double,point],'0.0555 (4 points)','','')). +assert(gv_attr(page,[graph],[double,point],'','','')). +assert(gv_attr(pagedir,[graph],[pagedir],'BL','','')). +assert(gv_attr(pencolor,[cluster],[color],black,'','')). +assert(gv_attr(penwidth,[cluster,edge,node],[double],'1.0','0.0','')). +assert(gv_attr(peripheries,[cluster,node],[int],'shape default(nodes)1(clusters)','0','')). +assert(gv_attr(pin,[node],[bool],false,'','fdp, neato only')). +assert(gv_attr(pos,[edge,node],[point,splineType],'','','')). +assert(gv_attr(quadtree,[graph],[quadType,bool],normal,'','sfdp only')). +assert(gv_attr(quantum,[graph],[double],'0.0','0.0','')). +assert(gv_attr(rank,[subgraph],[rankType],'','','dot only')). +assert(gv_attr(rankdir,[graph],[rankdir],'TB','','dot only')). +assert(gv_attr(ranksep,[graph],[double,doubleList],'0.5(dot)1.0(twopi)','0.02','twopi, dot only')). +assert(gv_attr(ratio,[graph],[double,string],'','','')). +assert(gv_attr(rects,[node],[rect],'','','write only')). +assert(gv_attr(regular,[node],[bool],false,'','')). +assert(gv_attr(remincross,[graph],[bool],true,'','dot only')). +assert(gv_attr(repulsiveforce,[graph],[double],'1.0','0.0','sfdp only')). +assert(gv_attr(resolution,[graph],[double],'96.00.0','','svg, bitmap output only')). +assert(gv_attr(root,[graph,node],[string,bool],'(graphs)false(nodes)','','circo, twopi only')). +assert(gv_attr(rotate,[graph],[int],'0','','')). +assert(gv_attr(rotation,[graph],[double],'0','','sfdp only')). +assert(gv_attr(samehead,[edge],[string],'','','dot only')). +assert(gv_attr(sametail,[edge],[string],'','','dot only')). +assert(gv_attr(samplepoints,[node],[int],'8(output)20(overlap and image maps)','','')). +assert(gv_attr(scale,[graph],[double,point],'','','not dot')). +assert(gv_attr(searchsize,[graph],[int],'30','','dot only')). +assert(gv_attr(sep,[graph],[addDouble,addPoint],'+4','','not dot')). +assert(gv_attr(shape,[node],[shape],ellipse,'','')). +assert(gv_attr(shapefile,[node],[string],'','','')). +assert(gv_attr(showboxes,[edge,graph,node],[int],'0','0','dot only')). +assert(gv_attr(sides,[node],[int],'4','0','')). +assert(gv_attr(size,[graph],[double,point],'','','')). +assert(gv_attr(skew,[node],[double],'0.0','-100.0','')). +assert(gv_attr(smoothing,[graph],[smoothType],'"none"','','sfdp only')). +assert(gv_attr(sortv,[cluster,graph,node],[int],'0','0','')). +assert(gv_attr(splines,[graph],[bool,string],'','','')). +assert(gv_attr(start,[graph],[startType],'','','fdp, neato only')). +assert(gv_attr(style,[cluster,edge,graph,node],[style],'','','')). +assert(gv_attr(stylesheet,[graph],[string],'','','svg only')). +assert(gv_attr(tailURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(tail_lp,[edge],[point],'','','write only')). +assert(gv_attr(tailclip,[edge],[bool],true,'','')). +assert(gv_attr(tailhref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(taillabel,[edge],[lblString],'','','')). +assert(gv_attr(tailport,[edge],[portPos],center,'','')). +assert(gv_attr(tailtarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(tailtooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(target,[cluster,edge,graph,node],[escString,string],_,'','svg, map only')). +assert(gv_attr(tooltip,[cluster,edge,node],[escString],'','','svg, cmap only')). +assert(gv_attr(truecolor,[graph],[bool],'','','bitmap output only')). +assert(gv_attr(vertices,[node],[pointList],'','','write only')). +assert(gv_attr(viewport,[graph],[viewPort],'','','')). +assert(gv_attr(voro_margin,[graph],[double],'0.05','0.0','not dot')). +assert(gv_attr(weight,[edge],[int,double],'1','0(dot,twopi)1(neato,fdp)','')). +assert(gv_attr(width,[node],[double],'0.75','0.01','')). +assert(gv_attr(xdotversion,[graph],[string],'','','xdot only')). +assert(gv_attr(xlabel,[edge,node],[lblString],'','','')). +assert(gv_attr(xlp,[edge,node],[point],'','','write only')). +assert(gv_attr(z,[node],[double],'0.0','-MAXFLOAT-1000','')). diff --git a/test/test.pl b/test/test.pl new file mode 100644 index 0000000..83dc023 --- /dev/null +++ b/test/test.pl @@ -0,0 +1,15 @@ +%/fca +:- use_module(library(fca/fca_viz)). +%/graph +:- use_module(library(graph/build_export_graph)). +%/gv +:- use_module(library(gv/gv_attrs)). +:- use_module(library(gv/gv_attr_type)). +:- use_module(library(gv/gv_color)). +:- use_module(library(gv/gv_dom)). +:- use_module(library(gv/gv_file)). +:- use_module(library(gv/gv_graph)). +:- use_module(library(gv/gv_graph_comp)). +:- use_module(library(gv/gv_html)). +%/tree +:- use_module(library(tree/tree_viz)). ```

25: 正在比较变动前 6dc1cf5 和变动后 76ea35d

[back to content](#compare) ``` diff diff --git a/.gitignore b/.gitignore index bd24270..b25c15b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ *~ -*# -*.db diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a63cbff --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "Prolog-Library-Collection"] + path = Prolog-Library-Collection + url = https://github.com/wouterbeek/Prolog-Library-Collection.git +[submodule "plHtml"] + path = plHtml + url = https://github.com/wouterbeek/plHtml.git diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index c7b7798..0000000 --- a/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Wouter Beek - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection new file mode 160000 index 0000000..5b34b01 --- /dev/null +++ b/Prolog-Library-Collection @@ -0,0 +1 @@ +Subproject commit 5b34b01ab0cc82a56e6fd90fc26e75da22f5a0fe diff --git a/README.md b/README.md deleted file mode 100644 index 23a45db..0000000 --- a/README.md +++ /dev/null @@ -1,151 +0,0 @@ -plGraphViz -========== - -This library allows you to easily export graphs represented as Prolog terms -using [GraphViz](http://www.graphviz.org/), an advanced graph drawing library. -The Prolog terms have the following form: - -~~~prolog -graph(Vertices, Edges, GraphAttrs) -~~~ - -`Vertices` and `Edges` are lists of compound terms of the following form: - -~~~prolog -vertex(Id, VertexAttrs) -edge(FromId, ToId, EdgeAttrs) -~~~ - -`Id` identifies a vertex and may or may not occur in any of the edges -(i.e., unconnected vertices are allowed). -`FromId` and `ToId` may occur in the list of vertices, -in order to draw an edge between vertices with set attributes. - -Attributes have the form `Name=Value`. -`GraphAttrs` are attributes of the graph. -`VertexAttrs` are attributes of the vertex. -`EdgeAttrs` are attributes of the edge. - -Attribute values are given as Prolog terms as well, -and are type-checked before exporting. -Many of the GraphViz attributes are supported. -New ones are added on an as-needed bases -(open an issue on Github if you want to see a specific feature added!). -HTML-like labels are supported, allowing complex tables to be shown -inside vertices. - ---- - -### Installation - -~~~shell -$ git clone https://github.com/wouterbeek/plGraphViz.git -$ cd plGraphViz -$ git submodule update --init -~~~ - -### Example - -~~~prolog -$ swipl run.pl -?- export_graph_to_gv_file( - graph([vertex(1,[]),vertex(2,[])],[edge(1,2,[])],[]), - File, - [method(sfdp),output(png)] - ). - File = 'PATH/plGraphViz/data/tmp.png' -~~~ - -![](https://raw.githubusercontent.com/wouterbeek/plGraphViz/master/example1.png "Example graph.") - -The graphic can be saved to a different file by instantiating -the `File` argument. - ---- - -### 'Method' option - -Option `method(+atom)` sets the drawing method that is used by GraphViz - to place the vertices and edges. -The following values are supported. - -| **Value** | **Description** | -| `circo` | Circular layout. | -| `dot` (default) | Directed graph. | -| `fdp` | Undirected graph. | -| `neato` | Undirected graph. | -| `osage` | Tree map. | -| `sfdp` | Large undirected graph. | -| `twopi` | Radical layouts. | - ---- - -### 'Output' option - -Option `output(+atom)` sets the type of file the graph is written to. -The following values are supported. - -| **Value** | **Description** | -|:---------------------:|:--------------------------------------| -| `bmp` | Windows Bitmap Format | -| `canon` | | -| `dot` | | -| `gv`, `xdot`, `xdot1.2`, `xdot1.4` | DOT | -| `cgimage` | CGImage bitmap format | -| `cmap` | Client-side imagemap (deprecated) | -| `eps` | Encapsulated PostScript | -| `exr` | OpenEXR | -| `fig` | | -| `gd`, `gd2` | GD/GD2 formats | -| `gif` | | -| `gtk` | GTK canvas | -| `ico` | Icon Image File Format | -| `imap` | | -| `cmapx` | Server-side and client-side imagemaps | -| `imap_np`, `cmapx_np` | Server-side and client-side imagemaps | -| `ismap` | Server-side imagemap (deprecated) | -| `jp2` | JPEG 2000 | -| `jpg`, `jpeg`, `jpe` | JPEG | -| `pct`, `pict` | PICT | -| `pdf` (default) | Portable Document Format (PDF) | -| `pic` | Kernighan's PIC graphics language | -| `plain`, `plain-ext` | Simple text format | -| `png` | Portable Network Graphics format | -| `pov` | POV-Ray markup language (prototype) | -| `ps` | PostScript | -| `ps2` | PostScript for PDF | -| `psd` | PSD | -| `sgi` | SGI | -| `svg`, `svgz` | Scalable Vector Graphics | -| `tga` | Truevision TGA | -| `tif`, `tiff` | TIFF (Tag Image File Format) | -| `tk` | TK graphics | -| `vml`, `vmlz` | Vector Markup Language (VML) | -| `vrml` | VRML | -| `wbmp` | Wireless BitMap format | -| `webp` | Image format for the Web | -| `xlib`, `x11` | Xlib canvas | - ---- - -### HTML-like labels - -Example of using HTML-like labels: - -~~~prolog -export_graph_to_gv_file( - graph( - [vertex(1,[]),vertex(2,[label=html(table([tr([td(a),td(b)]),tr([td(c),td(d)])]))])], - [edge(1,2,[label='From 1 to 2.'])], - [] - ), - File, - [] -). -~~~ - -![](https://raw.githubusercontent.com/wouterbeek/plGraphViz/master/example2.png "Example graph with HTML-like labels.") - ---- - -Developed during 2013-2014 by [Wouter Beek](http://www.wouterbeek.com). diff --git a/data/gv_attrs_scrape.pl b/data/gv_attrs_scrape.pl deleted file mode 100644 index bcc7654..0000000 --- a/data/gv_attrs_scrape.pl +++ /dev/null @@ -1,119 +0,0 @@ -:- module( - gv_attrs_scrape, - [ - gv_attrs_scrape/1 % +File - ] -). - -/** GraphViz: Scrape attributes - -Writes compound terms of the following form to file: - -```prolog -gv_attr( - ?Name, - ?UsedBy:list(oneof([cluster,edge,graph,node,subgraph])), - ?Types:list(atom), - ?Default, - ?Minimum, - ?Notes -) is nondet. -``` - -@author Wouter Beek -@version 2015/10, 2016/07 -*/ - -:- use_module(library(apply)). -:- use_module(library(dcg/dcg_ext)). -:- use_module(library(debug)). -:- use_module(library(gv/gv_attr_type)). -:- use_module(library(http/http_download)). -:- use_module(library(lists)). -:- use_module(library(os/io)). -:- use_module(library(pl_term)). -:- use_module(library(print_ext)). -:- use_module(library(xpath)). -:- use_module(library(xpath/xpath_table)). -:- use_module(library(yall)). - - - - - -%! gv_attrs_scrape(+File) is det. - -gv_attrs_scrape(File):- - debug(gv, "Updating the GraphViz attributes table.", []), - call_to_stream(File, [In,Meta,Meta]>>gv_attrs_download(In)). - - -gv_attrs_download(Write):- - gv_attrs_iri(Iri), - html_download(Iri, Dom), - xpath_chk(Dom, //table(@align=lower_case(center)), TableDom), - xpath_table(TableDom, _, Rows), - maplist(write_attr_row(Write), Rows). - - -write_attr_row(Write, [Name,UsedBy1,Types1,Default1,Minimum,Notes]):- - atom_phrase(translate_usedby(UsedBy2), UsedBy1), - once(atom_phrase(translate_type(Types2), Types1)), - sort(UsedBy2, UsedBy3), - translate_default(Default1, Default2), - with_output_to( - Write, - write_fact(gv_attr(Name, UsedBy3, Types2, Default2, Minimum, Notes)) - ). - -gv_attrs_iri('http://www.graphviz.org/doc/info/attrs.html'). - - - - - -% HELPERS % - -%! translate_default(+Default1, -Default2) is det. - -% The empty string is represented by the empty atom. -translate_default('""', ''):- !. -% The absence of a default value is represented by an uninstantiated variable. -translate_default('', _):- !. -translate_default(Default, Default). - - - -%! translate_type(-Types:list(atom))// is det. - -translate_type([H|T]) --> - gv_attr_type(H), - whites, - translate_type(T). -translate_type([H]) --> - gv_attr_type(H). -translate_type([]) --> "". - - - -%! translated_usedby( -%! -UsedBy:list(oneof([cluster,edge,graph,node,subgraph])) -%! )// is det. - -translate_usedby([cluster|T]) --> - "C", !, - translate_usedby(T). -translate_usedby([edge|T]) --> - "E", !, - translate_usedby(T). -translate_usedby([graph|T]) --> - "G", !, - translate_usedby(T). -translate_usedby([node|T]) --> - "N", !, - translate_usedby(T). -translate_usedby([subgraph|T]) --> - "S", !, - translate_usedby(T). -translate_usedby([]) --> - "". diff --git a/data/gv_color_scrape.pl b/data/gv_color_scrape.pl deleted file mode 100644 index 102a02a..0000000 --- a/data/gv_color_scrape.pl +++ /dev/null @@ -1,52 +0,0 @@ -:- module( - gv_color_scrape, - [ - gv_color_scrape/1 % +File - ] -). - -/** GraphViz: Scrape colors - -@author Wouter Beek -@version 2015/10, 2016/07 -*/ - -:- use_module(library(apply)). -:- use_module(library(debug)). -:- use_module(library(http/http_download)). -:- use_module(library(lists)). -:- use_module(library(os/io)). -:- use_module(library(pl_term)). -:- use_module(library(print_ext)). -:- use_module(library(xpath)). -:- use_module(library(xpath/xpath_table)). -:- use_module(library(yall)). - - - - - -%! gv_color_scrape(+File) is det. - -gv_color_scrape(File):- - debug(io, "Updating the GraphViz color table.", []), - call_to_stream(File, [In,Meta,Meta]>>gv_color_download(In)). - - -gv_color_download(Write):- - gv_color_iri(Iri), - html_download(Iri, Dom), - xpath_chk(Dom, //table(1), TableDom1), - xpath_chk(Dom, //table(2), TableDom2), - maplist(write_color_table(Write), [x11,svg], [TableDom1,TableDom2]). - - -write_color_table(Write, Colorscheme, TableDom):- - xpath_table(TableDom, _, Rows), - append(Rows, Cells), - forall( - member(Cell, Cells), - with_output_to(Write, write_fact(gv_color(Colorscheme, Cell))) - ). - -gv_color_iri('http://www.graphviz.org/doc/info/colors.html'). diff --git a/example1.png b/example1.png deleted file mode 100644 index 31e7ba6..0000000 Binary files a/example1.png and /dev/null differ diff --git a/example2.png b/example2.png deleted file mode 100644 index 6e44b16..0000000 Binary files a/example2.png and /dev/null differ diff --git a/gv_attr_type.pl b/gv_attr_type.pl new file mode 100644 index 0000000..7a64c82 --- /dev/null +++ b/gv_attr_type.pl @@ -0,0 +1,417 @@ +:- module( + gv_attr_type, + [ + gv_attr_type/1, % ?Type:atom + addDouble//1, % +Double:float + addPoint//1, % +Point:compound + arrowType//1, % +ArrowType:atom + bool//1, % +Boolean:boolean + clusterMode//1, % +ClusterMode:atom + dirType//1, % +DirectionType:oneof([back,both,forward,none]) + double//1, % +Double:float + doubleList//1, % +Doubles:list(float) + escString//1, + %layerList//1, + %layerRange//1, + lblString//1, + int//1, % +Integer:integer + outputMode//1, % +OutputMode:atom + %packMode//1, + pagedir//1, % +Pagedir:atom + point//1, % +Point:compound + pointList//1, % +Points:list(compound) + %portPos//1, + quadType//1, % +QuadType:atom + rankType//1, % +RankType:atom + rankdir//1, % +RankDirection:atom + rect//1, % +Rectangle:compound + shape//1, + smoothType//1, % +SmoothType:atom + %splineType//1, + %startType//1, + string//1, % ?Content:atom + style//2 % +Context:oneof([cluster,edge,node]) + % +Style:atom + %viewPort//1 + ] +). +:- reexport( + plGraphViz(gv_color), + [ + color//1, % +Color:compound + colorList//1 % +ColorList:list(compound) + ] +). + +/** GraphViz attribute types + +@author Wouter Beek +@version 2014/06 +*/ + +:- use_module(dcg(dcg_abnf)). +:- use_module(dcg(dcg_cardinal)). +:- use_module(dcg(dcg_content)). + +:- use_module(plGraphViz(gv_html)). + + + +%! gv_attr_type(?Type:atom) is nondet. + +gv_attr_type(addDouble). +gv_attr_type(addPoint). +gv_attr_type(arrowType). +gv_attr_type(bool). +gv_attr_type(color). +gv_attr_type(colorList). +gv_attr_type(clusterMode). +gv_attr_type(dirType). +gv_attr_type(double). +gv_attr_type(doubleList). +gv_attr_type(escString). +gv_attr_type(layerList). +gv_attr_type(layerRange). +gv_attr_type(lblString). +gv_attr_type(int). +gv_attr_type(outputMode). +gv_attr_type(packMode). +gv_attr_type(pagedir). +gv_attr_type(point). +gv_attr_type(pointList). +gv_attr_type(portPos). +gv_attr_type(quadType). +gv_attr_type(rankType). +gv_attr_type(rankdir). +gv_attr_type(rect). +gv_attr_type(shape). +gv_attr_type(smoothType). +gv_attr_type(splineType). +gv_attr_type(startType). +gv_attr_type(string). +gv_attr_type(style). +gv_attr_type(viewPort). + + +%! addDouble(+Float:float)// . +% An *addDouble* is represented by a Prolog float. + +addDouble(Float) --> + '?'(`+`), + double(Float). + + +%! addPoint(+Point:compound)// . +% An *addPoint* is represented by a compound of the following form: +% `point(X:float,Y:float,InputOnly:boolean)`. + +addPoint(Point) --> + '?'(`+`), + point(Point). + + +%! arrowType(+ArrowType:atom)// . + +arrowType(V) --> + {arrowType(V)}, + atom(V). + +arrowType(V):- + primitive_shape(V). +arrowType(V):- + derived(V). +arrowType(V):- + backwards_compatible(V). + +primitive_shape(box). +primitive_shape(crow). +primitive_shape(circle). +primitive_shape(diamond). +primitive_shape(dot). +primitive_shape(inv). +primitive_shape(none). +primitive_shape(normal). +primitive_shape(tee). +primitive_shape(vee). + +derived(odot). +derived(invdot). +derived(invodot). +derived(obox). +derived(odiamond). + +backwards_compatible(ediamond). +backwards_compatible(empty). +backwards_compatible(halfopen). +backwards_compatible(invempty). +backwards_compatible(open). + + +bool(false) --> `false`. +bool(false) --> `no`. +bool(true) --> `true`. +bool(true) --> `yes`. + + +%! clusterMode(+ClusterMode:atom)// . + +clusterMode(V) --> + {clusterMode(V)}, + atom(V). + +clusterMode(global). +clusterMode(local). +clusterMode(none). + + +%! dirType(+DirectionType:oneof([back,both,forward,none]))// . + +dirType(DirType) --> + {dirType(DirType)}, + atom(DirType). + +dirType(back). +dirType(both). +dirType(forward). +dirType(none). + + +double(Double1) --> + % float//1 will check for float type. + {Double2 is Double1 * 1.0}, + float(Double2). + + +doubleList([H|T]) --> + double(H), + '*'(doubleList1, T). + +doubleList1(Float) --> + `:`, + double(Float). + + +%! escString(+String:atom)// . +% @tbd Support for context-dependent replacements. + +escString(String) --> + atom(String). + + +% @tbd layerList + + +% @tbd layerRange + + +lblString(V) --> + escString(V). +lblString(V) --> + gv_html_like_label(V). + + +int(V) --> + integer(V). + + +outputMode(V) --> + {outputMode(V)}, + atom(V). + +outputMode(breadthfirst). +outputMode(edgesfirst). +outputMode(nodesfirst). + + +% @tbd packMode + + +pagedir(V) --> + {pagedir(V)}, + atom(V). + +pagedir('BL'). +pagedir('BR'). +pagedir('LB'). +pagedir('LT'). +pagedir('RB'). +pagedir('RT'). +pagedir('TL'). +pagedir('TR'). + + +%! point(+Point:compound)// . +% A *point* is represented by a compound of the following form: +% `point(X:float,Y:float,InputOnly:boolean)`. + +point(point(X,Y,InputOnly)) --> + float(X), + `,`, + float(Y), + input_only(InputOnly). + +input_only(false) --> []. +input_only(true) --> `!`. + + +pointList(Points) --> + '*'(point, Points). + + +% @tbd portPos + + +quadType(V) --> + {quadType(V)}, + atom(V). + +quadType(fast). +quadType(none). +quadType(normal). + + +rankType(V) --> + {rankType(V)}, + atom(V). + +rankType(max). +rankType(min). +rankType(same). +rankType(sink). +rankType(source). + + +rankdir(V) --> + {rankdir(V)}, + atom(V). + +rankdir('BT'). +rankdir('LR'). +rankdir('RL'). +rankdir('TB'). + + +rect(rect(LowerLeftX,LowerLeftY,UpperRightX,UpperRightY)) --> + float(LowerLeftX), `,`, + float(LowerLeftY), `,`, + float(UpperRightX), `,`, + float(UpperRightY). + + +shape(V) --> + {polygon_based_shape(V)}, + atom(V). + +polygon_based_shape(assembly). +polygon_based_shape(box). +polygon_based_shape(box3d). +polygon_based_shape(cds). +polygon_based_shape(circle). +polygon_based_shape(component). +polygon_based_shape(diamond). +polygon_based_shape(doublecircle). +polygon_based_shape(doubleoctagon). +polygon_based_shape(egg). +polygon_based_shape(ellipse). +polygon_based_shape(fivepoverhang). +polygon_based_shape(folder). +polygon_based_shape(hexagon). +polygon_based_shape(house). +polygon_based_shape(insulator). +polygon_based_shape(invhouse). +polygon_based_shape(invtrapezium). +polygon_based_shape(invtriangle). +polygon_based_shape(larrow). +polygon_based_shape(lpromoter). +polygon_based_shape('Mcircle'). +polygon_based_shape('Mdiamond'). +polygon_based_shape('Msquare'). +polygon_based_shape(none). +polygon_based_shape(note). +polygon_based_shape(noverhang). +polygon_based_shape(octagon). +polygon_based_shape(oval). +polygon_based_shape(parallelogram). +polygon_based_shape(pentagon). +polygon_based_shape(plaintext). +polygon_based_shape(point). +polygon_based_shape(polygon). +polygon_based_shape(primersite). +polygon_based_shape(promoter). +polygon_based_shape(proteasesite). +polygon_based_shape(proteinstab). +polygon_based_shape(rarrow). +polygon_based_shape(rect). +polygon_based_shape(rectangle). +polygon_based_shape(restrictionsite). +polygon_based_shape(ribosite). +polygon_based_shape(rnastab). +polygon_based_shape(rpromoter). +polygon_based_shape(septagon). +polygon_based_shape(signature). +polygon_based_shape(square). +polygon_based_shape(tab). +polygon_based_shape(terminator). +polygon_based_shape(threepoverhang). +polygon_based_shape(trapezium). +polygon_based_shape(triangle). +polygon_based_shape(tripleoctagon). +polygon_based_shape(utr). + + +smoothType(V) --> + {smoothType(V)}, + atom(V). + +smoothType(avg_dist). +smoothType(graph_dist). +smoothType(none). +smoothType(power_dist). +smoothType(rng). +smoothType(spring). +smoothType(triangle). + + +% @tbd splineType + + +% @tbd startType + + +%! string(?Content:atom)// . +% A GraphViz string. + +string(Content) --> + atom(Content). + + +%! style(?Context:oneof([cluster,edge,node]), ?Style:atom) is nondet. + +style(Context, Style) --> + {style(Context, Style)}, + atom(Style). + +style(cluster, bold). +style(cluster, dashed). +style(cluster, dotted). +style(cluster, filled). +style(cluster, rounded). +style(cluster, solid). +style(cluster, striped). +style(edge, bold). +style(edge, dashed). +style(edge, dotted). +style(edge, solid). +style(node, bold). +style(node, dashed). +style(node, diagonals). +style(node, dotted). +style(node, filled). +style(node, rounded). +style(node, solid). +style(node, striped). +style(node, wedged). + + +% @tbd viewPort + diff --git a/gv_attrs.pl b/gv_attrs.pl new file mode 100644 index 0000000..dd0145a --- /dev/null +++ b/gv_attrs.pl @@ -0,0 +1,184 @@ +:- module( + gv_attrs, + [ + gv_attr/3 % +Context:oneof([cluster,edge,graph,node,subgraph]) + % +Attr1:nvpair + % +Attr2:nvpair + ] +). + +/** GraphViz attributes v2 + +@author Wouter Beek +@version 2014/06 +*/ + +:- use_module(library(apply)). +:- use_module(library(persistency)). +:- use_module(library(xpath)). + +:- use_module(dcg(dcg_content)). +:- use_module(dcg(dcg_generic)). +:- use_module(generics(db_ext)). +:- use_module(os(file_ext)). + +:- use_module(plHtml(html)). +:- use_module(plHtml(html_table)). + +:- use_module(plGraphViz(gv_attr_type)). % DCGs implementing attribute types. + +:- db_add_novel(user:prolog_file_type(log, logging)). + +%! gv_attr( +%! ?Name:atom, +%! ?UsedBy:list(oneof([cluster,edge,graph,node,subgraph])), +%! ?Types:list(atom), +%! ?Default, +%! ?Minimum, +%! ?Notes:atom +%! ) is nondet. + +:- persistent( + gv_attr( + name:atom, + used_by:list(oneof([cluster,edge,graph,node,subgraph])), + types:list(atom), + default, + minimum, + notes:atom + ) +). + +:- initialization(gv_attrs_init). + + + +gv_attr(Context, N=V, N=V):- + var(V), !, + gv_attr(N, UsedBy, _, V, _, _), + memberchk(Context, UsedBy). +gv_attr(Context, N=V1, N=V2):- + gv_attr(N, UsedBy, Types, _, Minimum, _), + memberchk(Context, UsedBy), + member(Type, Types), + ( + Type == style + -> + Dcg =.. [Type,Context,V1] + ; + Dcg =.. [Type,V1] + ), + once(dcg_phrase(Dcg, V2)), + check_minimum(V1, Minimum). + +check_minimum(_, ''):- !. +check_minimum(V, Min1):- + atom_number(Min1, Min2), + Min2 =< V. + + + +% INITIALIZATION + +%! assert_gv_attr_row(+Row:list(atom)) is det. + +assert_gv_attr_row([Name,UsedBy1,Types1,Default1,Minimum,Notes]):- + dcg_phrase(translate_usedby(UsedBy2), UsedBy1), + once(dcg_phrase(translate_type(Types2), Types1)), + sort(UsedBy2, UsedBy3), + translate_default(Default1, Default2), + assert_gv_attr(Name, UsedBy3, Types2, Default2, Minimum, Notes). + + +%! gv_attrs_downloads is det. +% Downloads the table describing GraphViz attributes from `graphviz.org`. + +gv_attrs_download:- + gv_attrs_url(Url), + download_html(Url, Dom, [html_dialect(html4),verbose(silent)]), + + xpath(Dom, //table(@align=center), TableDom), + % @tbd This does not work, since in `record_name(Element, Name)`, + % `Element` is a signleton list whereas a compound term is expected. + %%%%xpath(Dom, /html/body/table, TableDom), + + html_to_table(TableDom, _, Rows), + maplist(assert_gv_attr_row, Rows). + + +%! gv_attrs_file(-File:atom) is det. + +gv_attrs_file(File):- + absolute_file_name( + data(gv_attrs), + File, + [access(write),file_type(logging)] + ). + + +%! gv_attrs_init is det. + +gv_attrs_init:- + gv_attrs_file(File), + safe_db_attach(File), + file_age(File, Age), + gv_attrs_update(Age). + + +%! gv_attrs_update(+Age:float) is det. + +% The persistent store is still fresh. +gv_attrs_update(Age):- + once(gv_attr(_, _, _, _, _, _)), + Age < 8640000, !. +% The persistent store has become stale, so refresh it. +gv_attrs_update(_):- + retractall_gv_attr(_, _, _, _, _, _), + gv_attrs_download. + + +%! gv_attrs_url(-Url:url) is det. + +gv_attrs_url('http://www.graphviz.org/doc/info/attrs.html'). + + +%! safe_db_attach(+File:atom) is det. + +safe_db_attach(File):- + exists_file(File), !, + db_attach(File, []). +safe_db_attach(File):- + touch_file(File), + safe_db_attach(File). + + +%! translate_default(+Default1:atom, -Default2:atom) is det. + +% The empty string is represented by the empty atom. +translate_default('""', ''):- !. +% The absence of a default value is represented by an uninstantiated variable. +translate_default('', _):- !. +translate_default(Default, Default). + + +%! translate_type(-Types:list(atom))// is det. + +translate_type([H|T]) --> + {gv_attr_type(H)}, + atom(H), + whites, + translate_type(T). +translate_type([]) --> !, []. + + +%! translated_usedby( +%! -UsedBy:list(oneof([cluster,edge,graph,node,subgraph])) +%! )// is det. + +translate_usedby([cluster|T]) --> `C`, !, translate_usedby(T). +translate_usedby([edge|T]) --> `E`, !, translate_usedby(T). +translate_usedby([graph|T]) --> `G`, !, translate_usedby(T). +translate_usedby([node|T]) --> `N`, !, translate_usedby(T). +translate_usedby([subgraph|T]) --> `S`, !, translate_usedby(T). +translate_usedby([]) --> []. + diff --git a/gv_color.pl b/gv_color.pl new file mode 100644 index 0000000..19d6e05 --- /dev/null +++ b/gv_color.pl @@ -0,0 +1,151 @@ +:- module( + gv_color, + [ + gv_color/2, % ?Colorscheme:oneof([svg,x11]) + % ?Color:atom + color//1, % +Color:compound + colorList//1 % +Pairs:list(pair(compound,float)) + ] +). + +/** GraphViz color + +@author Wouter Beek +@tbd Color value `transparent` is only available in the output formats + ps, svg, fig, vmrl, and the bitmap formats. +@version 2014/06 +*/ + +:- use_module(library(apply)). +:- use_module(library(lists)). +:- use_module(library(persistency)). +:- use_module(library(xpath)). + +:- use_module(dcg(dcg_abnf)). +:- use_module(dcg(dcg_cardinal)). +:- use_module(dcg(dcg_content)). +:- use_module(generics(db_ext)). +:- use_module(os(file_ext)). +:- use_module(sparql(sparql_char)). + +:- use_module(plHtml(html)). +:- use_module(plHtml(html_table)). + +:- db_add_novel(user:prolog_file_type(log, logging)). + +%! gv_color(?Colorscheme:oneof([svg,x11]), ?Color:atom) is nondet. + +:- persistent(gv_color(colorscheme:oneof([svg,x11]),color:atom)). + +:- initialization(gv_color_init). + + + +% color(+Color:compound)// . +% A *color* is represented by a compound term of one of the following forms: +% 1. `rgb(Red:nonneg,Green:nonneg,Blue:nonneg)` +% 2. `rgba(Red:nonneg,Green:nonneg,Blue:nonneg,Alpha:nonneg)` +% 3. `hsv(Hue:between(0.0,1.0),Saturation:between(0.0,1.0),Value:between(0.0,1.0))` + +color(rgb(Red,Green,Blue)) --> !, + `#`, + '#'(3, hex_color, [Red,Green,Blue]). +color(rgbs(Red,Green,Blue,Alpha)) --> !, + `#`, + '#'(4, hex_color, [Red,Green,Blue,Alpha]). +color(hsv(Hue,Saturation,Value)) --> !, + '#'(3, hsv_color, [Hue,Saturation,Value]). +color(Name) --> + {gv_color(_, Name)}, + atom(Name). + +hex_color(I) --> + {W1 is I / 16}, + 'HEX'(W1), + {W2 is I mod 16}, + 'HEX'(W2). + +hsv_color(D, Head, Tail):- + format(codes(Head,Tail), '~2f', [D]). + + +%! colorList(+Pairs:list(pair(compound,float)))// . + +colorList(Pairs) --> + '+'(wc, Pairs). + +wc(Color-Float) --> + color(Color), + '?'(wc_weight(Float)). + +wc_weight(Float) --> + `;`, + float(Float). + + + +% INITIALIZATION + +%! gv_color_download is det. + +gv_color_download:- + gv_color_url(Url), + download_html(Url, Dom, [html_dialect(html4),verbose(silent)]), + xpath(Dom, //table(1), TableDom1), + xpath(Dom, //table(2), TableDom2), + maplist(assert_color_table, [x11,svg], [TableDom1,TableDom2]). + +assert_color_table(Colorscheme, TableDom):- + html_to_table(TableDom, _, Rows), + append(Rows, Cells), + forall( + member(Cell, Cells), + assert_gv_color(Colorscheme, Cell) + ). + + +%! gv_color_file(-File:atom) is det. + +gv_color_file(File):- + absolute_file_name( + data(gv_color), + File, + [access(write),file_type(logging)] + ). + + +%! gv_color_init is det. + +gv_color_init:- + gv_color_file(File), + safe_db_attach(File), + file_age(File, Age), + gv_color_update(Age). + + +%! gv_color_update(+Age:float) is det. + +% The persistent store is still fresh. +gv_color_update(Age):- + once(gv_color(_, _)), + Age < 8640000, !. +% The persistent store has become stale, so refresh it. +gv_color_update(_):- + retractall_gv_color(_, _), + gv_color_download. + + +%! gv_color_url(-Url:url) is det. + +gv_color_url('http://www.graphviz.org/doc/info/colors.html'). + + +%! safe_db_attach(+File:atom) is det. + +safe_db_attach(File):- + exists_file(File), !, + db_attach(File, []). +safe_db_attach(File):- + touch_file(File), + safe_db_attach(File). + diff --git a/gv_dot.pl b/gv_dot.pl new file mode 100644 index 0000000..9888973 --- /dev/null +++ b/gv_dot.pl @@ -0,0 +1,496 @@ +:- module( + gv_dot, + [ + gv_graph//1 % +GraphTerm:compound + ] +). + +/** GraphViz DOT generator + +DCG rules for GraphViz DOT file generation. + +Methods for writing to the GraphViz DOT format. + +In GraphViz vertices are called 'nodes'. + +@author Wouter Beek +@see http://www.graphviz.org/content/dot-language +@version 2013/07, 2013/09, 2014/03-2014/06 +*/ + +:- use_module(library(apply)). +:- use_module(library(lists)). +:- use_module(library(ordsets)). + +:- use_module(dcg(dcg_abnf)). +:- use_module(dcg(dcg_ascii)). +:- use_module(dcg(dcg_content)). +:- use_module(dcg(dcg_generic)). +:- use_module(dcg(dcg_meta)). +:- use_module(dcg(dcg_os)). + +:- use_module(plGraphViz(gv_attrs)). +:- use_module(plGraphViz(gv_html)). +:- use_module(plGraphViz(gv_numeral)). + + + +%! gv_attribute(+Attribute:nvpair)// is det. +% A single GraphViz attribute. +% We assume that the attribute has already been validated. + +gv_attribute(Name=Val) --> + gv_id(Name), `=`, gv_id(Val), `;`. + + +%! gv_attribute_list( +%! +Context:oneof([cluster,edge,graph,node,subgraph]), +%! +GraphAttributes:list(nvpair), +%! +Attributes:list(nvpair) +%! )// . +% ~~~{.abnf} +% attr_list = "[" [a_list] "]" [attr_list] +% a_list = ID "=" ID [","] [a_list] +% ~~~ + +% Attributes occur between square brackets. +gv_attribute_list(Context, _, Attrs1) --> + {maplist(gv_attr(Context), Attrs1, Attrs2)}, + bracketed(square, '*'(gv_attribute, Attrs2)). + + +%! gv_compass_pt(+Direction:oneof(['_',c,e,n,ne,nw,s,se,sw,w]))// . +% ~~~ +% compass_pt : (n | ne | e | se | s | sw | w | nw | c | _) +% ~~~ + +gv_compass_pt('_') --> `_`. +gv_compass_pt(c) --> `c`. +gv_compass_pt(e) --> `e`. +gv_compass_pt(n) --> `n`. +gv_compass_pt(ne) --> `ne`. +gv_compass_pt(nw) --> `nw`. +gv_compass_pt(s) --> `s`. +gv_compass_pt(se) --> `se`. +gv_compass_pt(sw) --> `sw`. +gv_compass_pt(w) --> `w`. + + +%! gv_edge_operator(+Directed:boolean)// . +% The binary edge operator between two vertices. +% The operator that is used depends on whether the graph is directed or +% undirected. +% +% @arg Directed Whether an edge is directed (operator `->`) or +% undirected (operator `--`). + +gv_edge_operator(false) --> !, `--`. +gv_edge_operator(true) --> arrow(right, 2). + + +%! gv_edge_statement( +%! +Indent:nonneg, +%! +Directed:boolean, +%! +GraphAttributes:list(nvpair), +%! +EdgeTerm:compound +%! )// is det. +% A GraphViz statement describing an edge. +% +% @arg Indent The indentation level at which the edge statement is written. +% @arg Directed Whether the graph is directed or not. +% @arg GraphAttributes The attributes of the graph. Some of these attributes +% may be used in the edge statement (e.g., the colorscheme). +% @arg EdgeTerm A compound term in the GIFormat, representing an edge. +% +% @tbd Instead of gv_node_id//1 we could have a gv_subgraph//1 +% at the from and/or to location. +% @tbd Add support for multiple, consecutive occurrences of gv_edge_rhs//2. + +gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> + indent(I), + gv_node_id(FromId), ` `, + + gv_edge_operator(Directed), ` `, + + gv_node_id(ToId), ` `, + + % We want `colorscheme/1` from the edges and + % `directionality/1` from the graph. + gv_attribute_list(edge, GAttrs, EAttrs), + newline. + + +%! gv_generic_attributes_statement( +%! +Kind:oneof([edge,graph,node]), +%! +Indent:integer, +%! +GraphAttributes:list(nvpair), +%! +CategoryAttributes:list(nvpair) +%! )// +% A GraphViz statement describing generic attributes for a category of items. +% +% @arg Kind The category of items for to the attributes apply. +% Possible values: `edge`, `graph`, and `node`. +% @arg Indent An integer indicating the number of tabs. +% @arg GraphAttributes A list of name-value pairs. +% @arg CategoryAttributes A list of name-value pairs. +% +% ~~~ +% attr_stmt = (graph / node / edge) attr_list +% ~~~ + +gv_generic_attributes_statement(_, _, _, []) --> [], !. +gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> + indent(I), + gv_kind(Kind), ` `, + gv_attribute_list(Kind, GraphAttrs, KindAttrs), newline. + + +%! gv_graph(+GraphTerm:compound)// +% The follow graph attributes are supported, +% beyond the GraphViz attributes for graphs: +% 1. `directonality(+Directed:oneof([directed,undirected]))` +% A directed graph uses the keyword `digraph`. +% An undirected graph uses the keyword `graph`. +% 2. `name(+GraphName:atom)` +% 3. `strict(+StrictGraph:boolean)` +% This forbids the creation of self-arcs and multi-edges; +% they are ignored in the input file. +% Only in combinattion with directionality `directed`. +% +% ~~~{.abnf} +% graph = ["strict"] ("graph" / "digraph") [ID] "{" stmt_list "}" +% ~~~ +% +% `GraphTerm` is a compound term of the following form: +% ~~~{.pl} +% graph(VertexTerms,RankedVertexTerms,EdgeTerms,GraphAttributes) +% ~~~ +% +% `RankedVertexTerms` is a list of compound terms of the following form: +% ~~~{.pl} +% rank(RankNode,ContentNodes) +% ~~~ +% +% @tbd Add support for subgraphs (arbitrary nesting). +% @tbd Add support for escape strings: +% http://www.graphviz.org/doc/info/attrs.html#k:escString +% @tbd Assert attributes that are generic with respect to a subgraph. +% @tbd Not all vertex and edge properties can be shared it seems (e.g., label). + +gv_graph(graph(VTerms, ETerms, GAttrs)) --> + gv_graph(graph(VTerms, [], ETerms, GAttrs)). + +gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> + { + shared_attributes(VTerms, SharedVAttrs, NewVTerms), + shared_attributes(ETerms, SharedEAttrs, NewETerms), + select_nvpair(strict=Strict, GAttrs1, GAttrs2, false), + select_nvpair(directed=Directed, GAttrs2, GAttrs3, true), + select_nvpair(name=GName, GAttrs3, GAttrs4, noname), + add_default_nvpair(GAttrs4, overlap, false, GAttrs5), + I = 0 + }, + + % The first statement in the GraphViz output. + % States that this file represents a graph according to the GraphViz format. + indent(I), + gv_strict(Strict), + gv_graph_type(Directed), ` `, + gv_id(GName), ` `, + bracketed( + curly, + gv_graph1( + I, + NewVTerms, SharedVAttrs, RankedVTerms, + NewETerms, SharedEAttrs, + Directed, GAttrs5 + ) + ), + newline. + +gv_graph1( + I, + NewVTerms, SharedVAttrs, RankedVTerms, + NewETerms, SharedEAttrs, + Directed, GAttrs +) --> + newline, + + % The following lines are indented. + {NewI is I + 1}, + + % Attributes that apply to the graph as a whole. + gv_generic_attributes_statement(graph, NewI, GAttrs, GAttrs), + + % Attributes that are the same for all nodes. + gv_generic_attributes_statement(node, NewI, GAttrs, SharedVAttrs), + + % Attributes that are the same for all edges. + gv_generic_attributes_statement(edge, NewI, GAttrs, SharedEAttrs), + + % Only add a newline if some content was written in the previous three + % lines. + ({(GAttrs == [], SharedVAttrs == [], SharedEAttrs == [])} -> `` ; newline), + + % The list of GraphViz nodes. + '*'(gv_node_statement(NewI, GAttrs), NewVTerms), + ({NewVTerms == []} -> `` ; newline), + + % The ranked GraphViz nodes (displayed at the same height). + '*'(gv_ranked_node_collection(NewI, GAttrs), RankedVTerms), + ({RankedVTerms == []} -> `` ; newline), + + { + findall( + edge(FromId,ToId,[]), + ( + nth0(Index1, RankedVTerms, rank(vertex(FromId,_,_),_)), + nth0(Index2, RankedVTerms, rank(vertex(ToId,_,_),_)), + % We assume that the rank vertices are nicely ordered. + succ(Index1, Index2) + ), + RankEdges + ) + }, + + % The rank edges. + '*'(gv_edge_statement(NewI, Directed, GAttrs), RankEdges), + + % The non-rank edges. + '*'(gv_edge_statement(NewI, Directed, GAttrs), NewETerms), + + % Note that we do not include a newline here. + + % We want to indent the closing curly brace. + indent(I). + + +%! gv_graph_type(+Directed:boolean)// . +% The type of graph that is represented. + +gv_graph_type(false) --> `graph`. +gv_graph_type(true) --> `digraph`. + + +%! gv_id(?Atom:atom)// is det. +% Parse a GraphViz identifier. +% There are 4 variants: +% 1. Any string of alphabetic (`[a-zA-Z'200-'377]`) characters, +% underscores (`_`) or digits (`[0-9]`), not beginning with a digit. +% 2. A numeral `[-]?(.[0-9]+ | [0-9]+(.[0-9]*)? )`. +% 3. Any double-quoted string (`"..."`) possibly containing +% escaped quotes (`\"`). +% In quoted strings in DOT, the only escaped character is +% double-quote (`"`). That is, in quoted strings, the dyad `\"` +% is converted to `"`. All other characters are left unchanged. +% In particular, `\\` remains `\\`. +% Layout engines may apply additional escape sequences. +% 4. An HTML string (`<...>`). +% +% @tbd Add support for HTML-like labels: +% http://www.graphviz.org/doc/info/shapes.html#html +% This requires an XML grammar! + +% HTML strings (variant 4). +gv_id(Atom) --> + dcg_atom_codes(gv_html_like_label, Atom), !. +% Alpha-numeric strings (variant 1). +gv_id(Atom) --> + {atom_codes(Atom, [H|T])}, + gv_id_first(H), + gv_id_rest(T), !, + % Variant 1 identifiers should not be (case-variants of) a + % GraphViz keyword. + {\+ gv_keyword([H|T])}. +% Numerals (variant 2) +gv_id(N) --> + {number(N)}, !, + gv_numeral(N). +% Double-quoted strings (variant 3). +% The quotes are already part of the given atom. +gv_id(Atom) --> + { + atom_codes(Atom, [H|T]), + append(S, [H], T) + }, + dcg_between(double_quote(H), gv_quoted_string(S)), !. +% Double-quoted strings (variant 3). +% The quotes are not in the given atom. They are written anyway. +gv_id(Atom) --> + quoted(double_quote, dcg_atom_codes(gv_quoted_string, Atom)), !. + +gv_id_first(X) --> ascii_letter(X). +gv_id_first(X) --> underscore(X). + +gv_id_rest([]) --> []. +gv_id_rest([H|T]) --> + (ascii_alpha_numeric(H) ; underscore(H)), + gv_id_rest(T). + + +%! gv_keyword(+Codes:list(code)) is semidet. +% Succeeds if the given codes for a GraphViz reserved keyword. + +gv_keyword(Codes):- + % Obviously, the keywords do not occur on the difference list input. + % So we must use phrase/[2,3]. + phrase(gv_keyword, Codes). + +%! gv_keyword// . +% GraphViz has reserved keywords that cannot be used as identifiers. +% GraphViz keywords are case-insensitive. + +gv_keyword --> `digraph`. +gv_keyword --> `edge`. +gv_keyword --> `graph`. +gv_keyword --> `node`. +gv_keyword --> `strict`. +gv_keyword --> `subgraph`. + + +%! gv_kind(+Kind:oneof([edge,graph,node]))// . + +gv_kind(edge) --> `edge`. +gv_kind(graph) --> `graph`. +gv_kind(node) --> `node`. + + +%! gv_node_id(+NodeId:atom)// . +% GraphViz node identifiers can be of the following two types: +% 1. A GraphViz identifier, see gv_id//1. +% 2. A GraphViz identifier plus a GraphViz port indicator, see gv_port//0. +% +% @tbd Add support for GraphViz port indicators +% inside GraphViz node identifiers. + +gv_node_id(Id) --> + gv_id(Id). +%gv_node_id(_) --> +% gv_id(_), +% gv_port. + + +%! gv_node_statement( +%! +Indent:integer, +%! +GraphAttributes, +%! +VertexTerm:compound +%! )// . +% A GraphViz statement describing a vertex (GraphViz calls vertices 'nodes'). + +gv_node_statement(I, GraphAttrs, vertex(Id,_,VAttrs)) --> + indent(I), + gv_node_id(Id), ` `, + gv_attribute_list(node, GraphAttrs, VAttrs), newline. + + +gv_port --> + gv_port_location, + '?'(gv_port_angle). +gv_port --> + gv_port_angle, + '?'(gv_port_location). +gv_port --> + `:`, + gv_compass_pt(_). + +gv_port_angle --> + `@`, + gv_id(_). + +gv_port_location --> + `:`, + gv_id(_). +gv_port_location --> + `:`, + bracketed( + round, + ( + gv_id(_), + `,`, + gv_id(_) + ) + ). + + +gv_quoted_string([]) --> []. +% Just to be sure, we do not allow the double quote +% that closes the string to be escaped. +gv_quoted_string([X]) --> + {X \== 92}, !, + [X]. +% A double quote is only allowed if it is escaped by a backslash. +gv_quoted_string([92,34|T]) --> !, + gv_quoted_string(T). +% Add the backslash escape character. +gv_quoted_string([34|T]) --> !, + `\\\"`, + gv_quoted_string(T). +% All other characters are allowed without escaping. +gv_quoted_string([H|T]) --> + [H], + gv_quoted_string(T). + + +gv_ranked_node_collection( + I, + GraphAttrs, + rank(Rank_V_Term,Content_V_Terms) +) --> + indent(I), + bracketed(curly, ( + newline, + + % The rank attribute. + {NewI is I + 1}, + indent(NewI), gv_attribute(rank=same), `;`, newline, + + '*'(gv_node_statement(NewI, GraphAttrs), [Rank_V_Term|Content_V_Terms]), + + % We want to indent the closing curly brace. + indent(I) + )), + newline. + + +%! gv_strict(+Strict:boolean)// is det. +% The keyword denoting that the graph is strict, i.e., has no self-arcs and +% no multi-edges. +% This only applies to directed graphs. + +gv_strict(false) --> []. +gv_strict(true) --> `strict `. + + + +% Helpers + +add_default_nvpair(Attrs1, N, Default, Attrs2):- + add_default_nvpair(Attrs1, N, Default, _, Attrs2). + +add_default_nvpair(Attrs, N, _, V, Attrs):- + memberchk(N=V, Attrs), !. +add_default_nvpair(Attrs1, N, Default, Default, Attrs2):- + ord_add_element(Attrs1, N=Default, Attrs2). + +select_nvpair(N=V, Attrs1, Attrs2, _):- + memberchk(N=V, Attrs1), !, + select(N=V, Attrs1, Attrs2). +select_nvpair(_=Default, Attrs, Attrs, Default). + + +extract_shared([], []):- !. +extract_shared(Argss, Shared):- + ord_intersection(Argss, Shared). + +remove_shared_attributes(Shared, Args1, Args2):- + ord_subtract(Args1, Shared, Args2). + +shared_attributes(Terms1, Shared, Terms2):- + maplist(term_components(Func), Terms1, Args1, Args2, Args3a), + extract_shared(Args3a, Shared), + maplist(remove_shared_attributes(Shared), Args3a, Args3b), + maplist(term_components(Func), Terms2, Args1, Args2, Args3b). + +term_components(Func, Term, Arg1, Arg2, Arg3):- + Term =.. [Func,Arg1,Arg2,Arg3]. + diff --git a/gv_file.pl b/gv_file.pl new file mode 100644 index 0000000..c780692 --- /dev/null +++ b/gv_file.pl @@ -0,0 +1,211 @@ +:- module( + gv_file, + [ + gif_to_gv_file/3, % +GraphInterchangeFormat:compound + % ?ToFile:atom + % +Options:list(nvpair) + graph_to_svg_dom/3, % +GraphInterchangeFormat:compound + % -SvgDom:list(compound) + % +Options:list(nvpair) + open_dot/1 % +File:file + ] +). + +/** GraphViz file + +Predicates for converting GIF-formatted terms +into GraphViz output files or SVG DOM structures. + +Also converts between GraphViz DOT formatted files +and GraphViz output files or SVG DOM structures. + +@author Wouter Beek +@version 2011-2013/09, 2013/11-2014/01, 2014/05, 2014/07 +*/ + +:- use_module(library(option)). +:- use_module(library(process)). +:- use_module(library(predicate_options)). % Declarations. + +:- use_module(generics(codes_ext)). +:- use_module(generics(db_ext)). +:- use_module(generics(error_ext)). +:- use_module(generics(trees)). +:- use_module(os(file_ext)). +:- use_module(os(run_ext)). +:- use_module(os(safe_file)). +:- use_module(svg(svg_file)). +:- use_module(ugraph(ugraph_export)). + +:- use_module(plGraphViz(gv_dot)). + +:- dynamic(user:file_type_program/2). +:- multifile(user:file_type_program/2). + +:- dynamic(user:module_uses/2). +:- multifile(user:module_uses/2). + +:- dynamic(user:prolog_file_type/2). +:- multifile(user:prolog_file_type/2). + +% Register DOT. +:- db_add_novel(user:prolog_file_type(dot, dot)). +:- db_add_novel(user:prolog_file_type(dot, graphviz)). +:- db_add_novel(user:file_type_program(dot, dotty)). +:- db_add_novel(user:file_type_program(dot, dotx)). +:- db_add_novel(user:module_uses(gv_file, file_type(dot))). + +% Register JPG/JPEG. +:- db_add_novel(user:prolog_file_type(jpeg, jpeg)). +:- db_add_novel(user:prolog_file_type(jpeg, graphviz_output)). +:- db_add_novel(user:prolog_file_type(jpg, jpeg)). +:- db_add_novel(user:prolog_file_type(jpg, graphviz_output)). + +% Register PDF. +:- db_add_novel(user:prolog_file_type(pdf, pdf)). +:- db_add_novel(user:prolog_file_type(pdf, graphviz_output)). + +% Register PNG. +:- db_add_novel(user:prolog_file_type(png, png)). +:- db_add_novel(user:prolog_file_type(png, graphviz_output)). + +% Register SVG. +:- db_add_novel(user:prolog_file_type(svg, graphviz_output)). +:- db_add_novel(user:prolog_file_type(svg, svg)). + +% Register XDOT. +:- db_add_novel(user:prolog_file_type(xdot, graphviz_output)). +:- db_add_novel(user:prolog_file_type(xdot, xdot)). + +:- predicate_options(graph_to_svg_dom/3, 3, [ + pass_to(gif_to_gv_file/3, 3) + ]). +:- predicate_options(gif_to_gv_file/3, 3, [ + pass_to(to_gv_file/3, 3) + ]). +:- predicate_options(to_gv_file/3, 3, [ + pass_to(convert_gv/3, 3) + ]). +:- predicate_options(convert_gv/3, 3, [ + method(+oneof([dot,sfdp])), + to_file_type(+oneof([dot,jpeg,pdf,svg,xdot])) + ]). + + + +%! gif_to_gv_file(+Gif:compound, -ToFile:atom, +Options:list(nvpair)) is det. +% Returns a file containing a GraphViz visualization of the given graph. +% +% The following options are supported: +% * =|method(+Method:oneof([dot,sfdp])|= +% The algorithm used by GraphViz for positioning the tree nodes. +% Either =dot= (default) or =sfdp=. +% * =|to_file_type(+FileType:oneof([dot,jpeg,pdf,svg,xdot])|= +% The file type of the generated GraphViz file. +% Default: `pdf`. + +gif_to_gv_file(Gif, ToFile, Options):- + once(phrase(gv_graph(Gif), Codes)), + to_gv_file(Codes, ToFile, Options). + + +%! graph_to_svg_dom( +%! +GraphInterchangeFormat:compound, +%! -SvgDom:list(compound), +%! +Options:list(nvpair) +%! ) is det. + +graph_to_svg_dom(Gif, SvgDom, Options1):- + % Make sure the file type of the output file is SvgDom. + merge_options([to_file_type=svg], Options1, Options2), + gif_to_gv_file(Gif, ToFile, Options2), + file_to_svg(ToFile, SvgDom), + safe_delete_file(ToFile). + + +%! open_dot(+File:atom) is det. +% Opens the given DOT file. +% +% @tbd Test support on Windows. +% @tbd Test support on OS-X. + +open_dot(File):- + once(find_program_by_file_type(dot, Program)), + run_program(Program, [File]). + + + +% SUPPORT PREDICATES % + +%! convert_gv(+FromFile:atom, ?ToFile:atom, +Options:list(nvpair)) is det. +% Converts a GraphViz DOT file to an image file, using a specific +% visualization method. + +convert_gv(FromFile, ToFile, Options):- + option(to_file_type(dot), Options), !, + rename_file(FromFile, ToFile). +convert_gv(FromFile, ToFile, Options):- + % The input file must be readable. + access_file(FromFile, read), + + % The method option. + option(method(Method), Options, dot), + must_be(oneof([dot,sfdp]), Method), + + % The file type option. + option(to_file_type(ToFileType), Options, pdf), + prolog_file_type(ToExtension, ToFileType), + prolog_file_type(ToExtension, graphviz_output), !, + + % The output file is either given or created. + ( + var(ToFile) + -> + absolute_file_name( + data(export), + ToFile, + [access(write),file_type(ToFileType)] + ) + ; + is_absolute_file_name(ToFile), + % The given output file must match a certain file extension. + file_name_extension(_, ToExtension, ToFile) + ), + % Now that we have the output file we can prevent the + % file type / file extension translation predicates from bakctracking. + !, + + % Run the GraphViz conversion command in the shell. + format(atom(OutputType), '-T~w', [ToExtension]), + process_create( + path(Method), + [OutputType,FromFile,'-o',ToFile], + [process(PID)] + ), + process_wait(PID, exit(ShellStatus)), + exit_code_handler('GraphViz', ShellStatus). + + +%! to_gv_file(+Codes:list(code), ?ToFile:atom, +Options:list(nvpair)) is det. + +to_gv_file(Codes, ToFile, Options):- + absolute_file_name( + data(tmp), + FromFile, + [access(write),file_type(graphviz)] + ), + setup_call_cleanup( + open(FromFile, write, Out, [encoding(utf8),type(test)]), + put_codes(Out, Codes), + close(Out) + ), + convert_gv(FromFile, ToFile, Options), + + %%%%% DEB: Store DOT file. + %%%%ignore(( + %%%% file_type_alternative(ToFile, graphviz, DOT_File), + %%%% safe_copy_file(FromFile, DOT_File) + %%%%)), + + safe_delete_file(FromFile). + diff --git a/gv_html.pl b/gv_html.pl new file mode 100644 index 0000000..b8d3190 --- /dev/null +++ b/gv_html.pl @@ -0,0 +1,60 @@ +:- module( + gv_html, + [ + gv_html_like_label//1 % +Codes:list(code) + ] +). + +/** GraphViz HTML + +@author Wouter Beek +@version 2013/07, 2013/09, 2014/03-2014/06 +*/ + +:- use_module(dcg(dcg_content)). + +:- use_module(plHtml(html_dcg)). + + + +%! gv_html_label(+Codes:list(code))// . +% +% @see http://www.graphviz.org/doc/info/shapes.html#html + +gv_html_label --> gv_html_text, !. +gv_html_label --> gv_html_table, !. +gv_html_label --> []. + +gv_html_like_label --> bracketed(angular, gv_html_label). + +gv_html_like_label(Content) --> bracketed(angular, html_dcg(Content)). + +gv_html_table --> html_element(table, _, gv_html_rows). +gv_html_table --> html_element(font, _, html_element(table, _, gv_html_rows)). + +gv_html_rows --> gv_html_row, gv_html_rows. +gv_html_rows --> gv_html_row, html_element(hr, _), gv_html_rows. +gv_html_rows --> gv_html_row. + +gv_html_row --> html_element(tr, _, gv_html_cells). + +gv_html_cell --> html_element(td, _, gv_html_label). +gv_html_cell --> html_element(td, _, html_element(img, _)). + +gv_html_cells --> gv_html_cell, gv_html_cells. +gv_html_cells --> gv_html_cell. +gv_html_cells --> gv_html_cell, html_element(vr, _), gv_html_cells. + +gv_html_text --> gv_html_textitem, gv_html_text. +gv_html_text --> gv_html_textitem. + +gv_html_textitem --> html_string, !. +gv_html_textitem --> html_entity, !. +gv_html_textitem --> html_element(br, _), !. +gv_html_textitem --> html_element(font, _, gv_html_text), !. +gv_html_textitem --> html_element(i, _, gv_html_text), !. +gv_html_textitem --> html_element(b, _, gv_html_text), !. +gv_html_textitem --> html_element(u, _, gv_html_text), !. +gv_html_textitem --> html_element(sub, _, gv_html_text), !. +gv_html_textitem --> html_element(sup, _, gv_html_text), !. + diff --git a/gv_numeral.pl b/gv_numeral.pl new file mode 100644 index 0000000..9b82fc0 --- /dev/null +++ b/gv_numeral.pl @@ -0,0 +1,71 @@ +:- module( + gv_numeral, + [ + gv_numeral//1 % ?Value:number + ] +). + +/** GraphViz numeral + +@author Wouter Beek +@version 2014/05-2014/06 +*/ + +:- use_module(dcg(dcg_abnf)). +:- use_module(dcg(dcg_cardinal)). +:- use_module(math(math_ext)). + + + +%! gv_numeral(?Value:number)// . +% ~~~{.bnf} +% ('-')? ( '.' [0-9]+ | [0-9]+ ( '.' [0-9]* )? ) +% ~~~ + +gv_numeral(N) --> + {nonvar(N)}, + {number_sign_parts(N, Sign, Abs)}, + ({Sign =:= -1} -> `-` ; ``), + gv_numeral_abs(Abs). +gv_numeral(N) --> + {var(N)}, + 'sign?'(Sign), + gv_numeral_abs(Abs), + {number_sign_parts(N, Sign, Abs)}. + + +gv_numeral_abs(N) --> + {nonvar(N)}, + {number_integer_parts(N, N1, N2)}, + ( + {N2 =:= 0} + -> + integer(N1) + ; + {N1 =:= 0} + -> + `.`, + integer(N2) + ; + integer(N1), + '?'((`.`, 'integer?'(N2))) + ). +gv_numeral_abs(N) --> + {var(N)}, + ( + `.`, + integer(N2) + -> + {N1 = 0} + ; + integer(N1), + ( + `.` + -> + 'integer?'(N2) + ; + {N2 = 0} + ) + ), + {number_integer_parts(N, N1, N2)}. + diff --git a/gv_tree.pl b/gv_tree.pl new file mode 100644 index 0000000..afeb8f6 --- /dev/null +++ b/gv_tree.pl @@ -0,0 +1,43 @@ +:- module( + gv_tree, + [ + tree_to_gv_file/3 % +Tree:compound + % ?ToFile:atom + % +Options:list(nvpair) + ] +). + +/** GraphViz tree + +Export trees to GraphViz. + +@author Wouter Beek +@version 2014/06-2014/07 +*/ + +:- use_module(library(aggregate)). + +:- use_module(generics(trees)). + +:- use_module(plGraphViz(gv_file)). +:- use_module(plGraphViz(gv_gif)). + + +%! tree_to_gv_file( +%! +Tree:compound, +%! ?ToFile:atom, +%! +Options:list(nvpair) +%! ) is det. +% Stores the given tree term into a GraphViz file. +% +% Options are passed on to create_gif/3 and gif_to_gv_file/3. + +tree_to_gv_file(Tree, ToFile, Options):- + tree_to_gif(Tree, Gif, Options), + gif_to_gv_file(Gif, ToFile, Options). + + +tree_to_gif(H-T, Gif, Options):- + tree_to_vertices_edges(Tree, Vs, Es), + create_gif(Vs, Es, Gif, Options). + diff --git a/index.pl b/index.pl new file mode 100644 index 0000000..7461d13 --- /dev/null +++ b/index.pl @@ -0,0 +1,2 @@ +% Index of project plGraphViz (empty). + diff --git a/load.pl b/load.pl new file mode 100644 index 0000000..4b117d1 --- /dev/null +++ b/load.pl @@ -0,0 +1,12 @@ +% Load file for plGraphViz. + +:- dynamic(user:prolog/3). +:- multifile(user:prolog/3). + user:project(plGraphViz, 'GraphViz support for SWI-Prolog.', plGraphViz). + +:- use_module(load_project). +:- load_project(plGraphViz, [ + plc-'Prolog-Library-Collection', + plHtml +]). + diff --git a/load_project.pl b/load_project.pl new file mode 100644 index 0000000..5599b5e --- /dev/null +++ b/load_project.pl @@ -0,0 +1,120 @@ +:- module( + load_project, + [ + load_project/2, % +Parent:atom + % +ChildProjects:list(or([atom,pair(atom)])) + load_subproject/2, % +ParentFileSearchPath:atom + % +Child:or([atom,pair(atom)]) + set_data_subdirectory/1 % +ParentDirectory:atom + ] +). + +/** Load project + +Generic code for loading a project: + * Create a subdirectory for data. + * Load the root of subprojects onto the file search path. + * Load the index of subprojects onto the file search path. + +@author Wouter Beek +@version 2014/06/14 +*/ + +:- use_module(library(ansi_term)). % Colorized terminal messages. +:- use_module(library(apply)). + +:- dynamic(user:project/2). +:- multifile(user:project/2). +:- dynamic(user:project/3). +:- multifile(user:project/3). + + + +load_project(Parent, ChildProjects):- + parent_alias(Parent, ParentFsp), + + % Entry point. + source_file(load_project(_,_), ThisFile), + file_directory_name(ThisFile, ThisDir), + assert(user:file_search_path(ParentFsp, ThisDir)), + assert(user:file_search_path(project, ThisDir)), + + % Set the data subdirectory. + set_data_subdirectory(ThisDir), + + % Load the root of submodules onto the file search path. + maplist(load_subproject(ParentFsp), ChildProjects), + + % Load the index into the file search path. + load_project_index(ParentFsp). + + + +%! load_subproject( +%! +ParentFileSearchPath:atom, +%! +Child:or([atom,pair(atom)]) +%! ) is det. + +load_subproject(ParentFsp, ChildFsp-ChildDir):- !, + load_subproject_file_search_path(ParentFsp, ChildFsp, ChildDir), + load_project_index(ChildFsp). +load_subproject(ParentFsp, Child):- + load_subproject(ParentFsp, Child-Child). + + +%! load_subproject_file_search_path( +%! +ParentFileSearchPath:atom, +%! +ChildFileSearchPath:atom, +%! +ChildDirectory:atom +%! ) is det. + +% The file search path for the subproject has already been set. +load_subproject_file_search_path(_, ChildFsp, _):- + user:file_search_path(ChildFsp, _). +load_subproject_file_search_path(ParentFsp, ChildFsp, ChildDir):- + Spec =.. [ParentFsp,ChildDir], + absolute_file_name(Spec, _, [access(read),file_type(directory)]), !, + assert(user:file_search_path(ChildFsp, Spec)). +load_subproject_file_search_path(_, ChildFsp, ChildDir):- + print_message(warning, missing_subproject_directory(ChildFsp,ChildDir)). + + +%! load_project_index(+FileSearchPath:atom) is det. + +load_project_index(Fsp):- + Spec =.. [Fsp,index], + absolute_file_name( + Spec, + File, + [access(read),file_errors(fail),file_type(prolog)] + ), !, + ensure_loaded(File). +load_project_index(_). + + +%! parent_alias(+Parent:atom, -ParentFsp:atom) is det. + +parent_alias(Parent, ParentFsp):- + user:project(Parent, _, ParentFsp), !. +parent_alias(Parent, Parent). + + +%! set_data_subdirectory(+ParentDirectory:atom) is det. + +set_data_subdirectory(ParentDir):- + directory_file_path(ParentDir, data, DataDir), + make_directory_path(DataDir), + assert(user:file_search_path(data, DataDir)). + + + +:- multifile(prolog:message//1). + +prolog:message(missing_subproject_directory(ChildFsp,ChildDir)) --> + [ + 'The ~a submodule is not present.'-[ChildFsp], nl, + 'Check whether subdirectory ~a is present in your project directory:'-[ChildDir], nl, + ' git submodule init', nl, + ' git submodule update' + ]. + diff --git a/pack.pl b/pack.pl deleted file mode 100644 index 989108a..0000000 --- a/pack.pl +++ /dev/null @@ -1,9 +0,0 @@ -author('Wouter Beek', 'me@wouterbeek.com'). -download('https://github.com/wouterbeek/plGraphViz/release/*.zip'). -home('https://github.com/wouterbeek/plGraphViz'). -maintainer('Wouter Beek', 'me@wouterbeek.com'). -name(plGraphViz). -packager('Wouter Beek', 'me@wouterbeek.com'). -requires('Prolog-Library-Collection'). -title(plGraphViz). -version('0.0.1'). diff --git a/plHtml b/plHtml new file mode 160000 index 0000000..08480c4 --- /dev/null +++ b/plHtml @@ -0,0 +1 @@ +Subproject commit 08480c40acaee5f70bfb21e3c641bef1e7d258bd diff --git a/prolog/fca/fca_viz.pl b/prolog/fca/fca_viz.pl deleted file mode 100644 index 083dbb2..0000000 --- a/prolog/fca/fca_viz.pl +++ /dev/null @@ -1,101 +0,0 @@ -:- module( - fca_viz, - [ - fca_export_graph/2, % +Context, -ExportGraph - fca_export_graph/3, % +Context, -ExportGraph, :Opts - fca_viz/2, % +Context, ?File - fca_viz/3 % +Context, ?File, :Opts - ] -). - -/** FCA visualization - -@author Wouter Beek -@version 2015/11-2016/01 -*/ - -:- use_module(library(aggregate)). -:- use_module(library(dcg/dcg_ext)). -:- use_module(library(dcg/dcg_pl)). -:- use_module(library(fca/fca)). -:- use_module(library(graph/build_export_graph)). -:- use_module(library(graph/s/s_graph)). -:- use_module(library(gv/gv_file)). -:- use_module(library(option)). -:- use_module(library(ordsets)). - -:- meta_predicate(fca_export_graph(+,?,:)). -:- meta_predicate(fca_viz(+,?,:)). - -:- predicate_options(fca_export_graph/3, 3, [ - concept_label(+callable) - ]). -:- predicate_options(fca_viz/3, 3, [ - pass_to(fca_export_graph/3, 3), - pass_to(graph_viz/3, 3) - ]). - -is_meta(concept_label). - - - - - -%! fca_export_graph(+Context:compound, -ExportGraph:compound) is det. -% Wrapper around fca_export_graph/3 with default options. - -fca_export_graph(Context, ExportG):- - fca_export_graph(Context, ExportG, []). - - -%! fca_export_graph( -%! +Context:compound, -%! -ExportGraph:compound, -%! :Options:list(compound) -%! ) is det. -% The following optios are supported: -% * concept_label(+callable) -% DCG writing the labels for individual concepts. - -fca_export_graph(Context, ExportG, Opts1):- - fca_hasse(Context, Hasse), - meta_options(is_meta, Opts1, Opts2), - option(concept_label(Label_3), Opts2, concept_label), - merge_options( - [ - vertex_label(Label_3), - vertex_rank(fca:concept_cardinality) - ], - Opts2, - Opts3 - ), - build_export_graph(Hasse, ExportG, Opts3). - - - -%! fca_viz(+Context:compound, ?File:atom) is det. -% Wrapper around fca_viz/3 with default options. - -fca_viz(Context, File):- - fca_viz(Context, File, []). - - -%! fca_viz(+Context:compound, ?File:atom, :Options:list(compound)) is det. - -fca_viz(Context, File, Opts1):- - meta_options(is_meta, Opts1, Opts2), - statistics(process_cputime, Time1), - fca_export_graph(Context, ExportG, Opts2), - ExportG = graph(_,_,Es,_), - aggregate_all(max(N), (member(edge(V1,V2,_), Es), (N = V1 ; N = V2)), N), - ignore(option(number_of_vertices(N), Opts2)), - statistics(process_cputime, Time2), - Time is Time2 - Time1, - ignore(option(process_cputime(Time), Opts2)), - graph_viz(ExportG, File, Opts2). - - - -%! concept_label(+Concept:compound)// is det. - -concept_label(concept(Os,As)) --> set(Os), " / ", set(As). diff --git a/prolog/graph/build_export_graph.pl b/prolog/graph/build_export_graph.pl deleted file mode 100644 index 5134069..0000000 --- a/prolog/graph/build_export_graph.pl +++ /dev/null @@ -1,369 +0,0 @@ -:- module( - build_export_graph, - [ - build_export_graph/2, % +Graph, -ExportGraph - build_export_graph/3 % +Graph - % -ExportGraph:compound - % +Options:list(compound) - ] -). - -/** Build graph representation for exporting - -Support for building GIF representations. - -# Graph Intermediate Format (GIF) - -## Graph - -```prolog -graph(Vs:ordset(compound),Ranks,Es:compound,Attributes:list(compound)) -``` - -### Edge - -```prolog -edge(FromVertexId,ToVertexId,Attributes:list(compound)) -``` - -### Rank - -```prolog -RankVertex:compound-ContentVertices:ordset(compound) -``` - -### Vertex - -```prolog -vertex(Id,Attributes:list(compound)) -``` - -# Property functions - -Edge label: - 1. [[graph_edge]] edge_label/2 - -Vertex coordinates: - 1. [[circle_coords]] circular_coord/4 - 2. [[random_coords]] random_coord/4 - ---- - -@author Wouter Beek -@version 2015/07, 2015/09-2016/01 -*/ - -:- use_module(library(apply)). -:- use_module(library(dcg/dcg_ext)). -:- use_module(library(graph/s/s_graph)). -:- use_module(library(list_ext)). -:- use_module(library(option_ext)). -:- use_module(library(ordsets)). -:- use_module(library(pairs)). - -:- predicate_options(build_export_graph/4, 4, [ - pass_to(edge_term/3, 3), - pass_to(graph_attributes/2, 2), - pass_to(vertex_term/3, 3) - ]). -:- predicate_options(edge_term/3, 3, [ - edge_arrowhead(+callable), - edge_color(+callable), - edge_id(+callable), - edge_label(+callable), - edge_penwidth(+callable), - edge_style(+callable) - ]). -:- predicate_options(graph_attributes/2, 2, [ - graph_charset(+oneof(['iso-8859-1','Latin1','UTF-8'])), - graph_colorscheme(+oneof([none,svg,x11])), - graph_directed(+boolean), - graph_fontsize(+float), - graph_label(+atom), - graph_overlap(+boolean) - ]). -:- predicate_options(vertex_term/3, 3, [ - vertex_color(+callable), - vertex_id(+callable), - vertex_image(+callable), - vertex_label(+callable), - vertex_peripheries(+callable), - vertex_position(+callable), - vertex_rank(+callable), - vertex_shape(+callable), - vertex_uri(+callable) - ]). - -:- meta_predicate(build_export_graph(+,-,:)). - -is_meta(edge_arrowhead). -is_meta(edge_color). -is_meta(edge_id). -is_meta(edge_label). -is_meta(edge_penwidth). -is_meta(edge_style). -is_meta(vertex_color). -is_meta(vertex_id). -is_meta(vertex_image). -is_meta(vertex_label). -is_meta(vertex_peripheries). -is_meta(vertex_position). -is_meta(vertex_rank). -is_meta(vertex_shape). -is_meta(vertex_uri). - - - - - -%! build_export_graph(+Graph, -ExportGraph:compound) is det. -% Wrapper around build_export_graph/3 with default options. - -build_export_graph(G, ExportG):- - build_export_graph(G, ExportG, []). - - -%! build_export_graph( -%! +Graph, -%! -ExportGraph:compound, -%! +Options:list(compound) -%! ) is det. -% Graph is either: -% * a coumpound term `graph(Vs,Es)`, or -% * an unlabeled graph as defined by `library(ugraph)`. -% -% The following options are supported: -% * `vertex_rank(:RankFunction)` -% Assigns a non-negative integer to each vertex. -% No default. - -build_export_graph(G, graph(VTerms2,VRanks,ETerms,GAttrs), Opts1):- - graph_components(G, Vs, Es), - meta_options(is_meta, Opts1, Opts2), - maplist(vertex_term0(Vs, Opts2), Vs, VTerms1), - build_export_ranks(Vs, VTerms1, VRanks, VTerms2, Opts2), - maplist(edge_term0(Vs, Opts2), Es, ETerms), - graph_attributes(GAttrs, Opts2). - -vertex_term0(Vs, Opts, V, VTerm) :- vertex_term(Vs, V, VTerm, Opts). - -edge_term0(Vs, Opts, E, ETerm) :- edge_term(Vs, E, ETerm, Opts). - -graph_components(graph(Vs,Es), Vs, Es):- !. -graph_components(G, Vs, Es):- - s_graph_components(G, Vs, Es). - -build_export_ranks(Vs, VTerms, VRanks, [], Opts):- - option(vertex_rank(VRank_2), Opts), !, - maplist(VRank_2, Vs, Ranks), - pairs_keys_values(Pairs, Ranks, VTerms), - group_pairs_by_key(Pairs, GroupedPairs), - build_export_rank_terms(GroupedPairs, VRanks). -build_export_ranks(_, VTerms, [], VTerms, _). - -build_export_rank_terms([N-VTerms|T1], [RankTerm-VTerms|T2]):- !, - build_export_rank_term(N, RankTerm), - build_export_rank_terms(T1, T2). -build_export_rank_terms([], []). - -build_export_rank_term(N, vertex(Id,[label(""),shape(none)])):- - format(atom(Id), "r~d", [N]). - - - -%! edge_term( -%! +Vertices:ordset(compound), -%! +Edge:compound, -%! -EdgeTerm:compound, -%! +Options:list(compound) -%! ) is det. -% The following options are supported: -% * `edge_arrowhead(+callable)` -% No default. -% * `edge_color(+callable)` -% No default. -% * `edge_id(+callable)` -% Function that assignes the unique identifiers for an edge's -% incident vertices. -% * `edge_label(+callable)` -% No default. -% * `edge_penwidth(+callable)` -% No default. -% * `edge_style(+callable)` -% No default. - -edge_term(Vs, E, edge(FromId,ToId,EAttrs), Opts):- - % Arrowhead - if_option(edge_arrowhead(Arrowhead_2), Opts, - call(Arrowhead_2, E, EArrowhead) - ), - - % Color. - if_option(edge_color(ColorFunction), Opts, call(ColorFunction, E, EColor)), - - % Id. - ( option(edge_id(Id_2), Opts) - -> call(Id_2, E, FromId, ToId) - ; edge_components(E, FromV, ToV), - nth0chk(FromId, Vs, FromV), - nth0chk(ToId, Vs, ToV) - ), - - % Label. - if_option(edge_label(ELabel_3), Opts, string_phrase(dcg_call(ELabel_3, E), ELabel)), - - % Penwidth. - if_option(edge_penwidth(Penwidth_2), Opts, call(Penwidth_2, E, EPenwidth)), - - % Style. - if_option(edge_style(Style_2), Opts, call(Style_2, E, EStyle)), - - exclude( - option_has_var_value, - [ - arrowhead(EArrowhead), - color(EColor), - label(ELabel), - penwidth(EPenwidth), - style(EStyle) - ], - EAttrs - ). - - - -%! graph_attributes( -%! -GraphAttributes:list(compound), -%! +Options:list(compound) -%! ) is det. -% The following options are supported: -% * `graph_charset(+oneof(['iso-8859-1','Latin1','UTF-8']))` -% The name of the character set that is used to encode text in the graph. -% Default: `UTF-8`. -% * `graph_colorscheme(+oneof([none,svg,x11]))` -% The colorscheme from which the color in this graph are taken. -% Default: `x11`. -% * `graph_directed(+boolean)` -% Whether the graph is directed (`true`) or undirected (`false`). -% Default: `false`. -% * `graph_fontsize(+float)` -% The font size of text in the graph. -% Default: `11.0`. -% * `graph_label(+atom)` -% The graph label. -% No default. -% * `graph_overlap(+boolean)` -% Whether the vertices are allowed to overlap. -% Default: `false`. - -graph_attributes(GAttrs, Opts):- - % Characer set. - option(graph_charset(Charset), Opts, 'UTF-8'), - % Colorscheme. - option(graph_colorscheme(Colorscheme), Opts, x11), - % Directed. - option(graph_directed(Directed), Opts, false), - % Fontsize. - option(graph_fontsize(Fontsize), Opts, 11.0), - % Label. - % Defaults to the empty string. - option(graph_label(GLabel), Opts, '""'), - % Overlap. - option(graph_overlap(Overlap), Opts, false), - exclude( - option_has_var_value, - [ - charset(Charset), - colorscheme(Colorscheme), - directed(Directed), - fontsize(Fontsize), - label(GLabel), - overlap(Overlap) - ], - GAttrs - ). - - - -%! vertex_term( -%! +Vertices:ordset(compound), -%! +Vertex:compound, -%! -VertexTerm:compound, -%! +Options:list(compound) -%! ) is det. -% The following options are supported: -% * `vertex_color(:ColorFunction)` -% A function that assigns colors to vertices. -% No default. -% * `vertex_id(:ColorFunction)` -% A functions that assigns unique identifiers to vertices. -% * `vertex_image(:ImageFunction)` -% A function that assigns images to vertices. -% No default. -% * `vertex_label(:LabelFunction)` -% A function that assigns labels to vertices. -% No default. -% * `vertex_peripheries(:PeripheriesFunction)` -% A function that assinges peripheries to vertices. -% No default. -% * `vertex_position(:PositionFunction)` -% No default. -% * `vertex_shape(:ShapeFunction)` -% A function that assinges shapes to vertices. -% No default. -% * `vertex_uri(:UriFunction)` - -vertex_term(Vs, V, vertex(VId,VAttrs), Opts):- - % Color. - if_option(vertex_color(Color_2), Opts, call(Color_2, V, VColor)), - - % Id. - (option(vertex_id(Id_2), Opts) -> call(Id_2, V, VId) ; nth0chk(VId, Vs, V)), - - % Image. - ignore(if_option(vertex_image(Image_2), Opts, call(Image_2, V, VImage))), - - % Label. - if_option(vertex_label(VLabel_2), Opts, string_phrase(dcg_call(VLabel_2, V), VLabel)), - - % Peripheries. - if_option(vertex_peripheries(Peripheries_2), Opts, - call(Peripheries_2, V, VPeripheries) - ), - - % Position. - if_option(vertex_position(Position_4), Opts, - call(Position_4, Vs, Opts, V, VPosition) - ), - - % Shape. - if_option(vertex_shape(Shape_2), Opts, call(Shape_2, V, VShape)), - - % URI - if_option(vertex_uri(Uri_2), Opts, call(Uri_2, V, VUri)), - - exclude( - option_has_var_value, - [ - color(VColor), - image(VImage), - label(VLabel), - peripheries(VPeripheries), - pos(VPosition), - shape(VShape), - 'URL'(VUri) - ], - VAttrs - ). - - - - - -% HELPERS % - -%! edge_components(+Edge:compound, -FromV, -ToV) is det. - -edge_components(edge(FromV,_,ToV), FromV, ToV):- !. -edge_components(edge(FromV,ToV), FromV, ToV):- !. -edge_components(FromV-ToV, FromV, ToV):- !. diff --git a/prolog/gv/gv_attr_type.pl b/prolog/gv/gv_attr_type.pl deleted file mode 100644 index f55fce5..0000000 --- a/prolog/gv/gv_attr_type.pl +++ /dev/null @@ -1,421 +0,0 @@ -:- module( - gv_attr_type, - [ - gv_attr_type//1, % ?Type:atom - addDouble//1, % +Double:float - addPoint//1, % +Point:compound - arrowType//1, % +ArrowType:atom - bool//1, % +Boolean:boolean - clusterMode//1, % +ClusterMode:atom - dirType//1, % +DirectionType:oneof([back,both,forward,none]) - double//1, % +Double:float - doubleList//1, % +Doubles:list(float) - escString//1, - %layerList//1, - %layerRange//1, - lblString//1, - int//1, % +Integer:integer - outputMode//1, % +OutputMode:atom - %packMode//1, - pagedir//1, % +Pagedir:atom - point//1, % +Point:compound - pointList//1, % +Points:list(compound) - %portPos//1, - quadType//1, % +QuadType:atom - rankType//1, % +RankType:atom - rankdir//1, % +RankDirection:atom - rect//1, % +Rectangle:compound - shape//1, - smoothType//1, % +SmoothType:atom - %splineType//1, - %startType//1, - string//1, % ?Content:atom - style//2 % +Context:oneof([cluster,edge,node]) - % +Style:atom - %viewPort//1 - ] -). -:- reexport( - library(gv/gv_color), - [ - color//1, % +Color:compound - colorList//1 % +ColorList:list(compound) - ] -). - -/** GraphViz attribute types - -@author Wouter Beek -@version 2015/07, 2015/11, 2016/02 -*/ - -:- use_module(library(dcg/dcg_ext), except([string//1])). -:- use_module(library(gv/gv_html)). - - - - - -%! gv_attr_type(?Type:atom) is nondet. - -gv_attr_type(addDouble) --> "addDouble". -gv_attr_type(addPoint) --> "addPoint". -gv_attr_type(arrowType) --> "arrowType". -gv_attr_type(bool) --> "bool". -gv_attr_type(color) --> "color". -gv_attr_type(colorList) --> "colorList". -gv_attr_type(clusterMode) --> "clusterMode". -gv_attr_type(dirType) --> "dirType". -gv_attr_type(double) --> "double". -gv_attr_type(doubleList) --> "doubleList". -gv_attr_type(escString) --> "escString". -gv_attr_type(layerList) --> "layerList". -gv_attr_type(layerRange) --> "layerRange". -gv_attr_type(lblString) --> "lblString". -gv_attr_type(int) --> "int". -gv_attr_type(outputMode) --> "outputMode". -gv_attr_type(packMode) --> "packMode". -gv_attr_type(pagedir) --> "pagedir". -gv_attr_type(point) --> "point". -gv_attr_type(pointList) --> "pointList". -gv_attr_type(portPos) --> "portPos". -gv_attr_type(quadType) --> "quadType". -gv_attr_type(rankType) --> "rankType". -gv_attr_type(rankdir) --> "rankdir". -gv_attr_type(rect) --> "rect". -gv_attr_type(shape) --> "shape". -gv_attr_type(smoothType) --> "smoothType". -gv_attr_type(splineType) --> "splineType". -gv_attr_type(startType) --> "startType". -gv_attr_type(string) --> "string". -gv_attr_type(style) --> "style". -gv_attr_type(viewPort) --> "viewPort". - - - -%! addDouble(+Float:float)// . -% An *addDouble* is represented by a Prolog float. - -addDouble(N) --> ("+", ! ; ""), float(N). - - - -%! addPoint(+Point:compound)// . -% An *addPoint* is represented by a compound of the following form: -% `point(X:float,Y:float,InputOnly:boolean)`. - -addPoint(Point) --> ("+", ! ; ""), point(Point). - - - -%! arrowType(+ArrowType:atom)// . - -arrowType(V) --> primitive_shape(V). -arrowType(V) --> derived(V). -arrowType(V) --> backwards_compatible(V). - -primitive_shape(box) --> "box". -primitive_shape(crow) --> "crow". -primitive_shape(circle) --> "circle". -primitive_shape(diamond) --> "diamond". -primitive_shape(dot) --> "dot". -primitive_shape(inv) --> "inv". -primitive_shape(none) --> "none". -primitive_shape(normal) --> "normal". -primitive_shape(tee) --> "tee". -primitive_shape(vee) --> "vee". - -derived(odot) --> "odot". -derived(invdot) --> "invdot". -derived(invodot) --> "invodot". -derived(obox) --> "obox". -derived(odiamond) --> "odiamond". - -backwards_compatible(ediamond) --> "ediamond". -backwards_compatible(empty) --> "empty". -backwards_compatible(halfopen) --> "halfopen". -backwards_compatible(invempty) --> "invempty". -backwards_compatible(open) --> "open". - - - -%! bool(+Value:boolean)// . - -bool(false) --> "false". -bool(false) --> "no". -bool(true) --> "true". -bool(true) --> "yes". - - - -%! clusterMode(+ClusterMode:atom)// . - -clusterMode(global) --> "global". -clusterMode(local) --> "local". -clusterMode(none) --> "none". - - - -%! dirType(+DirectionType:oneof([back,both,forward,none]))// . - -dirType(back) --> "back". -dirType(both) --> "both". -dirType(forward) --> "forward". -dirType(none) --> "none". - - - -%! double(+Double:float)// . - -double(N) --> float(N). - - - -%! doubleList(+Doubles:list(float))// . - -doubleList([H|T]) --> double(H), (":", !, doubleList(T) ; {T = []}). - - - -%! escString(+String:or([atom,string]))// . -% @tbd Support for context-dependent replacements. - -escString(S1) --> - {( string(S1) - -> string_phrase(escape_double_quotes, S1, S2) - ; atom_phrase(escape_double_quotes, S1, S2) - )}, - "\"", atom(S2), "\"". - -escape_double_quotes, [0'\\,0'"] --> [0'"], !, escape_double_quotes. -escape_double_quotes, [X] --> [X], !, escape_double_quotes. -escape_double_quotes --> "". - - - -% @tbd layerList - - - -% @tbd layerRange - - - -%! lblString(+String:compound)// . - -lblString(html_like_label(V)) --> gv_html_like_label(V). -lblString(V) --> escString(V). - - - -%! int(+Integer:integer)// . - -int(V) --> integer(V). - - - -%! outputMode(+OutputMode:atom)// . - -outputMode(breadthfirst) --> "breadthfirst". -outputMode(edgesfirst) --> "edgesfirst". -outputMode(nodesfirst) --> "nodesfirst". - - - -% @tbd packMode - - - -%! pagedir(+PageDirection:atom)// . - -pagedir('BL') --> "BL". -pagedir('BR') --> "BR". -pagedir('LB') --> "LB". -pagedir('LT') --> "LT". -pagedir('RB') --> "RB". -pagedir('RT') --> "RT". -pagedir('TL') --> "TL". -pagedir('TR') --> "TR". - - - -%! point(+Point:compound)// . -% A *point* is represented by a compound of the following form: -% `point(X:float,Y:float,Changeable:boolean)`. - -point(point(X,Y,Changeable)) --> - float(X), ",", float(Y), - input_changeable(Changeable). - -input_changeable(false) --> "". -input_changeable(true) --> "!". - - - -%! pointList(+Points:list(compound))// . - -pointList(Points) --> - *(point, Points). - - - -% @tbd portPos - - - -%! quadType(+QuadType:atom)// . - -quadType(fast) --> "fast". -quadType(none) --> "none". -quadType(normal) --> "normal". - - - -%! rankType(+RankType:atom)// . - -rankType(max) --> "max". -rankType(min) --> "min". -rankType(same) --> "same". -rankType(sink) --> "sink". -rankType(source) --> "source". - - - -%! rankdir(+RankDirection:oneof(['BT','LR','RL','TB']))// . - -rankdir('BT') --> "BT". -rankdir('LR') --> "LR". -rankdir('RL') --> "RL". -rankdir('TB') --> "TB". - - - -%! rect(+Rectangle:compound)// . - -rect(rect(LowerLeftX,LowerLeftY,UpperRightX,UpperRightY)) --> - float(LowerLeftX), ",", - float(LowerLeftY), ",", - float(UpperRightX), ",", - float(UpperRightY). - - - -%! shape(+Shape:atom)// . - -shape(V) --> {polygon_based_shape(V)}, atom(V). - -polygon_based_shape(assembly). -polygon_based_shape(box). -polygon_based_shape(box3d). -polygon_based_shape(cds). -polygon_based_shape(circle). -polygon_based_shape(component). -polygon_based_shape(diamond). -polygon_based_shape(doublecircle). -polygon_based_shape(doubleoctagon). -polygon_based_shape(egg). -polygon_based_shape(ellipse). -polygon_based_shape(fivepoverhang). -polygon_based_shape(folder). -polygon_based_shape(hexagon). -polygon_based_shape(house). -polygon_based_shape(insulator). -polygon_based_shape(invhouse). -polygon_based_shape(invtrapezium). -polygon_based_shape(invtriangle). -polygon_based_shape(larrow). -polygon_based_shape(lpromoter). -polygon_based_shape('Mcircle'). -polygon_based_shape('Mdiamond'). -polygon_based_shape('Msquare'). -polygon_based_shape(none). -polygon_based_shape(note). -polygon_based_shape(noverhang). -polygon_based_shape(octagon). -polygon_based_shape(oval). -polygon_based_shape(parallelogram). -polygon_based_shape(pentagon). -polygon_based_shape(plaintext). -polygon_based_shape(point). -polygon_based_shape(polygon). -polygon_based_shape(primersite). -polygon_based_shape(promoter). -polygon_based_shape(proteasesite). -polygon_based_shape(proteinstab). -polygon_based_shape(rarrow). -polygon_based_shape(rect). -polygon_based_shape(rectangle). -polygon_based_shape(restrictionsite). -polygon_based_shape(ribosite). -polygon_based_shape(rnastab). -polygon_based_shape(rpromoter). -polygon_based_shape(septagon). -polygon_based_shape(signature). -polygon_based_shape(square). -polygon_based_shape(tab). -polygon_based_shape(terminator). -polygon_based_shape(threepoverhang). -polygon_based_shape(trapezium). -polygon_based_shape(triangle). -polygon_based_shape(tripleoctagon). -polygon_based_shape(utr). - - - -%! smoothType(+SmoothType:atom)// . - -smoothType(V) --> {smoothType(V)}, atom(V). - -smoothType(avg_dist). -smoothType(graph_dist). -smoothType(none). -smoothType(power_dist). -smoothType(rng). -smoothType(spring). -smoothType(triangle). - - - -% @tbd splineType - - - -% @tbd startType - - - -%! string(?String:atom)// . -% A GraphViz string. - -string(Content) --> "\"", atom(Content), "\"". - - - -%! style(?Context:oneof([cluster,edge,node]), ?Style:atom) is nondet. - -style(Context, Style) --> {style(Context, Style)}, atom(Style). - -style(cluster, bold). -style(cluster, dashed). -style(cluster, dotted). -style(cluster, filled). -style(cluster, rounded). -style(cluster, solid). -style(cluster, striped). -style(edge, bold). -style(edge, dashed). -style(edge, dotted). -style(edge, solid). -style(node, bold). -style(node, dashed). -style(node, diagonals). -style(node, dotted). -style(node, filled). -style(node, rounded). -style(node, solid). -style(node, striped). -style(node, wedged). - - - -% @tbd viewPort diff --git a/prolog/gv/gv_attrs.data b/prolog/gv/gv_attrs.data deleted file mode 100644 index 95fc680..0000000 --- a/prolog/gv/gv_attrs.data +++ /dev/null @@ -1,169 +0,0 @@ -gv_attr('Damping',[graph],[double],'0.99','0.0','neato only'). -gv_attr('K',[cluster,graph],[double],'0.3','0','sfdp, fdp only'). -gv_attr('URL',[cluster,edge,graph,node],[escString],_G59448,'','svg, postscript, map only'). -gv_attr('_background',[graph],[string],_G59644,'',''). -gv_attr(area,[cluster,node],[double],'1.0','>0','patchwork only'). -gv_attr(arrowhead,[edge],[arrowType],normal,'',''). -gv_attr(arrowsize,[edge],[double],'1.0','0.0',''). -gv_attr(arrowtail,[edge],[arrowType],normal,'',''). -gv_attr(bb,[graph],[rect],'','','write only'). -gv_attr(bgcolor,[cluster,graph],[color,colorList],_G60571,'',''). -gv_attr(center,[graph],[bool],false,'',''). -gv_attr(charset,[graph],[string],'"UTF-8"','',''). -gv_attr(clusterrank,[graph],[clusterMode],local,'','dot only'). -gv_attr(color,[cluster,edge,node],[color,colorList],black,'',''). -gv_attr(colorscheme,[cluster,edge,graph,node],[string],'','',''). -gv_attr(comment,[edge,graph,node],[string],'','',''). -gv_attr(compound,[graph],[bool],false,'','dot only'). -gv_attr(concentrate,[graph],[bool],false,'',''). -gv_attr(constraint,[edge],[bool],true,'','dot only'). -gv_attr(decorate,[edge],[bool],false,'',''). -gv_attr(defaultdist,[graph],[double],'1+(avg. len)*sqrt(|V|)',epsilon,'neato only'). -gv_attr(dim,[graph],[int],'2','2','sfdp, fdp, neato only'). -gv_attr(dimen,[graph],[int],'2','2','sfdp, fdp, neato only'). -gv_attr(dir,[edge],[dirType],'forward(directed)none(undirected)','',''). -gv_attr(diredgeconstraints,[graph],[string,bool],false,'','neato only'). -gv_attr(distortion,[node],[double],'0.0','-100.0',''). -gv_attr(dpi,[graph],[double],'96.00.0','','svg, bitmap output only'). -gv_attr(edgeURL,[edge],[escString],'','','svg, map only'). -gv_attr(edgehref,[edge],[escString],'','','svg, map only'). -gv_attr(edgetarget,[edge],[escString],_G63711,'','svg, map only'). -gv_attr(edgetooltip,[edge],[escString],'','','svg, cmap only'). -gv_attr(epsilon,[graph],[double],'.0001 * # nodes(mode == KK).0001(mode == major)','','neato only'). -gv_attr(esep,[graph],[addDouble,addPoint],'+3','','not dot'). -gv_attr(fillcolor,[cluster,edge,node],[color,colorList],'lightgrey(nodes)black(clusters)','',''). -gv_attr(fixedsize,[node],[bool,string],false,'',''). -gv_attr(fontcolor,[cluster,edge,graph,node],[color],black,'',''). -gv_attr(fontname,[cluster,edge,graph,node],[string],'"Times-Roman"','',''). -gv_attr(fontnames,[graph],[string],'','','svg only'). -gv_attr(fontpath,[graph],[string],'system-dependent','',''). -gv_attr(fontsize,[cluster,edge,graph,node],[double],'14.0','1.0',''). -gv_attr(forcelabels,[graph],[bool],true,'',''). -gv_attr(gradientangle,[cluster,graph,node],[int],'','',''). -gv_attr(group,[node],[string],'','','dot only'). -gv_attr(headURL,[edge],[escString],'','','svg, map only'). -gv_attr(head_lp,[edge],[point],'','','write only'). -gv_attr(headclip,[edge],[bool],true,'',''). -gv_attr(headhref,[edge],[escString],'','','svg, map only'). -gv_attr(headlabel,[edge],[lblString],'','',''). -gv_attr(headport,[edge],[portPos],center,'',''). -gv_attr(headtarget,[edge],[escString],_G4892,'','svg, map only'). -gv_attr(headtooltip,[edge],[escString],'','','svg, cmap only'). -gv_attr(height,[node],[double],'0.5','0.02',''). -gv_attr(href,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only'). -gv_attr(id,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only'). -gv_attr(image,[node],[string],'','',''). -gv_attr(imagepath,[graph],[string],'','',''). -gv_attr(imagescale,[node],[bool,string],false,'',''). -gv_attr(inputscale,[graph],[double],_G6250,'','fdp, neato only'). -gv_attr(label,[cluster,edge,graph,node],[lblString],'"\\N" (nodes)"" (otherwise)','',''). -gv_attr(labelURL,[edge],[escString],'','','svg, map only'). -gv_attr(label_scheme,[graph],[int],'0','0','sfdp only'). -gv_attr(labelangle,[edge],[double],'-25.0','-180.0',''). -gv_attr(labeldistance,[edge],[double],'1.0','0.0',''). -gv_attr(labelfloat,[edge],[bool],false,'',''). -gv_attr(labelfontcolor,[edge],[color],black,'',''). -gv_attr(labelfontname,[edge],[string],'"Times-Roman"','',''). -gv_attr(labelfontsize,[edge],[double],'14.0','1.0',''). -gv_attr(labelhref,[edge],[escString],'','','svg, map only'). -gv_attr(labeljust,[cluster,graph],[string],'"c"','',''). -gv_attr(labelloc,[cluster,graph,node],[string],'"t"(clusters)"b"(root graphs)"c"(nodes)','',''). -gv_attr(labeltarget,[edge],[escString],_G8276,'','svg, map only'). -gv_attr(labeltooltip,[edge],[escString],'','','svg, cmap only'). -gv_attr(landscape,[graph],[bool],false,'',''). -gv_attr(layer,[cluster,edge,node],[layerRange],'','',''). -gv_attr(layerlistsep,[graph],[string],'","','',''). -gv_attr(layers,[graph],[layerList],'','',''). -gv_attr(layerselect,[graph],[layerRange],'','',''). -gv_attr(layersep,[graph],[string],'" :\\t"','',''). -gv_attr(layout,[graph],[string],'','',''). -gv_attr(len,[edge],[double],'1.0(neato)0.3(fdp)','','fdp, neato only'). -gv_attr(levels,[graph],[int],'MAXINT','0.0','sfdp only'). -gv_attr(levelsgap,[graph],[double],'0.0','','neato only'). -gv_attr(lhead,[edge],[string],'','','dot only'). -gv_attr(lheight,[cluster,graph],[double],'','','write only'). -gv_attr(lp,[cluster,edge,graph],[point],'','','write only'). -gv_attr(ltail,[edge],[string],'','','dot only'). -gv_attr(lwidth,[cluster,graph],[double],'','','write only'). -gv_attr(margin,[cluster,graph,node],[double,point],'','',''). -gv_attr(maxiter,[graph],[int],'100 * # nodes(mode == KK)200(mode == major)600(fdp)','','fdp, neato only'). -gv_attr(mclimit,[graph],[double],'1.0','','dot only'). -gv_attr(mindist,[graph],[double],'1.0','0.0','circo only'). -gv_attr(minlen,[edge],[int],'1','0','dot only'). -gv_attr(mode,[graph],[string],major,'','neato only'). -gv_attr(model,[graph],[string],shortpath,'','neato only'). -gv_attr(mosek,[graph],[bool],false,'','neato only'). -gv_attr(nodesep,[graph],[double],'0.25','0.02',''). -gv_attr(nojustify,[cluster,edge,graph,node],[bool],false,'',''). -gv_attr(normalize,[graph],[double,bool],false,'','not dot'). -gv_attr(notranslate,[graph],[bool],false,'','neato only'). -gv_attr(nslimitnslimit1,[graph],[double],'','','dot only'). -gv_attr(ordering,[graph,node],[string],'','','dot only'). -gv_attr(orientation,[node],[double],'0.0','360.0',''). -gv_attr(orientation,[graph],[string],'','',''). -gv_attr(outputorder,[graph],[outputMode],breadthfirst,'',''). -gv_attr(overlap,[graph],[string,bool],true,'','not dot'). -gv_attr(overlap_scaling,[graph],[double],'-4','-1.0e10','prism only'). -gv_attr(overlap_shrink,[graph],[bool],true,'','prism only'). -gv_attr(pack,[graph],[bool,int],false,'',''). -gv_attr(packmode,[graph],[packMode],node,'',''). -gv_attr(pad,[graph],[double,point],'0.0555 (4 points)','',''). -gv_attr(page,[graph],[double,point],'','',''). -gv_attr(pagedir,[graph],[pagedir],'BL','',''). -gv_attr(pencolor,[cluster],[color],black,'',''). -gv_attr(penwidth,[cluster,edge,node],[double],'1.0','0.0',''). -gv_attr(peripheries,[cluster,node],[int],'shape default(nodes)1(clusters)','0',''). -gv_attr(pin,[node],[bool],false,'','fdp, neato only'). -gv_attr(pos,[edge,node],[point,splineType],'','',''). -gv_attr(quadtree,[graph],[quadType,bool],normal,'','sfdp only'). -gv_attr(quantum,[graph],[double],'0.0','0.0',''). -gv_attr(rank,[subgraph],[rankType],'','','dot only'). -gv_attr(rankdir,[graph],[rankdir],'TB','','dot only'). -gv_attr(ranksep,[graph],[double,doubleList],'0.5(dot)1.0(twopi)','0.02','twopi, dot only'). -gv_attr(ratio,[graph],[double,string],'','',''). -gv_attr(rects,[node],[rect],'','','write only'). -gv_attr(regular,[node],[bool],false,'',''). -gv_attr(remincross,[graph],[bool],true,'','dot only'). -gv_attr(repulsiveforce,[graph],[double],'1.0','0.0','sfdp only'). -gv_attr(resolution,[graph],[double],'96.00.0','','svg, bitmap output only'). -gv_attr(root,[graph,node],[string,bool],'(graphs)false(nodes)','','circo, twopi only'). -gv_attr(rotate,[graph],[int],'0','',''). -gv_attr(rotation,[graph],[double],'0','','sfdp only'). -gv_attr(samehead,[edge],[string],'','','dot only'). -gv_attr(sametail,[edge],[string],'','','dot only'). -gv_attr(samplepoints,[node],[int],'8(output)20(overlap and image maps)','',''). -gv_attr(scale,[graph],[double,point],'','','not dot'). -gv_attr(searchsize,[graph],[int],'30','','dot only'). -gv_attr(sep,[graph],[addDouble,addPoint],'+4','','not dot'). -gv_attr(shape,[node],[shape],ellipse,'',''). -gv_attr(shapefile,[node],[string],'','',''). -gv_attr(showboxes,[edge,graph,node],[int],'0','0','dot only'). -gv_attr(sides,[node],[int],'4','0',''). -gv_attr(size,[graph],[double,point],'','',''). -gv_attr(skew,[node],[double],'0.0','-100.0',''). -gv_attr(smoothing,[graph],[smoothType],'"none"','','sfdp only'). -gv_attr(sortv,[cluster,graph,node],[int],'0','0',''). -gv_attr(splines,[graph],[bool,string],'','',''). -gv_attr(start,[graph],[startType],'','','fdp, neato only'). -gv_attr(style,[cluster,edge,graph,node],[style],'','',''). -gv_attr(stylesheet,[graph],[string],'','','svg only'). -gv_attr(tailURL,[edge],[escString],'','','svg, map only'). -gv_attr(tail_lp,[edge],[point],'','','write only'). -gv_attr(tailclip,[edge],[bool],true,'',''). -gv_attr(tailhref,[edge],[escString],'','','svg, map only'). -gv_attr(taillabel,[edge],[lblString],'','',''). -gv_attr(tailport,[edge],[portPos],center,'',''). -gv_attr(tailtarget,[edge],[escString],_G21528,'','svg, map only'). -gv_attr(tailtooltip,[edge],[escString],'','','svg, cmap only'). -gv_attr(target,[cluster,edge,graph,node],[escString,string],_G21878,'','svg, map only'). -gv_attr(tooltip,[cluster,edge,node],[escString],'','','svg, cmap only'). -gv_attr(truecolor,[graph],[bool],'','','bitmap output only'). -gv_attr(vertices,[node],[pointList],'','','write only'). -gv_attr(viewport,[graph],[viewPort],'','',''). -gv_attr(voro_margin,[graph],[double],'0.05','0.0','not dot'). -gv_attr(weight,[edge],[int,double],'1','0(dot,twopi)1(neato,fdp)',''). -gv_attr(width,[node],[double],'0.75','0.01',''). -gv_attr(xdotversion,[graph],[string],'','','xdot only'). -gv_attr(xlabel,[edge,node],[lblString],'','',''). -gv_attr(xlp,[edge,node],[point],'','','write only'). -gv_attr(z,[node],[double],'0.0','-MAXFLOAT-1000',''). diff --git a/prolog/gv/gv_attrs.pl b/prolog/gv/gv_attrs.pl deleted file mode 100644 index 4a92d5b..0000000 --- a/prolog/gv/gv_attrs.pl +++ /dev/null @@ -1,76 +0,0 @@ -:- module( - gv_attrs, - [ - gv_attr_value//2 % +Context:oneof([cluster,edge,graph,node,subgraph]) - % +Attr - ] -). -:- ensure_loaded(library('gv/gv_attrs.data')). - -/** GraphViz attributes - -@author Wouter Beek -@version 2015/07-2015/08, 2015/10, 2016/03 -*/ - -:- use_module(library(apply)). -:- use_module(library(dcg/dcg_ext)). -:- use_module(library(error)). -:- use_module(library(gv/gv_attr_type), [gv_attr_type//1]). -:- use_module(library(lists)). -:- use_module(library(os/file_ext)). - - - - - -%! gv_attr_value(+Context, +Attr)// is det. -% Uses the default value in case Value is uninstantiated. -% Otherwise, performs a typecheck and converts the given value. -% -% Context can be either `cluster`, `edge`, `graph`, `node` or `subgraph`. - -% Use the default if no value is given. -gv_attr_value(Context, Name=Value) --> - { - var(Value), - gv_attr(Name, UsedBy, _, DefaultValue, _, _), - % Check validity of context. - memberchk(Context, UsedBy) - }, !, - gv_attr_value(Context, Name=DefaultValue). -gv_attr_value(Context, Name=Value) --> - { - % Check the validity of the context argument. - gv_attr(Name, UsedBy, Types, _, Minimum, _), - memberchk(Context, UsedBy), - - % Pick a value type non-deterministically. - member(Type, Types), - - % The `style` type is the only one that requires the context argument. - ( Type == style - -> Dcg =.. [Type,Context] - ; Dcg =.. [Type] - ), - - % Check validity of Value w.r.t. minimum value -- if available. - check_minimum(Value, Minimum) - }, !, - dcg_call(gv_attr_type:Dcg, Value). -gv_attr_value(_, Name=_) --> - {existence_error(gv_attr, Name)}. - - - - - -% HELPERS % - -%! check_minimum(+Value:atom, +Minimum:number) is semidet. -% Trivially succeeds if no minimum value is available for a given attribute. - -check_minimum(_, ''):- !. -check_minimum(V, Min1):- - atom_number(Min1, Min2), - Min2 =< V. diff --git a/prolog/gv/gv_color.data b/prolog/gv/gv_color.data deleted file mode 100644 index 166b13c..0000000 --- a/prolog/gv/gv_color.data +++ /dev/null @@ -1,802 +0,0 @@ -gv_color(x11,aliceblue). -gv_color(x11,antiquewhite). -gv_color(x11,antiquewhite1). -gv_color(x11,antiquewhite2). -gv_color(x11,antiquewhite3). -gv_color(x11,antiquewhite4). -gv_color(x11,aquamarine). -gv_color(x11,aquamarine1). -gv_color(x11,aquamarine2). -gv_color(x11,aquamarine3). -gv_color(x11,aquamarine4). -gv_color(x11,azure). -gv_color(x11,azure1). -gv_color(x11,azure2). -gv_color(x11,azure3). -gv_color(x11,azure4). -gv_color(x11,beige). -gv_color(x11,bisque). -gv_color(x11,bisque1). -gv_color(x11,bisque2). -gv_color(x11,bisque3). -gv_color(x11,bisque4). -gv_color(x11,black). -gv_color(x11,blanchedalmond). -gv_color(x11,blue). -gv_color(x11,blue1). -gv_color(x11,blue2). -gv_color(x11,blue3). -gv_color(x11,blue4). -gv_color(x11,blueviolet). -gv_color(x11,brown). -gv_color(x11,brown1). -gv_color(x11,brown2). -gv_color(x11,brown3). -gv_color(x11,brown4). -gv_color(x11,burlywood). -gv_color(x11,burlywood1). -gv_color(x11,burlywood2). -gv_color(x11,burlywood3). -gv_color(x11,burlywood4). -gv_color(x11,cadetblue). -gv_color(x11,cadetblue1). -gv_color(x11,cadetblue2). -gv_color(x11,cadetblue3). -gv_color(x11,cadetblue4). -gv_color(x11,chartreuse). -gv_color(x11,chartreuse1). -gv_color(x11,chartreuse2). -gv_color(x11,chartreuse3). -gv_color(x11,chartreuse4). -gv_color(x11,chocolate). -gv_color(x11,chocolate1). -gv_color(x11,chocolate2). -gv_color(x11,chocolate3). -gv_color(x11,chocolate4). -gv_color(x11,coral). -gv_color(x11,coral1). -gv_color(x11,coral2). -gv_color(x11,coral3). -gv_color(x11,coral4). -gv_color(x11,cornflowerblue). -gv_color(x11,cornsilk). -gv_color(x11,cornsilk1). -gv_color(x11,cornsilk2). -gv_color(x11,cornsilk3). -gv_color(x11,cornsilk4). -gv_color(x11,crimson). -gv_color(x11,cyan). -gv_color(x11,cyan1). -gv_color(x11,cyan2). -gv_color(x11,cyan3). -gv_color(x11,cyan4). -gv_color(x11,darkgoldenrod). -gv_color(x11,darkgoldenrod1). -gv_color(x11,darkgoldenrod2). -gv_color(x11,darkgoldenrod3). -gv_color(x11,darkgoldenrod4). -gv_color(x11,darkgreen). -gv_color(x11,darkkhaki). -gv_color(x11,darkolivegreen). -gv_color(x11,darkolivegreen1). -gv_color(x11,darkolivegreen2). -gv_color(x11,darkolivegreen3). -gv_color(x11,darkolivegreen4). -gv_color(x11,darkorange). -gv_color(x11,darkorange1). -gv_color(x11,darkorange2). -gv_color(x11,darkorange3). -gv_color(x11,darkorange4). -gv_color(x11,darkorchid). -gv_color(x11,darkorchid1). -gv_color(x11,darkorchid2). -gv_color(x11,darkorchid3). -gv_color(x11,darkorchid4). -gv_color(x11,darksalmon). -gv_color(x11,darkseagreen). -gv_color(x11,darkseagreen1). -gv_color(x11,darkseagreen2). -gv_color(x11,darkseagreen3). -gv_color(x11,darkseagreen4). -gv_color(x11,darkslateblue). -gv_color(x11,darkslategray). -gv_color(x11,darkslategray1). -gv_color(x11,darkslategray2). -gv_color(x11,darkslategray3). -gv_color(x11,darkslategray4). -gv_color(x11,darkslategrey). -gv_color(x11,darkturquoise). -gv_color(x11,darkviolet). -gv_color(x11,deeppink). -gv_color(x11,deeppink1). -gv_color(x11,deeppink2). -gv_color(x11,deeppink3). -gv_color(x11,deeppink4). -gv_color(x11,deepskyblue). -gv_color(x11,deepskyblue1). -gv_color(x11,deepskyblue2). -gv_color(x11,deepskyblue3). -gv_color(x11,deepskyblue4). -gv_color(x11,dimgray). -gv_color(x11,dimgrey). -gv_color(x11,dodgerblue). -gv_color(x11,dodgerblue1). -gv_color(x11,dodgerblue2). -gv_color(x11,dodgerblue3). -gv_color(x11,dodgerblue4). -gv_color(x11,firebrick). -gv_color(x11,firebrick1). -gv_color(x11,firebrick2). -gv_color(x11,firebrick3). -gv_color(x11,firebrick4). -gv_color(x11,floralwhite). -gv_color(x11,forestgreen). -gv_color(x11,gainsboro). -gv_color(x11,ghostwhite). -gv_color(x11,gold). -gv_color(x11,gold1). -gv_color(x11,gold2). -gv_color(x11,gold3). -gv_color(x11,gold4). -gv_color(x11,goldenrod). -gv_color(x11,goldenrod1). -gv_color(x11,goldenrod2). -gv_color(x11,goldenrod3). -gv_color(x11,goldenrod4). -gv_color(x11,gray). -gv_color(x11,gray0). -gv_color(x11,gray1). -gv_color(x11,gray10). -gv_color(x11,gray100). -gv_color(x11,gray11). -gv_color(x11,gray12). -gv_color(x11,gray13). -gv_color(x11,gray14). -gv_color(x11,gray15). -gv_color(x11,gray16). -gv_color(x11,gray17). -gv_color(x11,gray18). -gv_color(x11,gray19). -gv_color(x11,gray2). -gv_color(x11,gray20). -gv_color(x11,gray21). -gv_color(x11,gray22). -gv_color(x11,gray23). -gv_color(x11,gray24). -gv_color(x11,gray25). -gv_color(x11,gray26). -gv_color(x11,gray27). -gv_color(x11,gray28). -gv_color(x11,gray29). -gv_color(x11,gray3). -gv_color(x11,gray30). -gv_color(x11,gray31). -gv_color(x11,gray32). -gv_color(x11,gray33). -gv_color(x11,gray34). -gv_color(x11,gray35). -gv_color(x11,gray36). -gv_color(x11,gray37). -gv_color(x11,gray38). -gv_color(x11,gray39). -gv_color(x11,gray4). -gv_color(x11,gray40). -gv_color(x11,gray41). -gv_color(x11,gray42). -gv_color(x11,gray43). -gv_color(x11,gray44). -gv_color(x11,gray45). -gv_color(x11,gray46). -gv_color(x11,gray47). -gv_color(x11,gray48). -gv_color(x11,gray49). -gv_color(x11,gray5). -gv_color(x11,gray50). -gv_color(x11,gray51). -gv_color(x11,gray52). -gv_color(x11,gray53). -gv_color(x11,gray54). -gv_color(x11,gray55). -gv_color(x11,gray56). -gv_color(x11,gray57). -gv_color(x11,gray58). -gv_color(x11,gray59). -gv_color(x11,gray6). -gv_color(x11,gray60). -gv_color(x11,gray61). -gv_color(x11,gray62). -gv_color(x11,gray63). -gv_color(x11,gray64). -gv_color(x11,gray65). -gv_color(x11,gray66). -gv_color(x11,gray67). -gv_color(x11,gray68). -gv_color(x11,gray69). -gv_color(x11,gray7). -gv_color(x11,gray70). -gv_color(x11,gray71). -gv_color(x11,gray72). -gv_color(x11,gray73). -gv_color(x11,gray74). -gv_color(x11,gray75). -gv_color(x11,gray76). -gv_color(x11,gray77). -gv_color(x11,gray78). -gv_color(x11,gray79). -gv_color(x11,gray8). -gv_color(x11,gray80). -gv_color(x11,gray81). -gv_color(x11,gray82). -gv_color(x11,gray83). -gv_color(x11,gray84). -gv_color(x11,gray85). -gv_color(x11,gray86). -gv_color(x11,gray87). -gv_color(x11,gray88). -gv_color(x11,gray89). -gv_color(x11,gray9). -gv_color(x11,gray90). -gv_color(x11,gray91). -gv_color(x11,gray92). -gv_color(x11,gray93). -gv_color(x11,gray94). -gv_color(x11,gray95). -gv_color(x11,gray96). -gv_color(x11,gray97). -gv_color(x11,gray98). -gv_color(x11,gray99). -gv_color(x11,green). -gv_color(x11,green1). -gv_color(x11,green2). -gv_color(x11,green3). -gv_color(x11,green4). -gv_color(x11,greenyellow). -gv_color(x11,grey). -gv_color(x11,grey0). -gv_color(x11,grey1). -gv_color(x11,grey10). -gv_color(x11,grey100). -gv_color(x11,grey11). -gv_color(x11,grey12). -gv_color(x11,grey13). -gv_color(x11,grey14). -gv_color(x11,grey15). -gv_color(x11,grey16). -gv_color(x11,grey17). -gv_color(x11,grey18). -gv_color(x11,grey19). -gv_color(x11,grey2). -gv_color(x11,grey20). -gv_color(x11,grey21). -gv_color(x11,grey22). -gv_color(x11,grey23). -gv_color(x11,grey24). -gv_color(x11,grey25). -gv_color(x11,grey26). -gv_color(x11,grey27). -gv_color(x11,grey28). -gv_color(x11,grey29). -gv_color(x11,grey3). -gv_color(x11,grey30). -gv_color(x11,grey31). -gv_color(x11,grey32). -gv_color(x11,grey33). -gv_color(x11,grey34). -gv_color(x11,grey35). -gv_color(x11,grey36). -gv_color(x11,grey37). -gv_color(x11,grey38). -gv_color(x11,grey39). -gv_color(x11,grey4). -gv_color(x11,grey40). -gv_color(x11,grey41). -gv_color(x11,grey42). -gv_color(x11,grey43). -gv_color(x11,grey44). -gv_color(x11,grey45). -gv_color(x11,grey46). -gv_color(x11,grey47). -gv_color(x11,grey48). -gv_color(x11,grey49). -gv_color(x11,grey5). -gv_color(x11,grey50). -gv_color(x11,grey51). -gv_color(x11,grey52). -gv_color(x11,grey53). -gv_color(x11,grey54). -gv_color(x11,grey55). -gv_color(x11,grey56). -gv_color(x11,grey57). -gv_color(x11,grey58). -gv_color(x11,grey59). -gv_color(x11,grey6). -gv_color(x11,grey60). -gv_color(x11,grey61). -gv_color(x11,grey62). -gv_color(x11,grey63). -gv_color(x11,grey64). -gv_color(x11,grey65). -gv_color(x11,grey66). -gv_color(x11,grey67). -gv_color(x11,grey68). -gv_color(x11,grey69). -gv_color(x11,grey7). -gv_color(x11,grey70). -gv_color(x11,grey71). -gv_color(x11,grey72). -gv_color(x11,grey73). -gv_color(x11,grey74). -gv_color(x11,grey75). -gv_color(x11,grey76). -gv_color(x11,grey77). -gv_color(x11,grey78). -gv_color(x11,grey79). -gv_color(x11,grey8). -gv_color(x11,grey80). -gv_color(x11,grey81). -gv_color(x11,grey82). -gv_color(x11,grey83). -gv_color(x11,grey84). -gv_color(x11,grey85). -gv_color(x11,grey86). -gv_color(x11,grey87). -gv_color(x11,grey88). -gv_color(x11,grey89). -gv_color(x11,grey9). -gv_color(x11,grey90). -gv_color(x11,grey91). -gv_color(x11,grey92). -gv_color(x11,grey93). -gv_color(x11,grey94). -gv_color(x11,grey95). -gv_color(x11,grey96). -gv_color(x11,grey97). -gv_color(x11,grey98). -gv_color(x11,grey99). -gv_color(x11,honeydew). -gv_color(x11,honeydew1). -gv_color(x11,honeydew2). -gv_color(x11,honeydew3). -gv_color(x11,honeydew4). -gv_color(x11,hotpink). -gv_color(x11,hotpink1). -gv_color(x11,hotpink2). -gv_color(x11,hotpink3). -gv_color(x11,hotpink4). -gv_color(x11,indianred). -gv_color(x11,indianred1). -gv_color(x11,indianred2). -gv_color(x11,indianred3). -gv_color(x11,indianred4). -gv_color(x11,indigo). -gv_color(x11,invis). -gv_color(x11,ivory). -gv_color(x11,ivory1). -gv_color(x11,ivory2). -gv_color(x11,ivory3). -gv_color(x11,ivory4). -gv_color(x11,khaki). -gv_color(x11,khaki1). -gv_color(x11,khaki2). -gv_color(x11,khaki3). -gv_color(x11,khaki4). -gv_color(x11,lavender). -gv_color(x11,lavenderblush). -gv_color(x11,lavenderblush1). -gv_color(x11,lavenderblush2). -gv_color(x11,lavenderblush3). -gv_color(x11,lavenderblush4). -gv_color(x11,lawngreen). -gv_color(x11,lemonchiffon). -gv_color(x11,lemonchiffon1). -gv_color(x11,lemonchiffon2). -gv_color(x11,lemonchiffon3). -gv_color(x11,lemonchiffon4). -gv_color(x11,lightblue). -gv_color(x11,lightblue1). -gv_color(x11,lightblue2). -gv_color(x11,lightblue3). -gv_color(x11,lightblue4). -gv_color(x11,lightcoral). -gv_color(x11,lightcyan). -gv_color(x11,lightcyan1). -gv_color(x11,lightcyan2). -gv_color(x11,lightcyan3). -gv_color(x11,lightcyan4). -gv_color(x11,lightgoldenrod). -gv_color(x11,lightgoldenrod1). -gv_color(x11,lightgoldenrod2). -gv_color(x11,lightgoldenrod3). -gv_color(x11,lightgoldenrod4). -gv_color(x11,lightgoldenrodyellow). -gv_color(x11,lightgray). -gv_color(x11,lightgrey). -gv_color(x11,lightpink). -gv_color(x11,lightpink1). -gv_color(x11,lightpink2). -gv_color(x11,lightpink3). -gv_color(x11,lightpink4). -gv_color(x11,lightsalmon). -gv_color(x11,lightsalmon1). -gv_color(x11,lightsalmon2). -gv_color(x11,lightsalmon3). -gv_color(x11,lightsalmon4). -gv_color(x11,lightseagreen). -gv_color(x11,lightskyblue). -gv_color(x11,lightskyblue1). -gv_color(x11,lightskyblue2). -gv_color(x11,lightskyblue3). -gv_color(x11,lightskyblue4). -gv_color(x11,lightslateblue). -gv_color(x11,lightslategray). -gv_color(x11,lightslategrey). -gv_color(x11,lightsteelblue). -gv_color(x11,lightsteelblue1). -gv_color(x11,lightsteelblue2). -gv_color(x11,lightsteelblue3). -gv_color(x11,lightsteelblue4). -gv_color(x11,lightyellow). -gv_color(x11,lightyellow1). -gv_color(x11,lightyellow2). -gv_color(x11,lightyellow3). -gv_color(x11,lightyellow4). -gv_color(x11,limegreen). -gv_color(x11,linen). -gv_color(x11,magenta). -gv_color(x11,magenta1). -gv_color(x11,magenta2). -gv_color(x11,magenta3). -gv_color(x11,magenta4). -gv_color(x11,maroon). -gv_color(x11,maroon1). -gv_color(x11,maroon2). -gv_color(x11,maroon3). -gv_color(x11,maroon4). -gv_color(x11,mediumaquamarine). -gv_color(x11,mediumblue). -gv_color(x11,mediumorchid). -gv_color(x11,mediumorchid1). -gv_color(x11,mediumorchid2). -gv_color(x11,mediumorchid3). -gv_color(x11,mediumorchid4). -gv_color(x11,mediumpurple). -gv_color(x11,mediumpurple1). -gv_color(x11,mediumpurple2). -gv_color(x11,mediumpurple3). -gv_color(x11,mediumpurple4). -gv_color(x11,mediumseagreen). -gv_color(x11,mediumslateblue). -gv_color(x11,mediumspringgreen). -gv_color(x11,mediumturquoise). -gv_color(x11,mediumvioletred). -gv_color(x11,midnightblue). -gv_color(x11,mintcream). -gv_color(x11,mistyrose). -gv_color(x11,mistyrose1). -gv_color(x11,mistyrose2). -gv_color(x11,mistyrose3). -gv_color(x11,mistyrose4). -gv_color(x11,moccasin). -gv_color(x11,navajowhite). -gv_color(x11,navajowhite1). -gv_color(x11,navajowhite2). -gv_color(x11,navajowhite3). -gv_color(x11,navajowhite4). -gv_color(x11,navy). -gv_color(x11,navyblue). -gv_color(x11,none). -gv_color(x11,oldlace). -gv_color(x11,olivedrab). -gv_color(x11,olivedrab1). -gv_color(x11,olivedrab2). -gv_color(x11,olivedrab3). -gv_color(x11,olivedrab4). -gv_color(x11,orange). -gv_color(x11,orange1). -gv_color(x11,orange2). -gv_color(x11,orange3). -gv_color(x11,orange4). -gv_color(x11,orangered). -gv_color(x11,orangered1). -gv_color(x11,orangered2). -gv_color(x11,orangered3). -gv_color(x11,orangered4). -gv_color(x11,orchid). -gv_color(x11,orchid1). -gv_color(x11,orchid2). -gv_color(x11,orchid3). -gv_color(x11,orchid4). -gv_color(x11,palegoldenrod). -gv_color(x11,palegreen). -gv_color(x11,palegreen1). -gv_color(x11,palegreen2). -gv_color(x11,palegreen3). -gv_color(x11,palegreen4). -gv_color(x11,paleturquoise). -gv_color(x11,paleturquoise1). -gv_color(x11,paleturquoise2). -gv_color(x11,paleturquoise3). -gv_color(x11,paleturquoise4). -gv_color(x11,palevioletred). -gv_color(x11,palevioletred1). -gv_color(x11,palevioletred2). -gv_color(x11,palevioletred3). -gv_color(x11,palevioletred4). -gv_color(x11,papayawhip). -gv_color(x11,peachpuff). -gv_color(x11,peachpuff1). -gv_color(x11,peachpuff2). -gv_color(x11,peachpuff3). -gv_color(x11,peachpuff4). -gv_color(x11,peru). -gv_color(x11,pink). -gv_color(x11,pink1). -gv_color(x11,pink2). -gv_color(x11,pink3). -gv_color(x11,pink4). -gv_color(x11,plum). -gv_color(x11,plum1). -gv_color(x11,plum2). -gv_color(x11,plum3). -gv_color(x11,plum4). -gv_color(x11,powderblue). -gv_color(x11,purple). -gv_color(x11,purple1). -gv_color(x11,purple2). -gv_color(x11,purple3). -gv_color(x11,purple4). -gv_color(x11,red). -gv_color(x11,red1). -gv_color(x11,red2). -gv_color(x11,red3). -gv_color(x11,red4). -gv_color(x11,rosybrown). -gv_color(x11,rosybrown1). -gv_color(x11,rosybrown2). -gv_color(x11,rosybrown3). -gv_color(x11,rosybrown4). -gv_color(x11,royalblue). -gv_color(x11,royalblue1). -gv_color(x11,royalblue2). -gv_color(x11,royalblue3). -gv_color(x11,royalblue4). -gv_color(x11,saddlebrown). -gv_color(x11,salmon). -gv_color(x11,salmon1). -gv_color(x11,salmon2). -gv_color(x11,salmon3). -gv_color(x11,salmon4). -gv_color(x11,sandybrown). -gv_color(x11,seagreen). -gv_color(x11,seagreen1). -gv_color(x11,seagreen2). -gv_color(x11,seagreen3). -gv_color(x11,seagreen4). -gv_color(x11,seashell). -gv_color(x11,seashell1). -gv_color(x11,seashell2). -gv_color(x11,seashell3). -gv_color(x11,seashell4). -gv_color(x11,sienna). -gv_color(x11,sienna1). -gv_color(x11,sienna2). -gv_color(x11,sienna3). -gv_color(x11,sienna4). -gv_color(x11,skyblue). -gv_color(x11,skyblue1). -gv_color(x11,skyblue2). -gv_color(x11,skyblue3). -gv_color(x11,skyblue4). -gv_color(x11,slateblue). -gv_color(x11,slateblue1). -gv_color(x11,slateblue2). -gv_color(x11,slateblue3). -gv_color(x11,slateblue4). -gv_color(x11,slategray). -gv_color(x11,slategray1). -gv_color(x11,slategray2). -gv_color(x11,slategray3). -gv_color(x11,slategray4). -gv_color(x11,slategrey). -gv_color(x11,snow). -gv_color(x11,snow1). -gv_color(x11,snow2). -gv_color(x11,snow3). -gv_color(x11,snow4). -gv_color(x11,springgreen). -gv_color(x11,springgreen1). -gv_color(x11,springgreen2). -gv_color(x11,springgreen3). -gv_color(x11,springgreen4). -gv_color(x11,steelblue). -gv_color(x11,steelblue1). -gv_color(x11,steelblue2). -gv_color(x11,steelblue3). -gv_color(x11,steelblue4). -gv_color(x11,tan). -gv_color(x11,tan1). -gv_color(x11,tan2). -gv_color(x11,tan3). -gv_color(x11,tan4). -gv_color(x11,thistle). -gv_color(x11,thistle1). -gv_color(x11,thistle2). -gv_color(x11,thistle3). -gv_color(x11,thistle4). -gv_color(x11,tomato). -gv_color(x11,tomato1). -gv_color(x11,tomato2). -gv_color(x11,tomato3). -gv_color(x11,tomato4). -gv_color(x11,transparent). -gv_color(x11,turquoise). -gv_color(x11,turquoise1). -gv_color(x11,turquoise2). -gv_color(x11,turquoise3). -gv_color(x11,turquoise4). -gv_color(x11,violet). -gv_color(x11,violetred). -gv_color(x11,violetred1). -gv_color(x11,violetred2). -gv_color(x11,violetred3). -gv_color(x11,violetred4). -gv_color(x11,wheat). -gv_color(x11,wheat1). -gv_color(x11,wheat2). -gv_color(x11,wheat3). -gv_color(x11,wheat4). -gv_color(x11,white). -gv_color(x11,whitesmoke). -gv_color(x11,yellow). -gv_color(x11,yellow1). -gv_color(x11,yellow2). -gv_color(x11,yellow3). -gv_color(x11,yellow4). -gv_color(x11,yellowgreen). -gv_color(svg,aliceblue). -gv_color(svg,antiquewhite). -gv_color(svg,aqua). -gv_color(svg,aquamarine). -gv_color(svg,azure). -gv_color(svg,beige). -gv_color(svg,bisque). -gv_color(svg,black). -gv_color(svg,blanchedalmond). -gv_color(svg,blue). -gv_color(svg,blueviolet). -gv_color(svg,brown). -gv_color(svg,burlywood). -gv_color(svg,cadetblue). -gv_color(svg,chartreuse). -gv_color(svg,chocolate). -gv_color(svg,coral). -gv_color(svg,cornflowerblue). -gv_color(svg,cornsilk). -gv_color(svg,crimson). -gv_color(svg,cyan). -gv_color(svg,darkblue). -gv_color(svg,darkcyan). -gv_color(svg,darkgoldenrod). -gv_color(svg,darkgray). -gv_color(svg,darkgreen). -gv_color(svg,darkgrey). -gv_color(svg,darkkhaki). -gv_color(svg,darkmagenta). -gv_color(svg,darkolivegreen). -gv_color(svg,darkorange). -gv_color(svg,darkorchid). -gv_color(svg,darkred). -gv_color(svg,darksalmon). -gv_color(svg,darkseagreen). -gv_color(svg,darkslateblue). -gv_color(svg,darkslategray). -gv_color(svg,darkslategrey). -gv_color(svg,darkturquoise). -gv_color(svg,darkviolet). -gv_color(svg,deeppink). -gv_color(svg,deepskyblue). -gv_color(svg,dimgray). -gv_color(svg,dimgrey). -gv_color(svg,dodgerblue). -gv_color(svg,firebrick). -gv_color(svg,floralwhite). -gv_color(svg,forestgreen). -gv_color(svg,fuchsia). -gv_color(svg,gainsboro). -gv_color(svg,ghostwhite). -gv_color(svg,gold). -gv_color(svg,goldenrod). -gv_color(svg,gray). -gv_color(svg,grey). -gv_color(svg,green). -gv_color(svg,greenyellow). -gv_color(svg,honeydew). -gv_color(svg,hotpink). -gv_color(svg,indianred). -gv_color(svg,indigo). -gv_color(svg,ivory). -gv_color(svg,khaki). -gv_color(svg,lavender). -gv_color(svg,lavenderblush). -gv_color(svg,lawngreen). -gv_color(svg,lemonchiffon). -gv_color(svg,lightblue). -gv_color(svg,lightcoral). -gv_color(svg,lightcyan). -gv_color(svg,lightgoldenrodyellow). -gv_color(svg,lightgray). -gv_color(svg,lightgreen). -gv_color(svg,lightgrey). -gv_color(svg,lightpink). -gv_color(svg,lightsalmon). -gv_color(svg,lightseagreen). -gv_color(svg,lightskyblue). -gv_color(svg,lightslategray). -gv_color(svg,lightslategrey). -gv_color(svg,lightsteelblue). -gv_color(svg,lightyellow). -gv_color(svg,lime). -gv_color(svg,limegreen). -gv_color(svg,linen). -gv_color(svg,magenta). -gv_color(svg,maroon). -gv_color(svg,mediumaquamarine). -gv_color(svg,mediumblue). -gv_color(svg,mediumorchid). -gv_color(svg,mediumpurple). -gv_color(svg,mediumseagreen). -gv_color(svg,mediumslateblue). -gv_color(svg,mediumspringgreen). -gv_color(svg,mediumturquoise). -gv_color(svg,mediumvioletred). -gv_color(svg,midnightblue). -gv_color(svg,mintcream). -gv_color(svg,mistyrose). -gv_color(svg,moccasin). -gv_color(svg,navajowhite). -gv_color(svg,navy). -gv_color(svg,oldlace). -gv_color(svg,olive). -gv_color(svg,olivedrab). -gv_color(svg,orange). -gv_color(svg,orangered). -gv_color(svg,orchid). -gv_color(svg,palegoldenrod). -gv_color(svg,palegreen). -gv_color(svg,paleturquoise). -gv_color(svg,palevioletred). -gv_color(svg,papayawhip). -gv_color(svg,peachpuff). -gv_color(svg,peru). -gv_color(svg,pink). -gv_color(svg,plum). -gv_color(svg,powderblue). -gv_color(svg,purple). -gv_color(svg,red). -gv_color(svg,rosybrown). -gv_color(svg,royalblue). -gv_color(svg,saddlebrown). -gv_color(svg,salmon). -gv_color(svg,sandybrown). -gv_color(svg,seagreen). -gv_color(svg,seashell). -gv_color(svg,sienna). -gv_color(svg,silver). -gv_color(svg,skyblue). -gv_color(svg,slateblue). -gv_color(svg,slategray). -gv_color(svg,slategrey). -gv_color(svg,snow). -gv_color(svg,springgreen). -gv_color(svg,steelblue). -gv_color(svg,tan). -gv_color(svg,teal). -gv_color(svg,thistle). -gv_color(svg,tomato). -gv_color(svg,turquoise). -gv_color(svg,violet). -gv_color(svg,wheat). -gv_color(svg,white). -gv_color(svg,whitesmoke). -gv_color(svg,yellow). -gv_color(svg,yellowgreen). diff --git a/prolog/gv/gv_color.pl b/prolog/gv/gv_color.pl deleted file mode 100644 index ac319dc..0000000 --- a/prolog/gv/gv_color.pl +++ /dev/null @@ -1,68 +0,0 @@ -:- module( - gv_color, - [ - gv_color/2, % ?Colorscheme:oneof([svg,x11]) - % ?Color:atom - color//1, % +Color:compound - colorList//1 % +Pairs:list(pair(compound,float)) - ] -). -:- ensure_loaded(library('gv/gv_color.data')). - -/** GraphViz color - -@author Wouter Beek -@tbd Color value `transparent` is only available in the output formats - ps, svg, fig, vmrl, and the bitmap formats. -@version 2015/08, 2015/10, 2016/02 -*/ - -:- use_module(library(apply)). -:- use_module(library(dcg/dcg_ext)). -:- use_module(library(lists)). -:- use_module(library(os/file_ext)). - - - - - -% color(+Color:compound)// . -% A *color* is represented by a compound term of one of the following forms: -% 1. `rgb(Red:nonneg,Green:nonneg,Blue:nonneg)` -% 2. `rgba(Red:nonneg,Green:nonneg,Blue:nonneg,Alpha:nonneg)` -% 3. `hsv(Hue:between(0.0,1.0),Saturation:between(0.0,1.0),Value:between(0.0,1.0))` - -color(rgb(Red,Green,Blue)) --> !, - "#", - #(3, hex_color, [Red,Green,Blue]). -color(rgbs(Red,Green,Blue,Alpha)) --> !, - color(rgb(Red,Green,Blue)), - hex_color(Alpha). -color(hsv(Hue,Saturation,Value)) --> !, - #(3, hsv_color, [Hue,Saturation,Value]). -color(Name) --> - {gv_color(_, Name)}, - atom(Name). - -hex_color(I) --> - xinteger(I). - -hsv_color(D, Head, Tail):- - format(codes(Head,Tail), '~2f', [D]). - - - -%! colorList(+Pairs:list(pair(compound,float)))// . - -colorList(L) --> - '+'(wc, L). - -wc(Color-Float) --> - color(Color), - ( wc_weight(Float) - ; "" - ). - -wc_weight(Float) --> - ";", - float(Float). diff --git a/prolog/gv/gv_dom.pl b/prolog/gv/gv_dom.pl deleted file mode 100644 index 30c4263..0000000 --- a/prolog/gv/gv_dom.pl +++ /dev/null @@ -1,29 +0,0 @@ -:- module( - gv_dom, - [ - gv_dom/3 % +ExportG, -Dom, +Opts - ] -). - -/** GraphViz DOM - -@author Wouter Beek -@version 2015/07, 2016/01 -*/ - -:- use_module(library(gv/gv_file)). -:- use_module(library(option)). -:- use_module(library(svg/svg_ext)). - - - - - -%! gv_dom(+ExportG, -Dom, +Opts) is det. - -gv_dom(ExportG, Dom, Opts1):- - % Make sure the file type of the output file is SvgDom. - merge_options([output(svg)], Opts1, Opts2), - graph_viz(ExportG, ToFile, Opts2), - svg_dom(ToFile, Dom), - delete_file(ToFile). diff --git a/prolog/gv/gv_file.pl b/prolog/gv/gv_file.pl deleted file mode 100644 index 993fcee..0000000 --- a/prolog/gv/gv_file.pl +++ /dev/null @@ -1,175 +0,0 @@ -:- module( - gv_file, - [ - graph_viz/2, % +ExportG, ?File - graph_viz/3 % +ExportG, ?File, +Opts - ] -). - -/** GraphViz file - -@author Wouter Beek -@version 2015/07, 2015/10-2015/11, 2016/01 -*/ - -:- use_module(library(code_ext)). -:- use_module(library(error)). -:- use_module(library(gv/gv_graph)). -:- use_module(library(option)). -:- use_module(library(os/external_program)). -:- use_module(library(os/process_ext)). -:- use_module(library(string_ext)). - -:- predicate_options(graph_viz/3, 3, [ - pass_to(file_to_gv/3, 3) - ]). -:- predicate_options(file_to_gv/3, 3, [ - method(+oneof([circo,dot,fdp,neato,osage,sfdp,twopi])), - output(+atom) - ]). - -:- dynamic(user:module_uses/2). -:- multifile(user:module_uses/2). - -user:module_uses(gv_file, program(dot)). - - - - - -%! graph_viz(+ExportGraph:compound, ?File:atom) is det. -%! graph_viz(+ExportGraph:compound, ?File:atom, +Options:list(compound)) is det. -% Returns a file containing a GraphViz visualization of the given graph. -% -% The following options are supported: -% * method(+oneof([circo,dot,fdp,neato,osage,sfdp,twopi]) -% The algorithm used by GraphViz for positioning the tree nodes. -% Default is `dot'. -% For possible values see gv_method/1. -% * output(+atom)` -% The file type of the generated GraphViz file. -% Default is `pdf`. -% For possible values see gv_output_type/1. - -graph_viz(ExportG, File):- - graph_viz(ExportG, File, []). -graph_viz(ExportG, File, Opts):- - once(phrase(gv_graph(ExportG), Cs)), - - % Be thread-safe. - thread_self(Id), - string_list_concat(["gv_file",Id], "_", ThreadName), - absolute_file_name(ThreadName, TmpFile, [access(write),extensions([dot])]), - setup_call_cleanup( - open(TmpFile, write, Write, [encoding(utf8)]), - with_output_to(Write, put_codes(Cs)), - close(Write) - ), - file_to_gv(TmpFile, File, Opts). - - -%! file_to_gv( -%! +InputFile:atom, -%! ?OutputFile:atom, -%! +Options:list(compound) -%! ) is det. -% Converts a GraphViz DOT file to an image file, using a specific -% visualization method. - -file_to_gv(InputFile, OutputFile, Opts):- - var(OutputFile), !, - option(output(Ext), Opts, pdf), - file_name_extension(out, Ext, LocalName), - absolute_file_name(LocalName, OutputFile, Opts), - file_to_gv(InputFile, OutputFile, Opts). -file_to_gv(InputFile, OutputFile, Opts):- - option(output(dot), Opts), !, - ( var(OutputFile) - -> OutputFile = InputFile - ; rename_file(InputFile, OutputFile) - ). -file_to_gv(InputFile, OutputFile, Opts):- - % Typecheck for `method` option. - option(method(Method), Opts, dot), - findall(Method0, gv_method(Method0), Methods), - must_be(oneof(Methods), Method), - - % Typecheck for `output` option. - option(output(OutputType), Opts, pdf), - findall(OutputType0, gv_output_type(OutputType0), OutputTypes), - must_be(oneof(OutputTypes), OutputType), - - % Run the GraphViz conversion command in the shell. - format(atom(OutputTypeFlag), "-T~a", [OutputType]), - format(atom(OutputFileFlag), "-o~a", [OutputFile]), - run_process( - Method, - [OutputTypeFlag,file(InputFile),OutputFileFlag] - ). - - - - - -% HELPERS % - -gv_method(circo). -gv_method(dot). -gv_method(fdp). -gv_method(neato). -gv_method(osage). -gv_method(sfdp). -gv_method(twopi). - - -gv_output_type(bmp). -gv_output_type(canon). -gv_output_type(dot). -gv_output_type(gv). -gv_output_type(xdot). -gv_output_type('xdot1.2'). -gv_output_type('xdot1.4'). -gv_output_type(cgimage). -gv_output_type(cmap). -gv_output_type(eps). -gv_output_type(exr). -gv_output_type(fig). -gv_output_type(gd). -gv_output_type(gd2). -gv_output_type(gif). -gv_output_type(gtk). -gv_output_type(ico). -gv_output_type(imap). -gv_output_type(cmapx). -gv_output_type(imap_np). -gv_output_type(cmapx_np). -gv_output_type(ismap). -gv_output_type(jp2). -gv_output_type(jpg). -gv_output_type(jpeg). -gv_output_type(jpe). -gv_output_type(pct). -gv_output_type(pict). -gv_output_type(pdf). -gv_output_type(pic). -gv_output_type(plain). -gv_output_type('plain-ext'). -gv_output_type(png). -gv_output_type(pov). -gv_output_type(ps). -gv_output_type(ps2). -gv_output_type(psd). -gv_output_type(sgi). -gv_output_type(svg). -gv_output_type(svgz). -gv_output_type(tga). -gv_output_type(tif). -gv_output_type(tiff). -gv_output_type(tk). -gv_output_type(vml). -gv_output_type(vmlz). -gv_output_type(vrml). -gv_output_type(wbmp). -gv_output_type(webp). -gv_output_type(xlib). -gv_output_type(x11). diff --git a/prolog/gv/gv_graph.pl b/prolog/gv/gv_graph.pl deleted file mode 100644 index c95c9cc..0000000 --- a/prolog/gv/gv_graph.pl +++ /dev/null @@ -1,252 +0,0 @@ -:- module( - gv_graph, - [ - gv_graph//1 % +Graph:compound - ] -). - -/** GraphViz graph - -Generates GraphViz graphs in the DOT format based on -a Prolog representation of a graph. - -In GraphViz vertices are called 'nodes'. - ---- - -@author Wouter Beek -@version 2015/07, 2015/12 -*/ - -:- use_module(library(apply)). -:- use_module(library(dcg/dcg_ext)). -:- use_module(library(gv/gv_graph_comp)). -:- use_module(library(lists)). -:- use_module(library(option)). - - - - - -%! gv_graph(+Graph:compound)// is det. -% Wrapper around gv_graph//2 with no indentation. - -gv_graph(G) --> gv_graph(G, 0). - - -%! gv_graph(+Graph:compound, +Indent:nonneg)// is det. -% The follow graph attributes are supported, -% beyond the GraphViz attributes for graphs: -% * `directed(+boolean)` -% Whether the graph is directed (`true`) or undirected (`false`). -% Default: `false`. -% * `name(+GraphName:atom)` -% * `strict(+StrictGraph:boolean)` -% This forbids the creation of self-arcs and multi-edges; -% they are ignored in the input file. -% Only in combinattion with directionality `directed`. -% -% ```abnf -% graph = ["strict"] ("graph" / "digraph") [ID] "{" stmt_list "}" -% ``` -% -% `GraphTerm` is a compound term of the following form: -% ```prolog -% graph(VertexTerms,RankedVertexTerms,EdgeTerms,GraphAttributes) -% ``` -% -% `RankedVertexTerms` is a list of compound terms of the following form: -% ```prolog -% RankVertex-ContentVertices -% ``` -% -% @tbd Add support for subgraphs (arbitrary nesting). -% @tbd Add support for escape strings: -% http://www.graphviz.org/doc/info/attrs.html#k:escString -% @tbd Assert attributes that are generic with respect to a subgraph. -% @tbd Not all vertex and edge properties can be shared it seems (e.g., label). - -gv_graph(G1, I) --> - { - include_ranks(G1, G2), - G2 = graph(VTerms,RankedVTerms,ETerms,GAttrs1), - shared_attributes(VTerms, SharedVAttrs, NewVTerms), - shared_attributes(ETerms, SharedEAttrs, NewETerms), - add_default(GAttrs1, overlap(false), GAttrs2), - I = 0 - }, - - % The first statement in the GraphViz output. - % States that this file represents a graph according to the GraphViz format. - tab(I), - - % Strictness. - {select_option(strict(Strict), GAttrs2, GAttrs3, false)}, - gv_strict(Strict), - - % Directedness. - {select_option(directed(Directed), GAttrs3, GAttrs4, true)}, - gv_graph_type(Directed), - " ", - - % Graph name. - ( {select_option(name(GName), GAttrs4, GAttrs5)} - -> gv_id(GName), - " " - ; {GAttrs5 = GAttrs4} - ), - - % The body of the DOT file appears between curly braces. - "{\n", - - % The following lines are indented. - {NewI is I + 1}, - - % Attributes that apply to the graph as a whole. - gv_generic_attributes_statement(graph, NewI, GAttrs5), - - % Attributes that are the same for all nodes. - gv_generic_attributes_statement(node, NewI, SharedVAttrs), - - % Attributes that are the same for all edges. - gv_generic_attributes_statement(edge, NewI, SharedEAttrs), - - % Only add a line_feed if some content was already written - % and some content is about to be written. - ( % Succeeds if no content was written. - {(GAttrs5 == [], SharedVAttrs == [], SharedEAttrs == [])} - -> "" - ; % Succeeds if no content is about to be written. - {(NewVTerms == [], RankedVTerms == [])} - -> "" - ; "\n" - ), - - % The list of GraphViz nodes. - gv_node_statements(NewI, NewVTerms), - ({NewVTerms == []} -> "" ; "\n"), - - % The ranked GraphViz nodes (displayed at the same height). - gv_ranked_node_collections(NewI, RankedVTerms), - ({RankedVTerms == []} -> "" ; "\n"), - - { - findall( - edge(FromId,ToId,[]), - ( - nth0(J1, RankedVTerms, rank(vertex(FromId,_),_)), - nth0(J2, RankedVTerms, rank(vertex(ToId,_),_)), - % We assume that the rank vertices are nicely ordered. - succ(J1, J2) - ), - RankEdges - ) - }, - - % The rank edges. - gv_edge_statements(NewI, Directed, RankEdges), - - % The non-rank edges. - gv_edge_statements(NewI, Directed, NewETerms), - - % Note that we do not include a line_feed here. - - % We want to indent the closing curly brace. - tab(I), - "}\n". - - - -%! gv_edge_statements( -%! +Indent:nonneg, -%! +Directed:boolean, -%! +Statements:list(compound) -%! )// is det. - -gv_edge_statements(I, Dir, L) --> *(gv_edge_statement(I, Dir), L). - - - -%! gv_edge_statements(+Indent:nonneg, +Statements:list(compound))// is det. - -gv_node_statements(I, L) --> *(gv_node_statement(I), L). - - - -%! gv_ranked_node_collections(+Indent:nonneg, +Collections:list)// is det. - -gv_ranked_node_collections(I, L) --> *(gv_ranked_node_collection(I), L). - - - - - -% HELPERS % - -%! add_default_option( -%! +Options:list(compound), -%! +Default:compound, -%! -NewOptions:list(compound) -%! ) is det. - -add_default(L1, Opt, L2):- - Opt =.. [N,_Value], - Opt0 =.. [N,_FreshVar], - ( option(Opt0, L1) - -> L2 = L1 - ; L2 = [Opt|L1] - ). - - - -%! gv_graph_type(+Directed:boolean)// is det. -% The type of graph that is represented. - -gv_graph_type(false) --> !, "graph". -gv_graph_type(true) --> "digraph". - - - -%! gv_strict(+Strict:boolean)// is det. -% The keyword denoting that the graph is strict, i.e., has no self-arcs and -% no multi-edges. -% This only applies to directed graphs. - -gv_strict(false) --> !, "". -gv_strict(true) --> "strict ". - - - -%! invlude_ranges(+Graph:compound, -GraphWithRanks:compound) is det. -% Ensures that there is a ranks components in -% the graph-denoting compound term. - -include_ranks(graph(Vs,Rs,Es,L), graph(Vs,Rs,Es,L)):- !. -include_ranks(graph(Vs,Es,L), graph(Vs,[],Es,L)). - - - -%! shared_attributes( -%! +Terms:list(compound), -%! -SharedAttributes:list(compound), -%! -NewTerms:list(compound) -%! ) is det. - -shared_attributes(Ts1, Shared, Ts2):- - maplist(term_to_attrs, Ts1, L1), - extract_shared(L1, Shared), - maplist(remove_shared_attributes(Shared), L1, L2), - maplist(term_change_attrs, Ts1, L2, Ts2). - -term_to_attrs(edge(_,_,A), A). -term_to_attrs(vertex(_,A), A). - -extract_shared([], []):- !. -extract_shared(Argss, Shared):- - ord_intersection(Argss, Shared). - -remove_shared_attributes(Shared, Args1, Args2):- - ord_subtract(Args1, Shared, Args2). - -term_change_attrs(edge(From,To,_), A, edge(From,To,A)). -term_change_attrs(vertex(Id,_), A, vertex(Id,A)). diff --git a/prolog/gv/gv_graph_comp.pl b/prolog/gv/gv_graph_comp.pl deleted file mode 100644 index 30ea9c5..0000000 --- a/prolog/gv/gv_graph_comp.pl +++ /dev/null @@ -1,309 +0,0 @@ -:- module( - gv_graph_comp, - [ - gv_edge_statement//3, % +Indent:nonneg - % +Directed:boolean - % +Edge:compound - gv_generic_attributes_statement//3, % +Kind:oneof([edge,graph,node]) - % +Indent:nonneg - % +CategoryAttributes:list(compound) - gv_id//1, % +Name:compound - gv_node_statement//2, % +Indent:nonneg - % +Vertex:compound - gv_ranked_node_collection//2 % +Indent:nonneg - % +Rank - ] -). - -/** GraphViz graph components - -```abnf -attr_list = "[" [a_list] "]" [attr_list] -a_list = ID "=" ID [","] [a_list] -``` - -@author Wouter Beek -@see http://www.graphviz.org/content/dot-language -@version 2015/07-2015/08, 2015/10-2016/01 -*/ - -:- use_module(library(apply)). -:- use_module(library(dcg/dcg_ext)). -:- use_module(library(gv/gv_attrs)). -:- use_module(library(gv/gv_html)). -:- use_module(library(error)). -:- use_module(library(lists)). -:- use_module(library(ordsets)). - - - - - -%! gv_edge_statement( -%! +Indent:nonneg, -%! +Directed:boolean, -%! +Edge:compound -%! )// is det. -% A GraphViz statement describing an edge. -% -% @arg Indent The indentation level at which the edge statement is written. -% @arg Directed Whether the graph is directed or not. -% @arg GraphAttributes The attributes of the graph. Some of these attributes -% may be used in the edge statement (e.g., the colorscheme). -% @arg Edge A compound term in the GIFormat, representing an edge. -% -% @tbd Instead of gv_node_id//1 we could have a gv_subgraph//1 -% at the from and/or to location. -% @tbd Add support for multiple, consecutive occurrences of gv_edge_rhs//2. - -gv_edge_statement(I, Dir, edge(From,To,Attrs)) --> - tab(I), - - gv_node_id(From), " ", - gv_edge_operator(Dir), " ", - gv_node_id(To), " ", - - % We want `colorscheme/1` from the edges and - % `directionality/1` from the graph. - gv_attrs(edge, Attrs), - "\n". - -%! gv_edge_operator(+Directed:boolean)// . -% The binary edge operator between two vertices. -% The operator that is used depends on whether the graph is directed or -% undirected. -% -% @arg Directed Whether an edge is directed (operator `->`) or -% undirected (operator `--`). - -gv_edge_operator(Dir) --> - {must_be(boolean, Dir)}, - ({Dir == false} -> "--" ; {Dir == true} -> "->"). - - - -%! gv_generic_attributes_statement( -%! +Kind:oneof([edge,graph,node]), -%! +Indent:nonneg, -%! +CategoryAttrs -%! )// -% A GraphViz statement describing generic attributes for a category of items. -% -% @arg Kind The category of items for to the attributes apply. -% Possible values: `edge`, `graph`, and `node`. -% @arg Indent An integer indicating the number of tabs. -% @arg GraphAttributes A list of name-value pairs. -% @arg CategoryAttributes A list of name-value pairs. -% -% ``` -% attr_stmt = (graph / node / edge) attr_list -% ``` - -gv_generic_attributes_statement(_, _, []) --> !, "". -gv_generic_attributes_statement(Kind, I, Attrs) --> - tab(I), - gv_kind(Kind), " ", - gv_attrs(Kind, Attrs), - "\n", !. - - - -%! gv_kind(+Kind:oneof([edge,graph,node]))// . - -gv_kind(Kind) --> {must_be(oneof([edge,graph,node]), Kind)}, atom(Kind). - - - -%! gv_node_statement(+Indent:nonneg, +Vertex:compound)// is det. -% A GraphViz statement describing a vertex (GraphViz calls vertices 'nodes'). - -gv_node_statement(I, vertex(Id,Attrs)) --> - tab(I), - gv_node_id(Id), - gv_attrs(node, Attrs), - "\n". - - - -%! gv_ranked_node_collection(+Indent:nonneg, Rank:pair)// is det. - -gv_ranked_node_collection(I, RankVTerm-VTerms) --> - tab(I), - "{\n", - - % The rank attribute. - {NewI is I + 1}, - tab(NewI), - gv_attr(subgraph, rank(same)), - "\n", - - % Vertice statements. - *(gv_node_statement(NewI), [RankVTerm|VTerms]), - - % We want to indent the closing curly brace. - tab(I), - "\n}". - - - - - -% HELPERS % - -%! gv_attrs( -%! +Kind:oneof([edge,graph,node]), -%! +Attributes:list(compound) -%! )// is det. - -gv_attrs(Kind, L) --> "[", *(gv_attr(Kind), L), "]". - - -%! gv_attr(+Context:oneof([edge,graph,node]), +Attribute:compound)// is det. -% A single GraphViz attribute. -% We assume that the attribute has already been validated. - -gv_attr(Context, Attr) --> - {Attr =.. [N,V]}, - gv_id(N), "=", gv_attr_value(Context, N=V), ";". - - - -%! gv_id(+Id:compound)// is det. -% Parse a GraphViz identifier. -% There are 4 variants: -% 1. Any string of alphabetic (`[a-zA-Z'200-'377]`) characters, -% underscores (`_`) or digits (`[0-9]`), not beginning with a digit. -% 2. A numeral `[-]?(.[0-9]+ | [0-9]+(.[0-9]*)? )`. -% 3. Any double-quoted string (`"..."`) possibly containing -% escaped quotes (`\"`). -% In quoted strings in DOT, the only escaped character is -% double-quote (`"`). That is, in quoted strings, the dyad `\"` -% is converted to `"`. All other characters are left unchanged. -% In particular, `\\` remains `\\`. -% Layout engines may apply additional escape sequences. -% Represented by a Prolog term of the form `double_quoted_string(ATOM)`. -% 4. An HTML string (`<...>`). -% Represented by a Prolog term of the form `html_like_label(COMPOUND)`. -% -% @tbd Add support for HTML-like labels: -% http://www.graphviz.org/doc/info/shapes.html#html -% This requires an XML grammar! - -% HTML strings (assumed to be the same as HTML-like labels). -gv_id(html_like_label(Content)) --> !, - gv_html_like_label(Content). -% Double-quoted strings. -% The quotes are already part of the given atom. -gv_id(double_quoted_string(Atom)) --> !, - "\"", atom(Atom), "\"". -% Numerals. -gv_id(N) --> - {number(N)}, !, - {number_codes(N, Cs)}, - Cs. -% Alpha-numeric strings. -gv_id(Atom) --> - {atom_codes(Atom, [H|T])}, - gv_id_first(H), - gv_id_rest(T), !, - % Variant 1 identifiers should not be (case-variants of) a - % GraphViz keyword. - {\+ gv_keyword([H|T])}. - - -%! gv_id_first(+First:code)// is det. -% Generates the first character of a GraphViz identifier. - -gv_id_first(C) --> alpha(C), !. -gv_id_first(0'_) --> "_". - - -%! gv_id_rest(+NonFirst:code)// is det. -% Generates a non-first character of a GraphViz identifier. - -gv_id_rest([H|T]) --> alphadigit(H), !, gv_id_rest(T). -gv_id_rest([0'_|T]) --> "_", !, gv_id_rest(T). -gv_id_rest([]) --> "". - - - -%! gv_keyword(+Codes:list(code)) is semidet. -% Succeeds if the given codes for a GraphViz reserved keyword. - -gv_keyword(Cs):- - % Obviously, the keywords do not occur on the difference list input. - % So we must use phrase/[2,3]. - phrase(gv_keyword, Cs). - - -%! gv_keyword// . -% GraphViz has reserved keywords that cannot be used as identifiers. -% GraphViz keywords are case-insensitive. - -gv_keyword --> "digraph". -gv_keyword --> "edge". -gv_keyword --> "graph". -gv_keyword --> "node". -gv_keyword --> "strict". -gv_keyword --> "subgraph". - - - -%! gv_node_id(+NodeId:compound)// . -% GraphViz node identifiers can be of the following two types: -% 1. A GraphViz identifier, see gv_id//1. -% 2. A GraphViz identifier plus a GraphViz port indicator, see gv_port//0. -% -% @tbd Add support for GraphViz port indicators -% inside GraphViz node identifiers. - -gv_node_id(Id) --> gv_id(Id), !. -%gv_node_id(_) --> gv_id(_), gv_port. -gv_node_id(Id) --> {type_error(gv_node_id, Id)}. - - - -%! gv_numeral(-Number)// is det. -% ```bnf -% ('-')? ( '.' [0-9]+ | [0-9]+ ( '.' [0-9]* )? ) -% ``` - -gv_numeral(N) --> - ("-" -> {Sg = -1} ; {Sg = 1}), - ( "." - -> {I = 0}, +(digit, Ds), {pos_frac(Ds, Frac)} - ; +(digit, Ds1), {pos_sum(Ds1, I)}, - ("." -> *(digit, Ds2), {pos_frac(Ds2, Frac)} ; {Frac = 0.0}) - ), - {N is Sg * (I + Frac)}. - - - -%! gv_port// is det. - -gv_port --> gv_port_location, (gv_port_angle ; ""). -gv_port --> gv_port_angle, (gv_port_location ; ""). -gv_port --> ":", gv_compass_pt(_). - -gv_port_angle --> "@", gv_id(_). - -gv_port_location --> ":", gv_id(_). -gv_port_location --> ":[", gv_id(_), ",", gv_id(_), "]". - - - -%! gv_compass_pt(+Direction:oneof(['_',c,e,n,ne,nw,s,se,sw,w]))// . -% ``` -% compass_pt : ( n | ne | e | se | s | sw | w | nw | c | _ ) -% ``` - -gv_compass_pt('_') --> "_". -gv_compass_pt(c) --> "c". -gv_compass_pt(e) --> "e". -gv_compass_pt(n) --> "n". -gv_compass_pt(ne) --> "ne". -gv_compass_pt(nw) --> "nw". -gv_compass_pt(s) --> "s". -gv_compass_pt(se) --> "se". -gv_compass_pt(sw) --> "sw". -gv_compass_pt(w) --> "w". diff --git a/prolog/gv/gv_html.pl b/prolog/gv/gv_html.pl deleted file mode 100644 index b5c1368..0000000 --- a/prolog/gv/gv_html.pl +++ /dev/null @@ -1,255 +0,0 @@ -:- module( - gv_html, - [ - gv_html_like_label//1 % +Content:compound - ] -). - -/** GraphViz: HTML-like labels - -Grammar taken from the GraphViz Web site: - -``` -label : text - | table -text : textitem - | text textitem -textitem : string - |
- | text - | text - | text - | text - | text - | text - | text - | text -table : [ ] rows
[
] -rows : row - | rows row - | rows
row -row: cells -cells : cell - | cells cell - | cells cell -cell: label - | -``` - ---- - -@author Wouter Beek -@see http://www.graphviz.org/content/node-shapes#html -@version 2015/07, 2015/12 -*/ - -:- use_module(library(dcg/dcg_ext)). -:- use_module(library(html/html_dcg)). - - - - - -%! gv_html_like_label(+Content:compound)// is det. - -gv_html_like_label(Content) --> "<", label(Content), ">". - - - -%! cell(+Contents:compound)// is det. -% Supported attributes for `TD`: -% - `ALIGN="CENTER|LEFT|RIGHT|TEXT"` -% - `BALIGN="CENTER|LEFT|RIGHT"` -% - `BGCOLOR="color"` -% - `BORDER="value"` -% - `CELLPADDING="value"` -% - `CELLSPACING="value"` -% - `COLOR="color"` -% - `COLSPAN="value"` -% - `FIXEDSIZE="FALSE|TRUE"` -% - `GRADIENTANGLE="value"` -% - `HEIGHT="value"` -% - `HREF="value"` -% - `ID="value"` -% - `PORT="portName"` -% - `ROWSPAN="value"` -% - `SIDES="value"` -% - `STYLE="value"` -% - `TARGET="value"` -% - `TITLE="value"` -% - `TOOLTIP="value"` -% - `VALIGN="MIDDLE|BOTTOM|TOP"` -% - `WIDTH="value"` -% -% Supported attributes for `IMG`: -% - `SCALE="FALSE|TRUE|WIDTH|HEIGHT|BOTH"` -% - `SRC="value"` - -cell(td(Contents)) --> !, - cell(td([],Contents)). -cell(td(Attrs1,Image)) --> - {(Image =.. [img,Attrs2] -> true ; Image == img -> Attrs2 = [])}, !, - html_element(td, Attrs1, html_element(img,Attrs2)). -cell(td(Attrs,Contents)) --> - html_element(td, Attrs, label(Contents)). - - - -%! cells(+Contents:list(compound))// is det. - -cells([H,vr|T]) --> !, cell(H), html_element(vr), cells(T). -cells([H|T]) --> !, cell(H), cells(T). -cells([]) --> "". - - - -%! label(+Content:compound)// is det. -% GraphViz HTML-like label. - -label(Content) --> table(Content), !. -label(Content) --> text(Content). - - - -%! row(+Contents:compound)// is det. - -row(tr(Contents)) --> html_element(tr, [], cells(Contents)). - - - -%! rows(+Contents:list)// is det. - -rows([hr|T]) --> !, html_element(hr), rows(T). -rows([H|T]) --> row(H), !, rows(T). -rows([]) --> "". - - - -%! table(+Contents:compound)// is det. -% ``` -% table : [ ] rows
[
] -% ``` -% -% Supported attributes for `TABLE`: -% - `ALIGN="CENTER|LEFT|RIGHT"` -% - `BGCOLOR="color"` -% - `BORDER="value"` -% - `CELLBORDER="value"` -% - `CELLPADDING="value"` -% - `CELLSPACING="value"` -% - `COLOR="color"` -% - `COLUMNS="value"` -% - `FIXEDSIZE="FALSE|TRUE"` -% - `GRADIENTANGLE="value"` -% - `HEIGHT="value"` -% - `HREF="value"` -% - `ID="value"` -% - `PORT="portName"` -% - `ROWS="value"` -% - `SIDES="value"` -% - `STYLE="value"` -% - `TARGET="value"` -% - `TITLE="value"` -% - `TOOLTIP="value"` -% - `VALIGN="MIDDLE|BOTTOM|TOP"` -% - `WIDTH="value"` -% -% Supported attributes for `FONT`: -% - `COLOR="color"` -% Sets the color of the font within the scope of `...`, -% or the border color of the table or cell within the scope of -% `...
`, or `...`. -% This color can be overridden by a `COLOR` attribute in descendents. -% By default, the font color is determined by the `fontcolor` attribute -% of the corresponding node, edge or graph, and the border color is -% determined by the color attribute of the corresponding node, edge or -% graph. -% - `FACE="fontname"` -% - `POINT-SIZE="value"` - -table(table(Contents)) --> !, - table(table([],Contents)). -table(table(Attrs,Contents)) --> !, - html_element(table, Attrs, rows(Contents)). -table(font(Table)) --> !, - table(font([],Table)). -table(font(Attrs1,Table)) --> - {( Table =.. [table,Attrs2,Contents] - -> true - ; Table =.. [table,Contents] - -> Attrs2 = [] - )}, - html_element(font, Attrs1, table(table(Attrs2,Contents))). - - - -%! text(+Contents:list)// . -% ``` -% text : textitem -% | text textitem -% ``` - -text(Contents) --> {is_list(Contents)}, !, '+'(textitem, Contents). -text(Content) --> text([Content]). - - - -%! textitem(+Content:compound)// . -% ``` -% textitem : string -% |
-% | text -% | text -% | text -% | text -% | text -% | text -% | text -% | text -% ``` -% -% Supported attributes for BR: -% * `ALIGN="CENTER|LEFT|RIGHT"` -% -% Supported attributes for FONT: -% * COLOR="color" -% * FACE="fontname" -% * POINT-SIZE="value" - -textitem(br(Attrs)) --> !, - html_element(br, Attrs). -% Compound term: parser. -textitem(Compound) --> - {var(Compound)}, !, - html_element(Name, _, text(Content)), - { - supported_html_element(Name), - Compound =.. [Name,Content] - }. -% Compound term: generator. -textitem(Compound) --> - { - Compound =.. [Name,Content], !, - supported_html_element(Name) - }, - html_element(Name, _, text(Content)). -textitem(String) --> - html_string(String). - - - - - -% HELPERS % - -%! supported_html_element(+Name:atom) is semidet. -%! supported_html_element(-Name:atom) is multi. - -supported_html_element(b). -supported_html_element(font). -supported_html_element(i). -supported_html_element(o). -supported_html_element(s). -supported_html_element(sub). -supported_html_element(sup). -supported_html_element(u). diff --git a/prolog/tree/tree_viz.pl b/prolog/tree/tree_viz.pl deleted file mode 100644 index 4382aa6..0000000 --- a/prolog/tree/tree_viz.pl +++ /dev/null @@ -1,65 +0,0 @@ -:- module( - tree_viz, - [ - tree_export_graph/2, % +Tree, ExportG - tree_export_graph/3, % +Tree, ExportG, +Opts - tree_viz/2, % +Tree, ?File - tree_viz/3 % +Tree, ?File, +Opts - ] -). - -/** Tree visualization - -Export trees to GraphViz. - -@author Wouter Beek -@version 2016/01-2016/02 -*/ - -:- use_module(library(graph/build_export_graph)). -:- use_module(library(gv/gv_file)). -:- use_module(library(ordsets)). -:- use_module(library(tree/l_tree)). -:- use_module(library(tree/s_tree)). - -:- predicate_options(tree_export_graph/3, 3, [ - pass_to(build_export_graph/4, 4) - ]). -:- predicate_options(tree_viz/3, 3, [ - pass_to(graph_viz/3, 3), - pass_to(tree_to_graph/3, 3) - ]). - - - - - -%! tree_export_graph(+Tree, -ExportG) is det. -%! tree_export_graph(+Tree, -ExportG, +Opts) is det. -% Opts are passed to build_export_graph/4. - -tree_export_graph(Tree, ExportG) :- - tree_export_graph(Tree, ExportG, []). - -tree_export_graph(Tree, ExportG, Opts) :- - ( is_s_tree(Tree) - -> tree_to_graph(Tree, G) - ; is_l_tree(Tree) - -> l_tree_to_graph(Tree, G) - ), - build_export_graph(G, ExportG, Opts). - - - -%! tree_viz(+Tree, ?File) is det. -%! tree_viz(+Tree, ?File, +Opts) is det. -% Stores the given tree term into a GraphViz file. -% -% Options are passed to export_graph_to_gv_file/3, tree_to_graph/3. - -tree_viz(Tree, File) :- - tree_viz(Tree, File, []). - -tree_viz(Tree, File, Opts) :- - tree_export_graph(Tree, ExportG, Opts), - graph_viz(ExportG, File, Opts). diff --git a/test/gv_attrs.log b/test/gv_attrs.log deleted file mode 100644 index a9c6010..0000000 --- a/test/gv_attrs.log +++ /dev/null @@ -1,169 +0,0 @@ -assert(gv_attr('Damping',[graph],[double],'0.99','0.0','neato only')). -assert(gv_attr('K',[cluster,graph],[double],'0.3','0','sfdp, fdp only')). -assert(gv_attr('URL',[cluster,edge,graph,node],[escString],_,'','svg, postscript, map only')). -assert(gv_attr('_background',[graph],[string],_,'','')). -assert(gv_attr(area,[cluster,node],[double],'1.0','>0','patchwork only')). -assert(gv_attr(arrowhead,[edge],[arrowType],normal,'','')). -assert(gv_attr(arrowsize,[edge],[double],'1.0','0.0','')). -assert(gv_attr(arrowtail,[edge],[arrowType],normal,'','')). -assert(gv_attr(bb,[graph],[rect],'','','write only')). -assert(gv_attr(bgcolor,[cluster,graph],[color,colorList],_,'','')). -assert(gv_attr(center,[graph],[bool],false,'','')). -assert(gv_attr(charset,[graph],[string],'"UTF-8"','','')). -assert(gv_attr(clusterrank,[graph],[clusterMode],local,'','dot only')). -assert(gv_attr(color,[cluster,edge,node],[color,colorList],black,'','')). -assert(gv_attr(colorscheme,[cluster,edge,graph,node],[string],'','','')). -assert(gv_attr(comment,[edge,graph,node],[string],'','','')). -assert(gv_attr(compound,[graph],[bool],false,'','dot only')). -assert(gv_attr(concentrate,[graph],[bool],false,'','')). -assert(gv_attr(constraint,[edge],[bool],true,'','dot only')). -assert(gv_attr(decorate,[edge],[bool],false,'','')). -assert(gv_attr(defaultdist,[graph],[double],'1+(avg. len)*sqrt(|V|)',epsilon,'neato only')). -assert(gv_attr(dim,[graph],[int],'2','2','sfdp, fdp, neato only')). -assert(gv_attr(dimen,[graph],[int],'2','2','sfdp, fdp, neato only')). -assert(gv_attr(dir,[edge],[dirType],'forward(directed)none(undirected)','','')). -assert(gv_attr(diredgeconstraints,[graph],[string,bool],false,'','neato only')). -assert(gv_attr(distortion,[node],[double],'0.0','-100.0','')). -assert(gv_attr(dpi,[graph],[double],'96.00.0','','svg, bitmap output only')). -assert(gv_attr(edgeURL,[edge],[escString],'','','svg, map only')). -assert(gv_attr(edgehref,[edge],[escString],'','','svg, map only')). -assert(gv_attr(edgetarget,[edge],[escString],_,'','svg, map only')). -assert(gv_attr(edgetooltip,[edge],[escString],'','','svg, cmap only')). -assert(gv_attr(epsilon,[graph],[double],'.0001 * # nodes(mode == KK).0001(mode == major)','','neato only')). -assert(gv_attr(esep,[graph],[addDouble,addPoint],'+3','','not dot')). -assert(gv_attr(fillcolor,[cluster,edge,node],[color,colorList],'lightgrey(nodes)black(clusters)','','')). -assert(gv_attr(fixedsize,[node],[bool,string],false,'','')). -assert(gv_attr(fontcolor,[cluster,edge,graph,node],[color],black,'','')). -assert(gv_attr(fontname,[cluster,edge,graph,node],[string],'"Times-Roman"','','')). -assert(gv_attr(fontnames,[graph],[string],'','','svg only')). -assert(gv_attr(fontpath,[graph],[string],'system-dependent','','')). -assert(gv_attr(fontsize,[cluster,edge,graph,node],[double],'14.0','1.0','')). -assert(gv_attr(forcelabels,[graph],[bool],true,'','')). -assert(gv_attr(gradientangle,[cluster,graph,node],[int],'','','')). -assert(gv_attr(group,[node],[string],'','','dot only')). -assert(gv_attr(headURL,[edge],[escString],'','','svg, map only')). -assert(gv_attr(head_lp,[edge],[point],'','','write only')). -assert(gv_attr(headclip,[edge],[bool],true,'','')). -assert(gv_attr(headhref,[edge],[escString],'','','svg, map only')). -assert(gv_attr(headlabel,[edge],[lblString],'','','')). -assert(gv_attr(headport,[edge],[portPos],center,'','')). -assert(gv_attr(headtarget,[edge],[escString],_,'','svg, map only')). -assert(gv_attr(headtooltip,[edge],[escString],'','','svg, cmap only')). -assert(gv_attr(height,[node],[double],'0.5','0.02','')). -assert(gv_attr(href,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only')). -assert(gv_attr(id,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only')). -assert(gv_attr(image,[node],[string],'','','')). -assert(gv_attr(imagepath,[graph],[string],'','','')). -assert(gv_attr(imagescale,[node],[bool,string],false,'','')). -assert(gv_attr(inputscale,[graph],[double],_,'','fdp, neato only')). -assert(gv_attr(label,[cluster,edge,graph,node],[lblString],'"\\N" (nodes)"" (otherwise)','','')). -assert(gv_attr(labelURL,[edge],[escString],'','','svg, map only')). -assert(gv_attr(label_scheme,[graph],[int],'0','0','sfdp only')). -assert(gv_attr(labelangle,[edge],[double],'-25.0','-180.0','')). -assert(gv_attr(labeldistance,[edge],[double],'1.0','0.0','')). -assert(gv_attr(labelfloat,[edge],[bool],false,'','')). -assert(gv_attr(labelfontcolor,[edge],[color],black,'','')). -assert(gv_attr(labelfontname,[edge],[string],'"Times-Roman"','','')). -assert(gv_attr(labelfontsize,[edge],[double],'14.0','1.0','')). -assert(gv_attr(labelhref,[edge],[escString],'','','svg, map only')). -assert(gv_attr(labeljust,[cluster,graph],[string],'"c"','','')). -assert(gv_attr(labelloc,[cluster,graph,node],[string],'"t"(clusters)"b"(root graphs)"c"(nodes)','','')). -assert(gv_attr(labeltarget,[edge],[escString],_,'','svg, map only')). -assert(gv_attr(labeltooltip,[edge],[escString],'','','svg, cmap only')). -assert(gv_attr(landscape,[graph],[bool],false,'','')). -assert(gv_attr(layer,[cluster,edge,node],[layerRange],'','','')). -assert(gv_attr(layerlistsep,[graph],[string],'","','','')). -assert(gv_attr(layers,[graph],[layerList],'','','')). -assert(gv_attr(layerselect,[graph],[layerRange],'','','')). -assert(gv_attr(layersep,[graph],[string],'" :\\t"','','')). -assert(gv_attr(layout,[graph],[string],'','','')). -assert(gv_attr(len,[edge],[double],'1.0(neato)0.3(fdp)','','fdp, neato only')). -assert(gv_attr(levels,[graph],[int],'MAXINT','0.0','sfdp only')). -assert(gv_attr(levelsgap,[graph],[double],'0.0','','neato only')). -assert(gv_attr(lhead,[edge],[string],'','','dot only')). -assert(gv_attr(lheight,[cluster,graph],[double],'','','write only')). -assert(gv_attr(lp,[cluster,edge,graph],[point],'','','write only')). -assert(gv_attr(ltail,[edge],[string],'','','dot only')). -assert(gv_attr(lwidth,[cluster,graph],[double],'','','write only')). -assert(gv_attr(margin,[cluster,graph,node],[double,point],'','','')). -assert(gv_attr(maxiter,[graph],[int],'100 * # nodes(mode == KK)200(mode == major)600(fdp)','','fdp, neato only')). -assert(gv_attr(mclimit,[graph],[double],'1.0','','dot only')). -assert(gv_attr(mindist,[graph],[double],'1.0','0.0','circo only')). -assert(gv_attr(minlen,[edge],[int],'1','0','dot only')). -assert(gv_attr(mode,[graph],[string],major,'','neato only')). -assert(gv_attr(model,[graph],[string],shortpath,'','neato only')). -assert(gv_attr(mosek,[graph],[bool],false,'','neato only')). -assert(gv_attr(nodesep,[graph],[double],'0.25','0.02','')). -assert(gv_attr(nojustify,[cluster,edge,graph,node],[bool],false,'','')). -assert(gv_attr(normalize,[graph],[double,bool],false,'','not dot')). -assert(gv_attr(notranslate,[graph],[bool],false,'','neato only')). -assert(gv_attr('nslimit nslimit1',[graph],[double],'','','dot only')). -assert(gv_attr(ordering,[graph,node],[string],'','','dot only')). -assert(gv_attr(orientation,[node],[double],'0.0','360.0','')). -assert(gv_attr(orientation,[graph],[string],'','','')). -assert(gv_attr(outputorder,[graph],[outputMode],breadthfirst,'','')). -assert(gv_attr(overlap,[graph],[string,bool],true,'','not dot')). -assert(gv_attr(overlap_scaling,[graph],[double],'-4','-1.0e10','prism only')). -assert(gv_attr(overlap_shrink,[graph],[bool],true,'','prism only')). -assert(gv_attr(pack,[graph],[bool,int],false,'','')). -assert(gv_attr(packmode,[graph],[packMode],node,'','')). -assert(gv_attr(pad,[graph],[double,point],'0.0555 (4 points)','','')). -assert(gv_attr(page,[graph],[double,point],'','','')). -assert(gv_attr(pagedir,[graph],[pagedir],'BL','','')). -assert(gv_attr(pencolor,[cluster],[color],black,'','')). -assert(gv_attr(penwidth,[cluster,edge,node],[double],'1.0','0.0','')). -assert(gv_attr(peripheries,[cluster,node],[int],'shape default(nodes)1(clusters)','0','')). -assert(gv_attr(pin,[node],[bool],false,'','fdp, neato only')). -assert(gv_attr(pos,[edge,node],[point,splineType],'','','')). -assert(gv_attr(quadtree,[graph],[quadType,bool],normal,'','sfdp only')). -assert(gv_attr(quantum,[graph],[double],'0.0','0.0','')). -assert(gv_attr(rank,[subgraph],[rankType],'','','dot only')). -assert(gv_attr(rankdir,[graph],[rankdir],'TB','','dot only')). -assert(gv_attr(ranksep,[graph],[double,doubleList],'0.5(dot)1.0(twopi)','0.02','twopi, dot only')). -assert(gv_attr(ratio,[graph],[double,string],'','','')). -assert(gv_attr(rects,[node],[rect],'','','write only')). -assert(gv_attr(regular,[node],[bool],false,'','')). -assert(gv_attr(remincross,[graph],[bool],true,'','dot only')). -assert(gv_attr(repulsiveforce,[graph],[double],'1.0','0.0','sfdp only')). -assert(gv_attr(resolution,[graph],[double],'96.00.0','','svg, bitmap output only')). -assert(gv_attr(root,[graph,node],[string,bool],'(graphs)false(nodes)','','circo, twopi only')). -assert(gv_attr(rotate,[graph],[int],'0','','')). -assert(gv_attr(rotation,[graph],[double],'0','','sfdp only')). -assert(gv_attr(samehead,[edge],[string],'','','dot only')). -assert(gv_attr(sametail,[edge],[string],'','','dot only')). -assert(gv_attr(samplepoints,[node],[int],'8(output)20(overlap and image maps)','','')). -assert(gv_attr(scale,[graph],[double,point],'','','not dot')). -assert(gv_attr(searchsize,[graph],[int],'30','','dot only')). -assert(gv_attr(sep,[graph],[addDouble,addPoint],'+4','','not dot')). -assert(gv_attr(shape,[node],[shape],ellipse,'','')). -assert(gv_attr(shapefile,[node],[string],'','','')). -assert(gv_attr(showboxes,[edge,graph,node],[int],'0','0','dot only')). -assert(gv_attr(sides,[node],[int],'4','0','')). -assert(gv_attr(size,[graph],[double,point],'','','')). -assert(gv_attr(skew,[node],[double],'0.0','-100.0','')). -assert(gv_attr(smoothing,[graph],[smoothType],'"none"','','sfdp only')). -assert(gv_attr(sortv,[cluster,graph,node],[int],'0','0','')). -assert(gv_attr(splines,[graph],[bool,string],'','','')). -assert(gv_attr(start,[graph],[startType],'','','fdp, neato only')). -assert(gv_attr(style,[cluster,edge,graph,node],[style],'','','')). -assert(gv_attr(stylesheet,[graph],[string],'','','svg only')). -assert(gv_attr(tailURL,[edge],[escString],'','','svg, map only')). -assert(gv_attr(tail_lp,[edge],[point],'','','write only')). -assert(gv_attr(tailclip,[edge],[bool],true,'','')). -assert(gv_attr(tailhref,[edge],[escString],'','','svg, map only')). -assert(gv_attr(taillabel,[edge],[lblString],'','','')). -assert(gv_attr(tailport,[edge],[portPos],center,'','')). -assert(gv_attr(tailtarget,[edge],[escString],_,'','svg, map only')). -assert(gv_attr(tailtooltip,[edge],[escString],'','','svg, cmap only')). -assert(gv_attr(target,[cluster,edge,graph,node],[escString,string],_,'','svg, map only')). -assert(gv_attr(tooltip,[cluster,edge,node],[escString],'','','svg, cmap only')). -assert(gv_attr(truecolor,[graph],[bool],'','','bitmap output only')). -assert(gv_attr(vertices,[node],[pointList],'','','write only')). -assert(gv_attr(viewport,[graph],[viewPort],'','','')). -assert(gv_attr(voro_margin,[graph],[double],'0.05','0.0','not dot')). -assert(gv_attr(weight,[edge],[int,double],'1','0(dot,twopi)1(neato,fdp)','')). -assert(gv_attr(width,[node],[double],'0.75','0.01','')). -assert(gv_attr(xdotversion,[graph],[string],'','','xdot only')). -assert(gv_attr(xlabel,[edge,node],[lblString],'','','')). -assert(gv_attr(xlp,[edge,node],[point],'','','write only')). -assert(gv_attr(z,[node],[double],'0.0','-MAXFLOAT-1000','')). diff --git a/test/test.pl b/test/test.pl deleted file mode 100644 index 83dc023..0000000 --- a/test/test.pl +++ /dev/null @@ -1,15 +0,0 @@ -%/fca -:- use_module(library(fca/fca_viz)). -%/graph -:- use_module(library(graph/build_export_graph)). -%/gv -:- use_module(library(gv/gv_attrs)). -:- use_module(library(gv/gv_attr_type)). -:- use_module(library(gv/gv_color)). -:- use_module(library(gv/gv_dom)). -:- use_module(library(gv/gv_file)). -:- use_module(library(gv/gv_graph)). -:- use_module(library(gv/gv_graph_comp)). -:- use_module(library(gv/gv_html)). -%/tree -:- use_module(library(tree/tree_viz)). ```

26: 正在比较变动前 76ea35d 和变动后 2a2728b

[back to content](#compare) ``` diff diff --git a/gv_dot.pl b/gv_dot.pl index 9888973..68443ba 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -76,13 +76,13 @@ gv_compass_pt(sw) --> `sw`. gv_compass_pt(w) --> `w`. -%! gv_edge_operator(+Directed:boolean)// . +%! gv_edge_operator(+Directedness:boolean)// . % The binary edge operator between two vertices. % The operator that is used depends on whether the graph is directed or % undirected. % -% @arg Directed Whether an edge is directed (operator `->`) or -% undirected (operator `--`). +% @arg Directedness Whether an edge is directed (operator `->`) or +% undirected (operator `--`). gv_edge_operator(false) --> !, `--`. gv_edge_operator(true) --> arrow(right, 2). @@ -90,14 +90,14 @@ gv_edge_operator(true) --> arrow(right, 2). %! gv_edge_statement( %! +Indent:nonneg, -%! +Directed:boolean, +%! +Directedness:boolean, %! +GraphAttributes:list(nvpair), %! +EdgeTerm:compound %! )// is det. % A GraphViz statement describing an edge. % % @arg Indent The indentation level at which the edge statement is written. -% @arg Directed Whether the graph is directed or not. +% @arg Directedness Whether the graph is directed or not. % @arg GraphAttributes The attributes of the graph. Some of these attributes % may be used in the edge statement (e.g., the colorscheme). % @arg EdgeTerm A compound term in the GIFormat, representing an edge. @@ -106,11 +106,11 @@ gv_edge_operator(true) --> arrow(right, 2). % at the from and/or to location. % @tbd Add support for multiple, consecutive occurrences of gv_edge_rhs//2. -gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> +gv_edge_statement(I, Directedness, GAttrs, edge(FromId,ToId,EAttrs)) --> indent(I), gv_node_id(FromId), ` `, - gv_edge_operator(Directed), ` `, + gv_edge_operator(Directedness), ` `, gv_node_id(ToId), ` `, @@ -148,11 +148,11 @@ gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> %! gv_graph(+GraphTerm:compound)// % The follow graph attributes are supported, % beyond the GraphViz attributes for graphs: -% 1. `directonality(+Directed:oneof([directed,undirected]))` -% A directed graph uses the keyword `digraph`. -% An undirected graph uses the keyword `graph`. -% 2. `name(+GraphName:atom)` -% 3. `strict(+StrictGraph:boolean)` +% * `directedness(+boolean)` +% Whether the graph is directed (`true`) or undirected (`false`). +% Default: `false`. +% * `name(+GraphName:atom)` +% * `strict(+StrictGraph:boolean)` % This forbids the creation of self-arcs and multi-edges; % they are ignored in the input file. % Only in combinattion with directionality `directed`. @@ -185,7 +185,7 @@ gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> shared_attributes(VTerms, SharedVAttrs, NewVTerms), shared_attributes(ETerms, SharedEAttrs, NewETerms), select_nvpair(strict=Strict, GAttrs1, GAttrs2, false), - select_nvpair(directed=Directed, GAttrs2, GAttrs3, true), + select_nvpair(directedness=Directedness, GAttrs2, GAttrs3, true), select_nvpair(name=GName, GAttrs3, GAttrs4, noname), add_default_nvpair(GAttrs4, overlap, false, GAttrs5), I = 0 @@ -195,24 +195,24 @@ gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> % States that this file represents a graph according to the GraphViz format. indent(I), gv_strict(Strict), - gv_graph_type(Directed), ` `, + gv_graph_type(Directedness), ` `, gv_id(GName), ` `, bracketed( curly, - gv_graph1( + gv_graph0( I, NewVTerms, SharedVAttrs, RankedVTerms, NewETerms, SharedEAttrs, - Directed, GAttrs5 + Directedness, GAttrs5 ) - ), + ), newline. -gv_graph1( +gv_graph0( I, NewVTerms, SharedVAttrs, RankedVTerms, NewETerms, SharedEAttrs, - Directed, GAttrs + Directedness, GAttrs ) --> newline, @@ -254,10 +254,10 @@ gv_graph1( }, % The rank edges. - '*'(gv_edge_statement(NewI, Directed, GAttrs), RankEdges), + '*'(gv_edge_statement(NewI, Directedness, GAttrs), RankEdges), % The non-rank edges. - '*'(gv_edge_statement(NewI, Directed, GAttrs), NewETerms), + '*'(gv_edge_statement(NewI, Directedness, GAttrs), NewETerms), % Note that we do not include a newline here. @@ -265,7 +265,7 @@ gv_graph1( indent(I). -%! gv_graph_type(+Directed:boolean)// . +%! gv_graph_type(+Directedness:boolean)// . % The type of graph that is represented. gv_graph_type(false) --> `graph`. diff --git a/gv_file.pl b/gv_file.pl index c780692..9eaf66b 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -1,12 +1,17 @@ :- module( gv_file, [ + file_to_gv/2, % +File:atom + % +Options:list(nvpair) + file_to_gv/3, % +FromFile:atom + % ?ToFile:atom + % +Options:list(nvpair) gif_to_gv_file/3, % +GraphInterchangeFormat:compound - % ?ToFile:atom + % +ToFile:atom + % +Options:list(nvpair) + gif_to_svg_dom/3, % +GraphInterchangeFormat:compound + % -SvgDom:list(compound) % +Options:list(nvpair) - graph_to_svg_dom/3, % +GraphInterchangeFormat:compound - % -SvgDom:list(compound) - % +Options:list(nvpair) open_dot/1 % +File:file ] ). @@ -29,13 +34,10 @@ and GraphViz output files or SVG DOM structures. :- use_module(generics(codes_ext)). :- use_module(generics(db_ext)). -:- use_module(generics(error_ext)). -:- use_module(generics(trees)). :- use_module(os(file_ext)). :- use_module(os(run_ext)). :- use_module(os(safe_file)). :- use_module(svg(svg_file)). -:- use_module(ugraph(ugraph_export)). :- use_module(plGraphViz(gv_dot)). @@ -77,77 +79,56 @@ and GraphViz output files or SVG DOM structures. :- db_add_novel(user:prolog_file_type(xdot, graphviz_output)). :- db_add_novel(user:prolog_file_type(xdot, xdot)). -:- predicate_options(graph_to_svg_dom/3, 3, [ - pass_to(gif_to_gv_file/3, 3) +:- predicate_options(codes_to_gv_file/3, 3, [ + pass_to(file_to_gv/3, 3) ]). -:- predicate_options(gif_to_gv_file/3, 3, [ - pass_to(to_gv_file/3, 3) +:- predicate_options(file_to_gv/2, 2, [ + pass_to(file_to_gv/3, 3) ]). -:- predicate_options(to_gv_file/3, 3, [ - pass_to(convert_gv/3, 3) - ]). -:- predicate_options(convert_gv/3, 3, [ +:- predicate_options(file_to_gv/3, 3, [ method(+oneof([dot,sfdp])), to_file_type(+oneof([dot,jpeg,pdf,svg,xdot])) ]). +:- predicate_options(gif_to_svg_dom/3, 3, [ + pass_to(gif_to_gv_file/3, 3) + ]). +:- predicate_options(gif_to_gv_file/3, 3, [ + pass_to(codes_to_gv_file/3, 3) + ]). -%! gif_to_gv_file(+Gif:compound, -ToFile:atom, +Options:list(nvpair)) is det. -% Returns a file containing a GraphViz visualization of the given graph. -% -% The following options are supported: -% * =|method(+Method:oneof([dot,sfdp])|= -% The algorithm used by GraphViz for positioning the tree nodes. -% Either =dot= (default) or =sfdp=. -% * =|to_file_type(+FileType:oneof([dot,jpeg,pdf,svg,xdot])|= -% The file type of the generated GraphViz file. -% Default: `pdf`. - -gif_to_gv_file(Gif, ToFile, Options):- - once(phrase(gv_graph(Gif), Codes)), - to_gv_file(Codes, ToFile, Options). - - -%! graph_to_svg_dom( -%! +GraphInterchangeFormat:compound, -%! -SvgDom:list(compound), +%! codes_to_gv_file( +%! +Codes:list(code), +%! +ToFile:atom, %! +Options:list(nvpair) %! ) is det. -graph_to_svg_dom(Gif, SvgDom, Options1):- - % Make sure the file type of the output file is SvgDom. - merge_options([to_file_type=svg], Options1, Options2), - gif_to_gv_file(Gif, ToFile, Options2), - file_to_svg(ToFile, SvgDom), - safe_delete_file(ToFile). - - -%! open_dot(+File:atom) is det. -% Opens the given DOT file. -% -% @tbd Test support on Windows. -% @tbd Test support on OS-X. - -open_dot(File):- - once(find_program_by_file_type(dot, Program)), - run_program(Program, [File]). +codes_to_gv_file(Codes, ToFile, Options):- + access_file(ToFile, write), + absolute_file_name(data(tmp), TmpFile, [access(write),file_type(dot)]), + setup_call_cleanup( + open(TmpFile, write, Write, [encoding(utf8)]), + put_codes(Write, Codes), + close(Write) + ), + file_to_gv(TmpFile, ToFile, Options), + delete_file(TmpFile). +%! file_to_gv(+FromFile:atom, +Options:list(nvpair)) is det. -% SUPPORT PREDICATES % +file_to_gv(FromFile, Options):- + file_to_gv(FromFile, _, Options). -%! convert_gv(+FromFile:atom, ?ToFile:atom, +Options:list(nvpair)) is det. +%! file_to_gv(+FromFile:atom, ?ToFile:atom, +Options:list(nvpair)) is det. % Converts a GraphViz DOT file to an image file, using a specific % visualization method. -convert_gv(FromFile, ToFile, Options):- +file_to_gv(FromFile, ToFile, Options):- option(to_file_type(dot), Options), !, rename_file(FromFile, ToFile). -convert_gv(FromFile, ToFile, Options):- - % The input file must be readable. - access_file(FromFile, read), - +file_to_gv(FromFile, ToFile, Options):- % The method option. option(method(Method), Options, dot), must_be(oneof([dot,sfdp]), Method), @@ -161,11 +142,8 @@ convert_gv(FromFile, ToFile, Options):- ( var(ToFile) -> - absolute_file_name( - data(export), - ToFile, - [access(write),file_type(ToFileType)] - ) + user:prolog_file_type(ToExtension, ToFileType), + file_alternative(FromFile, _, _, ToExtension, ToFile) ; is_absolute_file_name(ToFile), % The given output file must match a certain file extension. @@ -186,26 +164,43 @@ convert_gv(FromFile, ToFile, Options):- exit_code_handler('GraphViz', ShellStatus). -%! to_gv_file(+Codes:list(code), ?ToFile:atom, +Options:list(nvpair)) is det. +%! gif_to_gv_file(+Gif:compound, +ToFile:atom, +Options:list(nvpair)) is det. +% Returns a file containing a GraphViz visualization of the given graph. +% +% The following options are supported: +% * =|method(+Method:oneof([dot,sfdp])|= +% The algorithm used by GraphViz for positioning the tree nodes. +% Either =dot= (default) or =sfdp=. +% * =|to_file_type(+FileType:oneof([dot,jpeg,pdf,svg,xdot])|= +% The file type of the generated GraphViz file. +% Default: `pdf`. -to_gv_file(Codes, ToFile, Options):- - absolute_file_name( - data(tmp), - FromFile, - [access(write),file_type(graphviz)] - ), - setup_call_cleanup( - open(FromFile, write, Out, [encoding(utf8),type(test)]), - put_codes(Out, Codes), - close(Out) - ), - convert_gv(FromFile, ToFile, Options), +gif_to_gv_file(Gif, ToFile, Options):- + once(phrase(gv_graph(Gif), Codes)), + codes_to_gv_file(Codes, ToFile, Options). - %%%%% DEB: Store DOT file. - %%%%ignore(( - %%%% file_type_alternative(ToFile, graphviz, DOT_File), - %%%% safe_copy_file(FromFile, DOT_File) - %%%%)), - safe_delete_file(FromFile). +%! gif_to_svg_dom( +%! +GraphInterchangeFormat:compound, +%! -SvgDom:list(compound), +%! +Options:list(nvpair) +%! ) is det. + +gif_to_svg_dom(Gif, SvgDom, Options1):- + % Make sure the file type of the output file is SvgDom. + merge_options([to_file_type=svg], Options1, Options2), + gif_to_gv_file(Gif, ToFile, Options2), + file_to_svg(ToFile, SvgDom), + safe_delete_file(ToFile). + + +%! open_dot(+File:atom) is det. +% Opens the given DOT file. +% +% @tbd Test support on Windows. +% @tbd Test support on OS-X. + +open_dot(File):- + once(find_program_by_file_type(dot, Program)), + run_program(Program, [File]). ```

27: 正在比较变动前 2a2728b 和变动后 7f9fc82

[back to content](#compare) ``` diff diff --git a/gv_tree.pl b/gv_tree.pl index afeb8f6..7a181b5 100644 --- a/gv_tree.pl +++ b/gv_tree.pl @@ -30,7 +30,7 @@ Export trees to GraphViz. %! ) is det. % Stores the given tree term into a GraphViz file. % -% Options are passed on to create_gif/3 and gif_to_gv_file/3. +% Options are passed on to build_gif/3 and gif_to_gv_file/3. tree_to_gv_file(Tree, ToFile, Options):- tree_to_gif(Tree, Gif, Options), @@ -39,5 +39,5 @@ tree_to_gv_file(Tree, ToFile, Options):- tree_to_gif(H-T, Gif, Options):- tree_to_vertices_edges(Tree, Vs, Es), - create_gif(Vs, Es, Gif, Options). + build_gif(Vs, Es, Gif, Options). ```

28: 正在比较变动前 7f9fc82 和变动后 5baddb5

[back to content](#compare) ``` diff diff --git a/gv_dot.pl b/gv_dot.pl index 68443ba..4f7f341 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -76,12 +76,12 @@ gv_compass_pt(sw) --> `sw`. gv_compass_pt(w) --> `w`. -%! gv_edge_operator(+Directedness:boolean)// . +%! gv_edge_operator(+Directed:boolean)// . % The binary edge operator between two vertices. % The operator that is used depends on whether the graph is directed or % undirected. % -% @arg Directedness Whether an edge is directed (operator `->`) or +% @arg Directed Whether an edge is directed (operator `->`) or % undirected (operator `--`). gv_edge_operator(false) --> !, `--`. @@ -90,14 +90,14 @@ gv_edge_operator(true) --> arrow(right, 2). %! gv_edge_statement( %! +Indent:nonneg, -%! +Directedness:boolean, +%! +Directed:boolean, %! +GraphAttributes:list(nvpair), %! +EdgeTerm:compound %! )// is det. % A GraphViz statement describing an edge. % % @arg Indent The indentation level at which the edge statement is written. -% @arg Directedness Whether the graph is directed or not. +% @arg Directed Whether the graph is directed or not. % @arg GraphAttributes The attributes of the graph. Some of these attributes % may be used in the edge statement (e.g., the colorscheme). % @arg EdgeTerm A compound term in the GIFormat, representing an edge. @@ -106,11 +106,11 @@ gv_edge_operator(true) --> arrow(right, 2). % at the from and/or to location. % @tbd Add support for multiple, consecutive occurrences of gv_edge_rhs//2. -gv_edge_statement(I, Directedness, GAttrs, edge(FromId,ToId,EAttrs)) --> +gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> indent(I), gv_node_id(FromId), ` `, - gv_edge_operator(Directedness), ` `, + gv_edge_operator(Directed), ` `, gv_node_id(ToId), ` `, @@ -148,7 +148,7 @@ gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> %! gv_graph(+GraphTerm:compound)// % The follow graph attributes are supported, % beyond the GraphViz attributes for graphs: -% * `directedness(+boolean)` +% * `directed(+boolean)` % Whether the graph is directed (`true`) or undirected (`false`). % Default: `false`. % * `name(+GraphName:atom)` @@ -185,7 +185,7 @@ gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> shared_attributes(VTerms, SharedVAttrs, NewVTerms), shared_attributes(ETerms, SharedEAttrs, NewETerms), select_nvpair(strict=Strict, GAttrs1, GAttrs2, false), - select_nvpair(directedness=Directedness, GAttrs2, GAttrs3, true), + select_nvpair(directed=Directed, GAttrs2, GAttrs3, true), select_nvpair(name=GName, GAttrs3, GAttrs4, noname), add_default_nvpair(GAttrs4, overlap, false, GAttrs5), I = 0 @@ -195,7 +195,7 @@ gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> % States that this file represents a graph according to the GraphViz format. indent(I), gv_strict(Strict), - gv_graph_type(Directedness), ` `, + gv_graph_type(Directed), ` `, gv_id(GName), ` `, bracketed( curly, @@ -203,16 +203,16 @@ gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> I, NewVTerms, SharedVAttrs, RankedVTerms, NewETerms, SharedEAttrs, - Directedness, GAttrs5 + Directed, GAttrs5 ) - ), + ), newline. gv_graph0( I, NewVTerms, SharedVAttrs, RankedVTerms, NewETerms, SharedEAttrs, - Directedness, GAttrs + Directed, GAttrs ) --> newline, @@ -254,10 +254,10 @@ gv_graph0( }, % The rank edges. - '*'(gv_edge_statement(NewI, Directedness, GAttrs), RankEdges), + '*'(gv_edge_statement(NewI, Directed, GAttrs), RankEdges), % The non-rank edges. - '*'(gv_edge_statement(NewI, Directedness, GAttrs), NewETerms), + '*'(gv_edge_statement(NewI, Directed, GAttrs), NewETerms), % Note that we do not include a newline here. @@ -265,7 +265,7 @@ gv_graph0( indent(I). -%! gv_graph_type(+Directedness:boolean)// . +%! gv_graph_type(+Directed:boolean)// . % The type of graph that is represented. gv_graph_type(false) --> `graph`. diff --git a/gv_file.pl b/gv_file.pl index 9eaf66b..0482196 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -112,8 +112,7 @@ codes_to_gv_file(Codes, ToFile, Options):- put_codes(Write, Codes), close(Write) ), - file_to_gv(TmpFile, ToFile, Options), - delete_file(TmpFile). + file_to_gv(TmpFile, ToFile, Options). %! file_to_gv(+FromFile:atom, +Options:list(nvpair)) is det. ```

29: 正在比较变动前 5baddb5 和变动后 95bfe7f

[back to content](#compare) ``` diff diff --git a/gv_dot.pl b/gv_dot.pl index 4f7f341..35bc3f9 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -197,6 +197,8 @@ gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> gv_strict(Strict), gv_graph_type(Directed), ` `, gv_id(GName), ` `, + + % The body of the DOT file appears between curly braces. bracketed( curly, gv_graph0( @@ -228,9 +230,21 @@ gv_graph0( % Attributes that are the same for all edges. gv_generic_attributes_statement(edge, NewI, GAttrs, SharedEAttrs), - % Only add a newline if some content was written in the previous three - % lines. - ({(GAttrs == [], SharedVAttrs == [], SharedEAttrs == [])} -> `` ; newline), + % Only add a newline if some content was already written + % and some content is about to be written. + ( + { + % Succeeds if no content was written. + (GAttrs == [], SharedVAttrs == [], SharedEAttrs == []) + ; + % Succeeds if no content is about to be written. + (NewVTerms == [], RankedVTerms == []) + } + -> + `` + ; + newline + ), % The list of GraphViz nodes. '*'(gv_node_statement(NewI, GAttrs), NewVTerms), diff --git a/gv_file.pl b/gv_file.pl index 0482196..bba87f9 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -7,7 +7,7 @@ % ?ToFile:atom % +Options:list(nvpair) gif_to_gv_file/3, % +GraphInterchangeFormat:compound - % +ToFile:atom + % ?ToFile:atom % +Options:list(nvpair) gif_to_svg_dom/3, % +GraphInterchangeFormat:compound % -SvgDom:list(compound) @@ -25,7 +25,7 @@ Also converts between GraphViz DOT formatted files and GraphViz output files or SVG DOM structures. @author Wouter Beek -@version 2011-2013/09, 2013/11-2014/01, 2014/05, 2014/07 +@version 2013/09, 2013/11-2014/01, 2014/05, 2014/07-2014/08 */ :- use_module(library(option)). @@ -36,7 +36,6 @@ and GraphViz output files or SVG DOM structures. :- use_module(generics(db_ext)). :- use_module(os(file_ext)). :- use_module(os(run_ext)). -:- use_module(os(safe_file)). :- use_module(svg(svg_file)). :- use_module(plGraphViz(gv_dot)). @@ -100,12 +99,11 @@ and GraphViz output files or SVG DOM structures. %! codes_to_gv_file( %! +Codes:list(code), -%! +ToFile:atom, +%! ?ToFile:atom, %! +Options:list(nvpair) %! ) is det. codes_to_gv_file(Codes, ToFile, Options):- - access_file(ToFile, write), absolute_file_name(data(tmp), TmpFile, [access(write),file_type(dot)]), setup_call_cleanup( open(TmpFile, write, Write, [encoding(utf8)]), @@ -163,7 +161,7 @@ file_to_gv(FromFile, ToFile, Options):- exit_code_handler('GraphViz', ShellStatus). -%! gif_to_gv_file(+Gif:compound, +ToFile:atom, +Options:list(nvpair)) is det. +%! gif_to_gv_file(+Gif:compound, ?ToFile:atom, +Options:list(nvpair)) is det. % Returns a file containing a GraphViz visualization of the given graph. % % The following options are supported: @@ -190,7 +188,7 @@ gif_to_svg_dom(Gif, SvgDom, Options1):- merge_options([to_file_type=svg], Options1, Options2), gif_to_gv_file(Gif, ToFile, Options2), file_to_svg(ToFile, SvgDom), - safe_delete_file(ToFile). + delete_file(ToFile). %! open_dot(+File:atom) is det. ```

30: 正在比较变动前 95bfe7f 和变动后 f1322fa

[back to content](#compare) ``` diff diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 5b34b01..d7d21ad 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 5b34b01ab0cc82a56e6fd90fc26e75da22f5a0fe +Subproject commit d7d21ad4d6d7cec98d8b0122f5303e691998f512 diff --git a/plHtml b/plHtml index 08480c4..18e657b 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit 08480c40acaee5f70bfb21e3c641bef1e7d258bd +Subproject commit 18e657b22a84d5e98a317ddec58314964ff68bcd ```

31: 正在比较变动前 f1322fa 和变动后 474bea8

[back to content](#compare) ``` diff diff --git a/index.pl b/index.pl deleted file mode 100644 index 7461d13..0000000 --- a/index.pl +++ /dev/null @@ -1,2 +0,0 @@ -% Index of project plGraphViz (empty). - ```

32: 正在比较变动前 474bea8 和变动后 262cb2a

[back to content](#compare) ``` diff diff --git a/gv_tree.pl b/gv_tree.pl deleted file mode 100644 index 7a181b5..0000000 --- a/gv_tree.pl +++ /dev/null @@ -1,43 +0,0 @@ -:- module( - gv_tree, - [ - tree_to_gv_file/3 % +Tree:compound - % ?ToFile:atom - % +Options:list(nvpair) - ] -). - -/** GraphViz tree - -Export trees to GraphViz. - -@author Wouter Beek -@version 2014/06-2014/07 -*/ - -:- use_module(library(aggregate)). - -:- use_module(generics(trees)). - -:- use_module(plGraphViz(gv_file)). -:- use_module(plGraphViz(gv_gif)). - - -%! tree_to_gv_file( -%! +Tree:compound, -%! ?ToFile:atom, -%! +Options:list(nvpair) -%! ) is det. -% Stores the given tree term into a GraphViz file. -% -% Options are passed on to build_gif/3 and gif_to_gv_file/3. - -tree_to_gv_file(Tree, ToFile, Options):- - tree_to_gif(Tree, Gif, Options), - gif_to_gv_file(Gif, ToFile, Options). - - -tree_to_gif(H-T, Gif, Options):- - tree_to_vertices_edges(Tree, Vs, Es), - build_gif(Vs, Es, Gif, Options). - ```

33: 正在比较变动前 262cb2a 和变动后 e7e6033

[back to content](#compare) ``` diff diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 7a64c82..3c7863d 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -49,9 +49,9 @@ @version 2014/06 */ -:- use_module(dcg(dcg_abnf)). -:- use_module(dcg(dcg_cardinal)). -:- use_module(dcg(dcg_content)). +:- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_cardinal)). +:- use_module(plDcg(dcg_content)). :- use_module(plGraphViz(gv_html)). @@ -97,7 +97,7 @@ gv_attr_type(viewPort). % An *addDouble* is represented by a Prolog float. addDouble(Float) --> - '?'(`+`), + '?'(`+`, []), double(Float). @@ -106,7 +106,7 @@ addDouble(Float) --> % `point(X:float,Y:float,InputOnly:boolean)`. addPoint(Point) --> - '?'(`+`), + '?'(`+`, []), point(Point). @@ -184,7 +184,7 @@ double(Double1) --> doubleList([H|T]) --> double(H), - '*'(doubleList1, T). + '*'(doubleList1, T, []). doubleList1(Float) --> `:`, @@ -255,7 +255,7 @@ input_only(true) --> `!`. pointList(Points) --> - '*'(point, Points). + '*'(point, Points, []). % @tbd portPos diff --git a/gv_attrs.pl b/gv_attrs.pl index dd0145a..faf496c 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -17,11 +17,12 @@ :- use_module(library(persistency)). :- use_module(library(xpath)). -:- use_module(dcg(dcg_content)). -:- use_module(dcg(dcg_generic)). :- use_module(generics(db_ext)). :- use_module(os(file_ext)). +:- use_module(plDcg(dcg_content)). +:- use_module(plDcg(dcg_generic)). + :- use_module(plHtml(html)). :- use_module(plHtml(html_table)). diff --git a/gv_color.pl b/gv_color.pl index 19d6e05..14026ee 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -21,16 +21,19 @@ :- use_module(library(persistency)). :- use_module(library(xpath)). -:- use_module(dcg(dcg_abnf)). -:- use_module(dcg(dcg_cardinal)). -:- use_module(dcg(dcg_content)). :- use_module(generics(db_ext)). :- use_module(os(file_ext)). -:- use_module(sparql(sparql_char)). + +:- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_cardinal)). +:- use_module(plDcg(dcg_content)). +:- use_module(plDcg_rfc(rfc2616_basic)). :- use_module(plHtml(html)). :- use_module(plHtml(html_table)). +:- use_module(plSparql_parse(sparql_char)). + :- db_add_novel(user:prolog_file_type(log, logging)). %! gv_color(?Colorscheme:oneof([svg,x11]), ?Color:atom) is nondet. @@ -49,12 +52,12 @@ color(rgb(Red,Green,Blue)) --> !, `#`, - '#'(3, hex_color, [Red,Green,Blue]). + '#'(3, hex_color, [Red,Green,Blue], []). color(rgbs(Red,Green,Blue,Alpha)) --> !, `#`, - '#'(4, hex_color, [Red,Green,Blue,Alpha]). + '#'(4, hex_color, [Red,Green,Blue,Alpha], []). color(hsv(Hue,Saturation,Value)) --> !, - '#'(3, hsv_color, [Hue,Saturation,Value]). + '#'(3, hsv_color, [Hue,Saturation,Value], []). color(Name) --> {gv_color(_, Name)}, atom(Name). @@ -72,11 +75,11 @@ hsv_color(D, Head, Tail):- %! colorList(+Pairs:list(pair(compound,float)))// . colorList(Pairs) --> - '+'(wc, Pairs). + '+'(wc, Pairs, []). wc(Color-Float) --> color(Color), - '?'(wc_weight(Float)). + '?'(wc_weight(Float), []). wc_weight(Float) --> `;`, diff --git a/gv_dot.pl b/gv_dot.pl index 35bc3f9..accd5bd 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -22,12 +22,11 @@ In GraphViz vertices are called 'nodes'. :- use_module(library(lists)). :- use_module(library(ordsets)). -:- use_module(dcg(dcg_abnf)). -:- use_module(dcg(dcg_ascii)). -:- use_module(dcg(dcg_content)). -:- use_module(dcg(dcg_generic)). -:- use_module(dcg(dcg_meta)). -:- use_module(dcg(dcg_os)). +:- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_ascii)). +:- use_module(plDcg(dcg_content)). +:- use_module(plDcg(dcg_generic)). +:- use_module(plDcg(dcg_meta)). :- use_module(plGraphViz(gv_attrs)). :- use_module(plGraphViz(gv_html)). @@ -56,7 +55,7 @@ gv_attribute(Name=Val) --> % Attributes occur between square brackets. gv_attribute_list(Context, _, Attrs1) --> {maplist(gv_attr(Context), Attrs1, Attrs2)}, - bracketed(square, '*'(gv_attribute, Attrs2)). + bracketed(square, '*'(gv_attribute, Attrs2, [])). %! gv_compass_pt(+Direction:oneof(['_',c,e,n,ne,nw,s,se,sw,w]))// . @@ -117,7 +116,7 @@ gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> % We want `colorscheme/1` from the edges and % `directionality/1` from the graph. gv_attribute_list(edge, GAttrs, EAttrs), - newline. + line_feed. %! gv_generic_attributes_statement( @@ -142,7 +141,7 @@ gv_generic_attributes_statement(_, _, _, []) --> [], !. gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> indent(I), gv_kind(Kind), ` `, - gv_attribute_list(Kind, GraphAttrs, KindAttrs), newline. + gv_attribute_list(Kind, GraphAttrs, KindAttrs), line_feed. %! gv_graph(+GraphTerm:compound)// @@ -208,7 +207,7 @@ gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> Directed, GAttrs5 ) ), - newline. + line_feed. gv_graph0( I, @@ -216,7 +215,7 @@ gv_graph0( NewETerms, SharedEAttrs, Directed, GAttrs ) --> - newline, + line_feed, % The following lines are indented. {NewI is I + 1}, @@ -230,7 +229,7 @@ gv_graph0( % Attributes that are the same for all edges. gv_generic_attributes_statement(edge, NewI, GAttrs, SharedEAttrs), - % Only add a newline if some content was already written + % Only add a line_feed if some content was already written % and some content is about to be written. ( { @@ -243,16 +242,16 @@ gv_graph0( -> `` ; - newline + line_feed ), % The list of GraphViz nodes. - '*'(gv_node_statement(NewI, GAttrs), NewVTerms), - ({NewVTerms == []} -> `` ; newline), + '*'(gv_node_statement(NewI, GAttrs), NewVTerms, []), + ({NewVTerms == []} -> `` ; line_feed), % The ranked GraphViz nodes (displayed at the same height). - '*'(gv_ranked_node_collection(NewI, GAttrs), RankedVTerms), - ({RankedVTerms == []} -> `` ; newline), + '*'(gv_ranked_node_collection(NewI, GAttrs), RankedVTerms, []), + ({RankedVTerms == []} -> `` ; line_feed), { findall( @@ -268,12 +267,12 @@ gv_graph0( }, % The rank edges. - '*'(gv_edge_statement(NewI, Directed, GAttrs), RankEdges), + '*'(gv_edge_statement(NewI, Directed, GAttrs), RankEdges, []), % The non-rank edges. - '*'(gv_edge_statement(NewI, Directed, GAttrs), NewETerms), + '*'(gv_edge_statement(NewI, Directed, GAttrs), NewETerms, []), - % Note that we do not include a newline here. + % Note that we do not include a line_feed here. % We want to indent the closing curly brace. indent(I). @@ -394,15 +393,15 @@ gv_node_id(Id) --> gv_node_statement(I, GraphAttrs, vertex(Id,_,VAttrs)) --> indent(I), gv_node_id(Id), ` `, - gv_attribute_list(node, GraphAttrs, VAttrs), newline. + gv_attribute_list(node, GraphAttrs, VAttrs), line_feed. gv_port --> gv_port_location, - '?'(gv_port_angle). + '?'(gv_port_angle, []). gv_port --> gv_port_angle, - '?'(gv_port_location). + '?'(gv_port_location, []). gv_port --> `:`, gv_compass_pt(_). @@ -452,18 +451,22 @@ gv_ranked_node_collection( ) --> indent(I), bracketed(curly, ( - newline, + line_feed, % The rank attribute. {NewI is I + 1}, - indent(NewI), gv_attribute(rank=same), `;`, newline, - - '*'(gv_node_statement(NewI, GraphAttrs), [Rank_V_Term|Content_V_Terms]), - + indent(NewI), gv_attribute(rank=same), `;`, line_feed, + + '*'( + gv_node_statement(NewI, GraphAttrs), + [Rank_V_Term|Content_V_Terms], + [] + ), + % We want to indent the closing curly brace. indent(I) )), - newline. + line_feed. %! gv_strict(+Strict:boolean)// is det. diff --git a/gv_html.pl b/gv_html.pl index b8d3190..3f0b08b 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -11,7 +11,7 @@ @version 2013/07, 2013/09, 2014/03-2014/06 */ -:- use_module(dcg(dcg_content)). +:- use_module(plDcg(dcg_content)). :- use_module(plHtml(html_dcg)). diff --git a/gv_numeral.pl b/gv_numeral.pl index 9b82fc0..7870eb1 100644 --- a/gv_numeral.pl +++ b/gv_numeral.pl @@ -11,10 +11,11 @@ @version 2014/05-2014/06 */ -:- use_module(dcg(dcg_abnf)). -:- use_module(dcg(dcg_cardinal)). :- use_module(math(math_ext)). +:- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_cardinal)). + %! gv_numeral(?Value:number)// . @@ -48,7 +49,7 @@ gv_numeral_abs(N) --> integer(N2) ; integer(N1), - '?'((`.`, 'integer?'(N2))) + '?'((`.`, 'integer?'(N2)), []) ). gv_numeral_abs(N) --> {var(N)}, ```

34: 正在比较变动前 e7e6033 和变动后 e17bf44

[back to content](#compare) ``` diff ```

35: 正在比较变动前 e17bf44 和变动后 6596aa1

[back to content](#compare) ``` diff diff --git a/gv_file.pl b/gv_file.pl index bba87f9..c6d2933 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -30,7 +30,6 @@ and GraphViz output files or SVG DOM structures. :- use_module(library(option)). :- use_module(library(process)). -:- use_module(library(predicate_options)). % Declarations. :- use_module(generics(codes_ext)). :- use_module(generics(db_ext)). ```

36: 正在比较变动前 6596aa1 和变动后 87e8982

[back to content](#compare) ``` diff diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index d7d21ad..b1d2484 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit d7d21ad4d6d7cec98d8b0122f5303e691998f512 +Subproject commit b1d2484486ad4876aecc1bf70b2963b12efca341 diff --git a/plHtml b/plHtml index 18e657b..24fff7b 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit 18e657b22a84d5e98a317ddec58314964ff68bcd +Subproject commit 24fff7bcf90b6bc4fbf317d504be899dc1b869cb ```

37: 正在比较变动前 87e8982 和变动后 cb6aada

[back to content](#compare) ``` diff diff --git a/gv_attrs.pl b/gv_attrs.pl index faf496c..1692915 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -21,7 +21,7 @@ :- use_module(os(file_ext)). :- use_module(plDcg(dcg_content)). -:- use_module(plDcg(dcg_generic)). +:- use_module(plDcg(dcg_generics)). :- use_module(plHtml(html)). :- use_module(plHtml(html_table)). diff --git a/gv_dot.pl b/gv_dot.pl index accd5bd..5f33e5c 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -25,7 +25,7 @@ In GraphViz vertices are called 'nodes'. :- use_module(plDcg(dcg_abnf)). :- use_module(plDcg(dcg_ascii)). :- use_module(plDcg(dcg_content)). -:- use_module(plDcg(dcg_generic)). +:- use_module(plDcg(dcg_generics)). :- use_module(plDcg(dcg_meta)). :- use_module(plGraphViz(gv_attrs)). ```

38: 正在比较变动前 cb6aada 和变动后 7c8125b

[back to content](#compare) ``` diff diff --git a/gv_color.pl b/gv_color.pl index 14026ee..c5fccd4 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -13,7 +13,7 @@ @author Wouter Beek @tbd Color value `transparent` is only available in the output formats ps, svg, fig, vmrl, and the bitmap formats. -@version 2014/06 +@version 2014/06, 2014/10 */ :- use_module(library(apply)). @@ -32,8 +32,6 @@ :- use_module(plHtml(html)). :- use_module(plHtml(html_table)). -:- use_module(plSparql_parse(sparql_char)). - :- db_add_novel(user:prolog_file_type(log, logging)). %! gv_color(?Colorscheme:oneof([svg,x11]), ?Color:atom) is nondet. diff --git a/gv_file.pl b/gv_file.pl index c6d2933..5253f39 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -135,15 +135,12 @@ file_to_gv(FromFile, ToFile, Options):- prolog_file_type(ToExtension, graphviz_output), !, % The output file is either given or created. - ( - var(ToFile) - -> - user:prolog_file_type(ToExtension, ToFileType), - file_alternative(FromFile, _, _, ToExtension, ToFile) - ; - is_absolute_file_name(ToFile), - % The given output file must match a certain file extension. - file_name_extension(_, ToExtension, ToFile) + ( var(ToFile) + -> user:prolog_file_type(ToExtension, ToFileType), + file_alternative(FromFile, _, _, ToExtension, ToFile) + ; is_absolute_file_name(ToFile), + % The given output file must match a certain file extension. + file_name_extension(_, ToExtension, ToFile) ), % Now that we have the output file we can prevent the % file type / file extension translation predicates from bakctracking. @@ -152,7 +149,8 @@ file_to_gv(FromFile, ToFile, Options):- % Run the GraphViz conversion command in the shell. format(atom(OutputType), '-T~w', [ToExtension]), process_create( - path(Method), + %%%%path(Method), + 'C:\\Program Files (x86)\\Graphviz2.38\\bin\\dot.exe', [OutputType,FromFile,'-o',ToFile], [process(PID)] ), ```

39: 正在比较变动前 7c8125b 和变动后 6a38f95

[back to content](#compare) ``` diff diff --git a/gv_file.pl b/gv_file.pl index 5253f39..00c9eb0 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -149,8 +149,9 @@ file_to_gv(FromFile, ToFile, Options):- % Run the GraphViz conversion command in the shell. format(atom(OutputType), '-T~w', [ToExtension]), process_create( - %%%%path(Method), - 'C:\\Program Files (x86)\\Graphviz2.38\\bin\\dot.exe', + path(Method), + % @tbd Windows hack: + %%%%'C:\\Program Files (x86)\\Graphviz2.38\\bin\\dot.exe', [OutputType,FromFile,'-o',ToFile], [process(PID)] ), ```

40: 正在比较变动前 6a38f95 和变动后 ebb86cd

[back to content](#compare) ``` diff diff --git a/.gitignore b/.gitignore index b25c15b..7193a38 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ *~ +*# +*.db +data/* diff --git a/.gitmodules b/.gitmodules index a63cbff..844b1bd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "plHtml"] path = plHtml url = https://github.com/wouterbeek/plHtml.git +[submodule "plDcg"] + path = plDcg + url = https://github.com/wouterbeek/plDcg.git diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index b1d2484..15bbbbf 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit b1d2484486ad4876aecc1bf70b2963b12efca341 +Subproject commit 15bbbbf25471abe856afbf92a04c5b3ce76b0217 diff --git a/debug.pl b/debug.pl new file mode 100644 index 0000000..099cb84 --- /dev/null +++ b/debug.pl @@ -0,0 +1,7 @@ +% Loads debug tools for the plGraphViz library. + +:- [load]. + +:- use_module(debug_project). +:- debug_all_files. + diff --git a/debug_project.pl b/debug_project.pl new file mode 100644 index 0000000..4eb2785 --- /dev/null +++ b/debug_project.pl @@ -0,0 +1,55 @@ +:- module( + debug_project, + [ + debug_all_files/0 + ] +). + +/** Debug project + +Generic code for debugging a project: + * Load all subdirectories and Prolog files contained in those directories. + +@author Wouter Beek +@version 2014/10/31 +*/ + +:- use_module(library(ansi_term)). +:- use_module(library(apply)). + +:- use_module(os(dir_ext)). + +% Avoid errors when using gtrace/0 in threads. +:- initialization(guitracer). + + + +debug_all_files:- + absolute_file_name(project(.), Dir, [access(read),file_type(directory)]), + directory_files( + Dir, + Files1, + [ + file_types([prolog]), + include_directories(false), + include_self(false), + recursive(true) + ] + ), + exclude(do_not_load, Files1, Files2), + maplist(use_module, Files2). + +do_not_load(File1):- + file_base_name(File1, File2), + file_name_extension(File3, pl, File2), + do_not_load0(File3). + +do_not_load0(dcg_ascii). +do_not_load0(dcg_unicode). +do_not_load0(debug). +do_not_load0(debug_project). +do_not_load0(index). +do_not_load0(load). +do_not_load0(load_project). +do_not_load0(rfc2616_basic). +do_not_load0(run). diff --git a/load.pl b/load.pl index 4b117d1..1681cd0 100644 --- a/load.pl +++ b/load.pl @@ -1,12 +1,13 @@ -% Load file for plGraphViz. +% Load file for the plGraphViz library. -:- dynamic(user:prolog/3). -:- multifile(user:prolog/3). - user:project(plGraphViz, 'GraphViz support for SWI-Prolog.', plGraphViz). +:- dynamic(user:project/3). +:- multifile(user:project/3). + user:project(plGraphViz, 'GraphViz support for SWI-Prolog.'). :- use_module(load_project). -:- load_project(plGraphViz, [ +:- load_project([ plc-'Prolog-Library-Collection', + plDcg, plHtml ]). diff --git a/load_project.pl b/load_project.pl index 5599b5e..e2196b7 100644 --- a/load_project.pl +++ b/load_project.pl @@ -1,8 +1,7 @@ :- module( load_project, [ - load_project/2, % +Parent:atom - % +ChildProjects:list(or([atom,pair(atom)])) + load_project/1, % +ChildProjects:list(or([atom,pair(atom)])) load_subproject/2, % +ParentFileSearchPath:atom % +Child:or([atom,pair(atom)]) set_data_subdirectory/1 % +ParentDirectory:atom @@ -17,7 +16,7 @@ Generic code for loading a project: * Load the index of subprojects onto the file search path. @author Wouter Beek -@version 2014/06/14 +@version 2014/08/20 */ :- use_module(library(ansi_term)). % Colorized terminal messages. @@ -30,11 +29,11 @@ Generic code for loading a project: -load_project(Parent, ChildProjects):- - parent_alias(Parent, ParentFsp), +load_project(ChildProjects):- + parent_alias(ParentFsp), % Entry point. - source_file(load_project(_,_), ThisFile), + source_file(load_project(_), ThisFile), file_directory_name(ThisFile, ThisDir), assert(user:file_search_path(ParentFsp, ThisDir)), assert(user:file_search_path(project, ThisDir)), @@ -92,11 +91,12 @@ load_project_index(Fsp):- load_project_index(_). -%! parent_alias(+Parent:atom, -ParentFsp:atom) is det. +%! parent_alias(-ParentFsp:atom) is det. -parent_alias(Parent, ParentFsp):- - user:project(Parent, _, ParentFsp), !. -parent_alias(Parent, Parent). +parent_alias(ParentFsp):- + user:project(_, _, ParentFsp), !. +parent_alias(ParentFsp):- + user:project(ParentFsp, _). %! set_data_subdirectory(+ParentDirectory:atom) is det. @@ -108,6 +108,8 @@ set_data_subdirectory(ParentDir):- +% Messages + :- multifile(prolog:message//1). prolog:message(missing_subproject_directory(ChildFsp,ChildDir)) --> diff --git a/plDcg b/plDcg new file mode 160000 index 0000000..e074367 --- /dev/null +++ b/plDcg @@ -0,0 +1 @@ +Subproject commit e0743670465a92c083e6954c5cf6220222f088b6 diff --git a/plHtml b/plHtml index 24fff7b..8ef47e0 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit 24fff7bcf90b6bc4fbf317d504be899dc1b869cb +Subproject commit 8ef47e09a24c637ac435abbe1d01b21237be4534 diff --git a/run.pl b/run.pl new file mode 100644 index 0000000..8bba736 --- /dev/null +++ b/run.pl @@ -0,0 +1,9 @@ +% Standalone execution of the plGraphViz library. + +:- if(current_prolog_flag(argv, ['--debug'|_])). + :- ensure_loaded(debug). +:- else. + :- set_prolog_flag(verbose, silent). + :- ensure_loaded(load). +:- endif. + ```

41: 正在比较变动前 ebb86cd 和变动后 1549e44

[back to content](#compare) ``` diff diff --git a/gv_dot.pl b/gv_dot.pl index 5f33e5c..bde2962 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -1,7 +1,7 @@ :- module( gv_dot, [ - gv_graph//1 % +GraphTerm:compound + gv_graph//1 % +Gif:compound ] ). @@ -39,7 +39,7 @@ In GraphViz vertices are called 'nodes'. % We assume that the attribute has already been validated. gv_attribute(Name=Val) --> - gv_id(Name), `=`, gv_id(Val), `;`. + gv_id(Name), "=", gv_id(Val), ";". %! gv_attribute_list( @@ -63,16 +63,16 @@ gv_attribute_list(Context, _, Attrs1) --> % compass_pt : (n | ne | e | se | s | sw | w | nw | c | _) % ~~~ -gv_compass_pt('_') --> `_`. -gv_compass_pt(c) --> `c`. -gv_compass_pt(e) --> `e`. -gv_compass_pt(n) --> `n`. -gv_compass_pt(ne) --> `ne`. -gv_compass_pt(nw) --> `nw`. -gv_compass_pt(s) --> `s`. -gv_compass_pt(se) --> `se`. -gv_compass_pt(sw) --> `sw`. -gv_compass_pt(w) --> `w`. +gv_compass_pt('_') --> "_". +gv_compass_pt(c) --> "c". +gv_compass_pt(e) --> "e". +gv_compass_pt(n) --> "n". +gv_compass_pt(ne) --> "ne". +gv_compass_pt(nw) --> "nw". +gv_compass_pt(s) --> "s". +gv_compass_pt(se) --> "se". +gv_compass_pt(sw) --> "sw". +gv_compass_pt(w) --> "w". %! gv_edge_operator(+Directed:boolean)// . @@ -83,7 +83,7 @@ gv_compass_pt(w) --> `w`. % @arg Directed Whether an edge is directed (operator `->`) or % undirected (operator `--`). -gv_edge_operator(false) --> !, `--`. +gv_edge_operator(false) --> !, "--". gv_edge_operator(true) --> arrow(right, 2). @@ -107,11 +107,11 @@ gv_edge_operator(true) --> arrow(right, 2). gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> indent(I), - gv_node_id(FromId), ` `, + gv_node_id(FromId), " ", - gv_edge_operator(Directed), ` `, + gv_edge_operator(Directed), " ", - gv_node_id(ToId), ` `, + gv_node_id(ToId), " ", % We want `colorscheme/1` from the edges and % `directionality/1` from the graph. @@ -140,11 +140,11 @@ gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> gv_generic_attributes_statement(_, _, _, []) --> [], !. gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> indent(I), - gv_kind(Kind), ` `, + gv_kind(Kind), " ", gv_attribute_list(Kind, GraphAttrs, KindAttrs), line_feed. -%! gv_graph(+GraphTerm:compound)// +%! gv_graph(+Gif:compound)// % The follow graph attributes are supported, % beyond the GraphViz attributes for graphs: % * `directed(+boolean)` @@ -176,10 +176,10 @@ gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> % @tbd Assert attributes that are generic with respect to a subgraph. % @tbd Not all vertex and edge properties can be shared it seems (e.g., label). -gv_graph(graph(VTerms, ETerms, GAttrs)) --> - gv_graph(graph(VTerms, [], ETerms, GAttrs)). +gv_graph(graph(VTerms,ETerms,GAttrs)) --> + gv_graph(graph(VTerms,[],ETerms,GAttrs)). -gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> +gv_graph(graph(VTerms,RankedVTerms,ETerms,GAttrs1)) --> { shared_attributes(VTerms, SharedVAttrs, NewVTerms), shared_attributes(ETerms, SharedEAttrs, NewETerms), @@ -194,8 +194,8 @@ gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> % States that this file represents a graph according to the GraphViz format. indent(I), gv_strict(Strict), - gv_graph_type(Directed), ` `, - gv_id(GName), ` `, + gv_graph_type(Directed), " ", + gv_id(GName), " ", % The body of the DOT file appears between curly braces. bracketed( @@ -240,18 +240,18 @@ gv_graph0( (NewVTerms == [], RankedVTerms == []) } -> - `` + "" ; line_feed ), % The list of GraphViz nodes. '*'(gv_node_statement(NewI, GAttrs), NewVTerms, []), - ({NewVTerms == []} -> `` ; line_feed), + ({NewVTerms == []} -> "" ; line_feed), % The ranked GraphViz nodes (displayed at the same height). '*'(gv_ranked_node_collection(NewI, GAttrs), RankedVTerms, []), - ({RankedVTerms == []} -> `` ; line_feed), + ({RankedVTerms == []} -> "" ; line_feed), { findall( @@ -281,8 +281,8 @@ gv_graph0( %! gv_graph_type(+Directed:boolean)// . % The type of graph that is represented. -gv_graph_type(false) --> `graph`. -gv_graph_type(true) --> `digraph`. +gv_graph_type(false) --> "graph". +gv_graph_type(true) --> "digraph". %! gv_id(?Atom:atom)// is det. @@ -305,8 +305,9 @@ gv_graph_type(true) --> `digraph`. % This requires an XML grammar! % HTML strings (variant 4). -gv_id(Atom) --> - dcg_atom_codes(gv_html_like_label, Atom), !. +gv_id(Content) --> + {compound(Content)}, !, + gv_html_like_label, Content). % Alpha-numeric strings (variant 1). gv_id(Atom) --> {atom_codes(Atom, [H|T])}, @@ -353,19 +354,19 @@ gv_keyword(Codes):- % GraphViz has reserved keywords that cannot be used as identifiers. % GraphViz keywords are case-insensitive. -gv_keyword --> `digraph`. -gv_keyword --> `edge`. -gv_keyword --> `graph`. -gv_keyword --> `node`. -gv_keyword --> `strict`. -gv_keyword --> `subgraph`. +gv_keyword --> "digraph". +gv_keyword --> "edge". +gv_keyword --> "graph". +gv_keyword --> "node". +gv_keyword --> "strict". +gv_keyword --> "subgraph". %! gv_kind(+Kind:oneof([edge,graph,node]))// . -gv_kind(edge) --> `edge`. -gv_kind(graph) --> `graph`. -gv_kind(node) --> `node`. +gv_kind(edge) --> "edge". +gv_kind(graph) --> "graph". +gv_kind(node) --> "node". %! gv_node_id(+NodeId:atom)// . @@ -392,7 +393,7 @@ gv_node_id(Id) --> gv_node_statement(I, GraphAttrs, vertex(Id,_,VAttrs)) --> indent(I), - gv_node_id(Id), ` `, + gv_node_id(Id), " ", gv_attribute_list(node, GraphAttrs, VAttrs), line_feed. @@ -403,23 +404,23 @@ gv_port --> gv_port_angle, '?'(gv_port_location, []). gv_port --> - `:`, + ":", gv_compass_pt(_). gv_port_angle --> - `@`, + "@", gv_id(_). gv_port_location --> - `:`, + ":", gv_id(_). gv_port_location --> - `:`, + ":", bracketed( round, ( gv_id(_), - `,`, + ",", gv_id(_) ) ). @@ -436,7 +437,7 @@ gv_quoted_string([92,34|T]) --> !, gv_quoted_string(T). % Add the backslash escape character. gv_quoted_string([34|T]) --> !, - `\\\"`, + "\\\"", gv_quoted_string(T). % All other characters are allowed without escaping. gv_quoted_string([H|T]) --> @@ -455,7 +456,7 @@ gv_ranked_node_collection( % The rank attribute. {NewI is I + 1}, - indent(NewI), gv_attribute(rank=same), `;`, line_feed, + indent(NewI), gv_attribute(rank=same), ";", line_feed, '*'( gv_node_statement(NewI, GraphAttrs), @@ -475,7 +476,7 @@ gv_ranked_node_collection( % This only applies to directed graphs. gv_strict(false) --> []. -gv_strict(true) --> `strict `. +gv_strict(true) --> "strict ". diff --git a/gv_html.pl b/gv_html.pl index 3f0b08b..a308ac7 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -1,60 +1,223 @@ :- module( gv_html, [ - gv_html_like_label//1 % +Codes:list(code) + gv_html_like_label//1 % +Content:compound ] ). -/** GraphViz HTML +/** GraphViz: HTML-like labels + +Grammar taken from the GraphViz Web site: + +~~~{.txt} +label : text + | table +text : textitem + | text textitem +textitem : string + |
+ | text + | text + | text + | text + | text + | text + | text + | text +table : [ ] rows
[
] +rows : row + | rows row + | rows
row +row : cells +cells : cell + | cells cell + | cells cell +cell : label + | +~~~ @author Wouter Beek -@version 2013/07, 2013/09, 2014/03-2014/06 +@see http://www.graphviz.org/content/node-shapes#html +@version 2013/07, 2013/09, 2014/03-2014/06, 2014/11 */ +:- use_module(plDcg(dcg_abnf)). :- use_module(plDcg(dcg_content)). :- use_module(plHtml(html_dcg)). -%! gv_html_label(+Codes:list(code))// . +%! gv_html_like_label(?Content:compound)// . + +gv_html_like_label(Content) --> + bracketed(angular, label(Content)). + + +%! cell(?Contents:compound)// . +% Supported attributes for TD: +% ~~~{.txt} +% ALIGN="CENTER|LEFT|RIGHT|TEXT" +% BALIGN="CENTER|LEFT|RIGHT" +% BGCOLOR="color" +% BORDER="value" +% CELLPADDING="value" +% CELLSPACING="value" +% COLOR="color" +% COLSPAN="value" +% FIXEDSIZE="FALSE|TRUE" +% GRADIENTANGLE="value" +% HEIGHT="value" +% HREF="value" +% ID="value" +% PORT="portName" +% ROWSPAN="value" +% SIDES="value" +% STYLE="value" +% TARGET="value" +% TITLE="value" +% TOOLTIP="value" +% VALIGN="MIDDLE|BOTTOM|TOP" +% WIDTH="value" +% ~~~ % -% @see http://www.graphviz.org/doc/info/shapes.html#html - -gv_html_label --> gv_html_text, !. -gv_html_label --> gv_html_table, !. -gv_html_label --> []. - -gv_html_like_label --> bracketed(angular, gv_html_label). - -gv_html_like_label(Content) --> bracketed(angular, html_dcg(Content)). - -gv_html_table --> html_element(table, _, gv_html_rows). -gv_html_table --> html_element(font, _, html_element(table, _, gv_html_rows)). - -gv_html_rows --> gv_html_row, gv_html_rows. -gv_html_rows --> gv_html_row, html_element(hr, _), gv_html_rows. -gv_html_rows --> gv_html_row. - -gv_html_row --> html_element(tr, _, gv_html_cells). - -gv_html_cell --> html_element(td, _, gv_html_label). -gv_html_cell --> html_element(td, _, html_element(img, _)). - -gv_html_cells --> gv_html_cell, gv_html_cells. -gv_html_cells --> gv_html_cell. -gv_html_cells --> gv_html_cell, html_element(vr, _), gv_html_cells. - -gv_html_text --> gv_html_textitem, gv_html_text. -gv_html_text --> gv_html_textitem. - -gv_html_textitem --> html_string, !. -gv_html_textitem --> html_entity, !. -gv_html_textitem --> html_element(br, _), !. -gv_html_textitem --> html_element(font, _, gv_html_text), !. -gv_html_textitem --> html_element(i, _, gv_html_text), !. -gv_html_textitem --> html_element(b, _, gv_html_text), !. -gv_html_textitem --> html_element(u, _, gv_html_text), !. -gv_html_textitem --> html_element(sub, _, gv_html_text), !. -gv_html_textitem --> html_element(sup, _, gv_html_text), !. - +% Supported attributes for IMG: +% ~~~{.txt} +% SCALE="FALSE|TRUE|WIDTH|HEIGHT|BOTH" +% SRC="value" +% ~~~ + +cell(td(Contents)) --> + html_element(td, [], label(Contents)). +cell(td(img)) --> + html_element(td, [], html_element(img)). + + +%! cells(?Contents:list(compound))// . + +cells([H|T]) --> + cell(H), + cells(T). +cells([H,vr|T]) --> + cell(H), + html_element(vr), + cells(T). +cells([H]) --> + cell(H). + + +%! label(?Content:compound)// . +% GraphViz HTML-like label. + +label(Content) --> + text(Content). +label(Content) --> + table(Content). + + +%! row(?Contents:compound)// . + +row(tr(Contents)) --> + html_element(tr, [], cell(Contents)). + + +%! rows(?Contents:list)// . + +rows([H|T]) --> + row(H), + rows. +rows([H,hr|T]) --> + row(H), + html_element(hr), + rows(T). +rows([H]) --> + row(H). + + +%! table(?Contents:compound)// . +% Supported attributes for TABLE: +% ~~~{.txt} +% ALIGN="CENTER|LEFT|RIGHT" +% BGCOLOR="color" +% BORDER="value" +% CELLBORDER="value" +% CELLPADDING="value" +% CELLSPACING="value" +% COLOR="color" +% COLUMNS="value" +% FIXEDSIZE="FALSE|TRUE" +% GRADIENTANGLE="value" +% HEIGHT="value" +% HREF="value" +% ID="value" +% PORT="portName" +% ROWS="value" +% SIDES="value" +% STYLE="value" +% TARGET="value" +% TITLE="value" +% TOOLTIP="value" +% VALIGN="MIDDLE|BOTTOM|TOP" +% WIDTH="value" +% ~~~ +% +% Supported attributes for FONT: +% ~~~{.txt} +% COLOR="color" +% FACE="fontname" +% POINT-SIZE="value" +% ~~~ + +table(table(Attrs,Contents)) --> + html_element(table, Attrs, rows(Contents)). +table(table(font(Contents))) --> + html_element(font, [], html_element(table, [], rows(Contents))). + + +%! text(?Contents:list)// . + +text(Contents) --> + '+'(textitem, Contents, []). + + +%! textitem(?Content)// . +% Supported attributes for BR: +% ~~~{.txt} +% ALIGN="CENTER|LEFT|RIGHT" +% ~~~ + +textitem(string(String)) --> + html_string(String). +textitem(entity(Name)) --> + html_entity(Name). +textitem(br(Attrs)) --> + html_element(br, Attrs). +textitem(Compound) --> + {var(Compound)}, !, + html_element(Name, _, text(Content)), + { + supported_html_element(Name), + Compound =.. [Name,Content] + }. +textitem(Compound) --> + { + Compound =.. [Name,Content], + supported_html_element(Name) + }, + html_element(Name, _, text(Content)). + + + +% HELPERS + +%! supported_html_element(+Name:atom) is semidet. +%! supported_html_element(-Name:atom) is multi. + +supported_html_element(b). +supported_html_element(font). +supported_html_element(i). +supported_html_element(o). +supported_html_element(s). +supported_html_element(sub). +supported_html_element(sup). +supported_html_element(u). ```

42: 正在比较变动前 1549e44 和变动后 61ddca2

[back to content](#compare) ``` diff diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 15bbbbf..727ea49 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 15bbbbf25471abe856afbf92a04c5b3ce76b0217 +Subproject commit 727ea49d47063b733ae499615fda6aa06c84fb6f diff --git a/debug_project.pl b/debug_project.pl index 4eb2785..ab61534 100644 --- a/debug_project.pl +++ b/debug_project.pl @@ -37,7 +37,10 @@ debug_all_files:- ] ), exclude(do_not_load, Files1, Files2), - maplist(use_module, Files2). + maplist(use_module0, Files2). +use_module0(File):- + print_message(informational, loading_module(File)), + use_module(File). do_not_load(File1):- file_base_name(File1, File2), @@ -53,3 +56,12 @@ do_not_load0(load). do_not_load0(load_project). do_not_load0(rfc2616_basic). do_not_load0(run). + + + +% MESSAGES + +:- multifile(prolog:message//1). + +prolog:message(loading_module(File)) --> + ['[M] ',File]. diff --git a/gv_dot.pl b/gv_dot.pl index bde2962..5f33e5c 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -1,7 +1,7 @@ :- module( gv_dot, [ - gv_graph//1 % +Gif:compound + gv_graph//1 % +GraphTerm:compound ] ). @@ -39,7 +39,7 @@ In GraphViz vertices are called 'nodes'. % We assume that the attribute has already been validated. gv_attribute(Name=Val) --> - gv_id(Name), "=", gv_id(Val), ";". + gv_id(Name), `=`, gv_id(Val), `;`. %! gv_attribute_list( @@ -63,16 +63,16 @@ gv_attribute_list(Context, _, Attrs1) --> % compass_pt : (n | ne | e | se | s | sw | w | nw | c | _) % ~~~ -gv_compass_pt('_') --> "_". -gv_compass_pt(c) --> "c". -gv_compass_pt(e) --> "e". -gv_compass_pt(n) --> "n". -gv_compass_pt(ne) --> "ne". -gv_compass_pt(nw) --> "nw". -gv_compass_pt(s) --> "s". -gv_compass_pt(se) --> "se". -gv_compass_pt(sw) --> "sw". -gv_compass_pt(w) --> "w". +gv_compass_pt('_') --> `_`. +gv_compass_pt(c) --> `c`. +gv_compass_pt(e) --> `e`. +gv_compass_pt(n) --> `n`. +gv_compass_pt(ne) --> `ne`. +gv_compass_pt(nw) --> `nw`. +gv_compass_pt(s) --> `s`. +gv_compass_pt(se) --> `se`. +gv_compass_pt(sw) --> `sw`. +gv_compass_pt(w) --> `w`. %! gv_edge_operator(+Directed:boolean)// . @@ -83,7 +83,7 @@ gv_compass_pt(w) --> "w". % @arg Directed Whether an edge is directed (operator `->`) or % undirected (operator `--`). -gv_edge_operator(false) --> !, "--". +gv_edge_operator(false) --> !, `--`. gv_edge_operator(true) --> arrow(right, 2). @@ -107,11 +107,11 @@ gv_edge_operator(true) --> arrow(right, 2). gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> indent(I), - gv_node_id(FromId), " ", + gv_node_id(FromId), ` `, - gv_edge_operator(Directed), " ", + gv_edge_operator(Directed), ` `, - gv_node_id(ToId), " ", + gv_node_id(ToId), ` `, % We want `colorscheme/1` from the edges and % `directionality/1` from the graph. @@ -140,11 +140,11 @@ gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> gv_generic_attributes_statement(_, _, _, []) --> [], !. gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> indent(I), - gv_kind(Kind), " ", + gv_kind(Kind), ` `, gv_attribute_list(Kind, GraphAttrs, KindAttrs), line_feed. -%! gv_graph(+Gif:compound)// +%! gv_graph(+GraphTerm:compound)// % The follow graph attributes are supported, % beyond the GraphViz attributes for graphs: % * `directed(+boolean)` @@ -176,10 +176,10 @@ gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> % @tbd Assert attributes that are generic with respect to a subgraph. % @tbd Not all vertex and edge properties can be shared it seems (e.g., label). -gv_graph(graph(VTerms,ETerms,GAttrs)) --> - gv_graph(graph(VTerms,[],ETerms,GAttrs)). +gv_graph(graph(VTerms, ETerms, GAttrs)) --> + gv_graph(graph(VTerms, [], ETerms, GAttrs)). -gv_graph(graph(VTerms,RankedVTerms,ETerms,GAttrs1)) --> +gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> { shared_attributes(VTerms, SharedVAttrs, NewVTerms), shared_attributes(ETerms, SharedEAttrs, NewETerms), @@ -194,8 +194,8 @@ gv_graph(graph(VTerms,RankedVTerms,ETerms,GAttrs1)) --> % States that this file represents a graph according to the GraphViz format. indent(I), gv_strict(Strict), - gv_graph_type(Directed), " ", - gv_id(GName), " ", + gv_graph_type(Directed), ` `, + gv_id(GName), ` `, % The body of the DOT file appears between curly braces. bracketed( @@ -240,18 +240,18 @@ gv_graph0( (NewVTerms == [], RankedVTerms == []) } -> - "" + `` ; line_feed ), % The list of GraphViz nodes. '*'(gv_node_statement(NewI, GAttrs), NewVTerms, []), - ({NewVTerms == []} -> "" ; line_feed), + ({NewVTerms == []} -> `` ; line_feed), % The ranked GraphViz nodes (displayed at the same height). '*'(gv_ranked_node_collection(NewI, GAttrs), RankedVTerms, []), - ({RankedVTerms == []} -> "" ; line_feed), + ({RankedVTerms == []} -> `` ; line_feed), { findall( @@ -281,8 +281,8 @@ gv_graph0( %! gv_graph_type(+Directed:boolean)// . % The type of graph that is represented. -gv_graph_type(false) --> "graph". -gv_graph_type(true) --> "digraph". +gv_graph_type(false) --> `graph`. +gv_graph_type(true) --> `digraph`. %! gv_id(?Atom:atom)// is det. @@ -305,9 +305,8 @@ gv_graph_type(true) --> "digraph". % This requires an XML grammar! % HTML strings (variant 4). -gv_id(Content) --> - {compound(Content)}, !, - gv_html_like_label, Content). +gv_id(Atom) --> + dcg_atom_codes(gv_html_like_label, Atom), !. % Alpha-numeric strings (variant 1). gv_id(Atom) --> {atom_codes(Atom, [H|T])}, @@ -354,19 +353,19 @@ gv_keyword(Codes):- % GraphViz has reserved keywords that cannot be used as identifiers. % GraphViz keywords are case-insensitive. -gv_keyword --> "digraph". -gv_keyword --> "edge". -gv_keyword --> "graph". -gv_keyword --> "node". -gv_keyword --> "strict". -gv_keyword --> "subgraph". +gv_keyword --> `digraph`. +gv_keyword --> `edge`. +gv_keyword --> `graph`. +gv_keyword --> `node`. +gv_keyword --> `strict`. +gv_keyword --> `subgraph`. %! gv_kind(+Kind:oneof([edge,graph,node]))// . -gv_kind(edge) --> "edge". -gv_kind(graph) --> "graph". -gv_kind(node) --> "node". +gv_kind(edge) --> `edge`. +gv_kind(graph) --> `graph`. +gv_kind(node) --> `node`. %! gv_node_id(+NodeId:atom)// . @@ -393,7 +392,7 @@ gv_node_id(Id) --> gv_node_statement(I, GraphAttrs, vertex(Id,_,VAttrs)) --> indent(I), - gv_node_id(Id), " ", + gv_node_id(Id), ` `, gv_attribute_list(node, GraphAttrs, VAttrs), line_feed. @@ -404,23 +403,23 @@ gv_port --> gv_port_angle, '?'(gv_port_location, []). gv_port --> - ":", + `:`, gv_compass_pt(_). gv_port_angle --> - "@", + `@`, gv_id(_). gv_port_location --> - ":", + `:`, gv_id(_). gv_port_location --> - ":", + `:`, bracketed( round, ( gv_id(_), - ",", + `,`, gv_id(_) ) ). @@ -437,7 +436,7 @@ gv_quoted_string([92,34|T]) --> !, gv_quoted_string(T). % Add the backslash escape character. gv_quoted_string([34|T]) --> !, - "\\\"", + `\\\"`, gv_quoted_string(T). % All other characters are allowed without escaping. gv_quoted_string([H|T]) --> @@ -456,7 +455,7 @@ gv_ranked_node_collection( % The rank attribute. {NewI is I + 1}, - indent(NewI), gv_attribute(rank=same), ";", line_feed, + indent(NewI), gv_attribute(rank=same), `;`, line_feed, '*'( gv_node_statement(NewI, GraphAttrs), @@ -476,7 +475,7 @@ gv_ranked_node_collection( % This only applies to directed graphs. gv_strict(false) --> []. -gv_strict(true) --> "strict ". +gv_strict(true) --> `strict `. diff --git a/gv_html.pl b/gv_html.pl index a308ac7..3f0b08b 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -1,223 +1,60 @@ :- module( gv_html, [ - gv_html_like_label//1 % +Content:compound + gv_html_like_label//1 % +Codes:list(code) ] ). -/** GraphViz: HTML-like labels - -Grammar taken from the GraphViz Web site: - -~~~{.txt} -label : text - | table -text : textitem - | text textitem -textitem : string - |
- | text - | text - | text - | text - | text - | text - | text - | text -table : [ ] rows
[
] -rows : row - | rows row - | rows
row -row : cells -cells : cell - | cells cell - | cells cell -cell : label - | -~~~ +/** GraphViz HTML @author Wouter Beek -@see http://www.graphviz.org/content/node-shapes#html -@version 2013/07, 2013/09, 2014/03-2014/06, 2014/11 +@version 2013/07, 2013/09, 2014/03-2014/06 */ -:- use_module(plDcg(dcg_abnf)). :- use_module(plDcg(dcg_content)). :- use_module(plHtml(html_dcg)). -%! gv_html_like_label(?Content:compound)// . - -gv_html_like_label(Content) --> - bracketed(angular, label(Content)). - - -%! cell(?Contents:compound)// . -% Supported attributes for TD: -% ~~~{.txt} -% ALIGN="CENTER|LEFT|RIGHT|TEXT" -% BALIGN="CENTER|LEFT|RIGHT" -% BGCOLOR="color" -% BORDER="value" -% CELLPADDING="value" -% CELLSPACING="value" -% COLOR="color" -% COLSPAN="value" -% FIXEDSIZE="FALSE|TRUE" -% GRADIENTANGLE="value" -% HEIGHT="value" -% HREF="value" -% ID="value" -% PORT="portName" -% ROWSPAN="value" -% SIDES="value" -% STYLE="value" -% TARGET="value" -% TITLE="value" -% TOOLTIP="value" -% VALIGN="MIDDLE|BOTTOM|TOP" -% WIDTH="value" -% ~~~ +%! gv_html_label(+Codes:list(code))// . % -% Supported attributes for IMG: -% ~~~{.txt} -% SCALE="FALSE|TRUE|WIDTH|HEIGHT|BOTH" -% SRC="value" -% ~~~ - -cell(td(Contents)) --> - html_element(td, [], label(Contents)). -cell(td(img)) --> - html_element(td, [], html_element(img)). - - -%! cells(?Contents:list(compound))// . - -cells([H|T]) --> - cell(H), - cells(T). -cells([H,vr|T]) --> - cell(H), - html_element(vr), - cells(T). -cells([H]) --> - cell(H). - - -%! label(?Content:compound)// . -% GraphViz HTML-like label. - -label(Content) --> - text(Content). -label(Content) --> - table(Content). - - -%! row(?Contents:compound)// . - -row(tr(Contents)) --> - html_element(tr, [], cell(Contents)). - - -%! rows(?Contents:list)// . - -rows([H|T]) --> - row(H), - rows. -rows([H,hr|T]) --> - row(H), - html_element(hr), - rows(T). -rows([H]) --> - row(H). - - -%! table(?Contents:compound)// . -% Supported attributes for TABLE: -% ~~~{.txt} -% ALIGN="CENTER|LEFT|RIGHT" -% BGCOLOR="color" -% BORDER="value" -% CELLBORDER="value" -% CELLPADDING="value" -% CELLSPACING="value" -% COLOR="color" -% COLUMNS="value" -% FIXEDSIZE="FALSE|TRUE" -% GRADIENTANGLE="value" -% HEIGHT="value" -% HREF="value" -% ID="value" -% PORT="portName" -% ROWS="value" -% SIDES="value" -% STYLE="value" -% TARGET="value" -% TITLE="value" -% TOOLTIP="value" -% VALIGN="MIDDLE|BOTTOM|TOP" -% WIDTH="value" -% ~~~ -% -% Supported attributes for FONT: -% ~~~{.txt} -% COLOR="color" -% FACE="fontname" -% POINT-SIZE="value" -% ~~~ - -table(table(Attrs,Contents)) --> - html_element(table, Attrs, rows(Contents)). -table(table(font(Contents))) --> - html_element(font, [], html_element(table, [], rows(Contents))). - - -%! text(?Contents:list)// . - -text(Contents) --> - '+'(textitem, Contents, []). - - -%! textitem(?Content)// . -% Supported attributes for BR: -% ~~~{.txt} -% ALIGN="CENTER|LEFT|RIGHT" -% ~~~ - -textitem(string(String)) --> - html_string(String). -textitem(entity(Name)) --> - html_entity(Name). -textitem(br(Attrs)) --> - html_element(br, Attrs). -textitem(Compound) --> - {var(Compound)}, !, - html_element(Name, _, text(Content)), - { - supported_html_element(Name), - Compound =.. [Name,Content] - }. -textitem(Compound) --> - { - Compound =.. [Name,Content], - supported_html_element(Name) - }, - html_element(Name, _, text(Content)). - - - -% HELPERS - -%! supported_html_element(+Name:atom) is semidet. -%! supported_html_element(-Name:atom) is multi. - -supported_html_element(b). -supported_html_element(font). -supported_html_element(i). -supported_html_element(o). -supported_html_element(s). -supported_html_element(sub). -supported_html_element(sup). -supported_html_element(u). +% @see http://www.graphviz.org/doc/info/shapes.html#html + +gv_html_label --> gv_html_text, !. +gv_html_label --> gv_html_table, !. +gv_html_label --> []. + +gv_html_like_label --> bracketed(angular, gv_html_label). + +gv_html_like_label(Content) --> bracketed(angular, html_dcg(Content)). + +gv_html_table --> html_element(table, _, gv_html_rows). +gv_html_table --> html_element(font, _, html_element(table, _, gv_html_rows)). + +gv_html_rows --> gv_html_row, gv_html_rows. +gv_html_rows --> gv_html_row, html_element(hr, _), gv_html_rows. +gv_html_rows --> gv_html_row. + +gv_html_row --> html_element(tr, _, gv_html_cells). + +gv_html_cell --> html_element(td, _, gv_html_label). +gv_html_cell --> html_element(td, _, html_element(img, _)). + +gv_html_cells --> gv_html_cell, gv_html_cells. +gv_html_cells --> gv_html_cell. +gv_html_cells --> gv_html_cell, html_element(vr, _), gv_html_cells. + +gv_html_text --> gv_html_textitem, gv_html_text. +gv_html_text --> gv_html_textitem. + +gv_html_textitem --> html_string, !. +gv_html_textitem --> html_entity, !. +gv_html_textitem --> html_element(br, _), !. +gv_html_textitem --> html_element(font, _, gv_html_text), !. +gv_html_textitem --> html_element(i, _, gv_html_text), !. +gv_html_textitem --> html_element(b, _, gv_html_text), !. +gv_html_textitem --> html_element(u, _, gv_html_text), !. +gv_html_textitem --> html_element(sub, _, gv_html_text), !. +gv_html_textitem --> html_element(sup, _, gv_html_text), !. + diff --git a/plDcg b/plDcg index e074367..be16501 160000 --- a/plDcg +++ b/plDcg @@ -1 +1 @@ -Subproject commit e0743670465a92c083e6954c5cf6220222f088b6 +Subproject commit be165017993efcf781007c5d682a519fb5eaa31f diff --git a/plHtml b/plHtml index 8ef47e0..e3abeed 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit 8ef47e09a24c637ac435abbe1d01b21237be4534 +Subproject commit e3abeed4041392013965598145806ee33081f76f ```

43: 正在比较变动前 61ddca2 和变动后 26f07e7

[back to content](#compare) ``` diff diff --git a/gv_dot.pl b/gv_dot.pl index 5f33e5c..bde2962 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -1,7 +1,7 @@ :- module( gv_dot, [ - gv_graph//1 % +GraphTerm:compound + gv_graph//1 % +Gif:compound ] ). @@ -39,7 +39,7 @@ In GraphViz vertices are called 'nodes'. % We assume that the attribute has already been validated. gv_attribute(Name=Val) --> - gv_id(Name), `=`, gv_id(Val), `;`. + gv_id(Name), "=", gv_id(Val), ";". %! gv_attribute_list( @@ -63,16 +63,16 @@ gv_attribute_list(Context, _, Attrs1) --> % compass_pt : (n | ne | e | se | s | sw | w | nw | c | _) % ~~~ -gv_compass_pt('_') --> `_`. -gv_compass_pt(c) --> `c`. -gv_compass_pt(e) --> `e`. -gv_compass_pt(n) --> `n`. -gv_compass_pt(ne) --> `ne`. -gv_compass_pt(nw) --> `nw`. -gv_compass_pt(s) --> `s`. -gv_compass_pt(se) --> `se`. -gv_compass_pt(sw) --> `sw`. -gv_compass_pt(w) --> `w`. +gv_compass_pt('_') --> "_". +gv_compass_pt(c) --> "c". +gv_compass_pt(e) --> "e". +gv_compass_pt(n) --> "n". +gv_compass_pt(ne) --> "ne". +gv_compass_pt(nw) --> "nw". +gv_compass_pt(s) --> "s". +gv_compass_pt(se) --> "se". +gv_compass_pt(sw) --> "sw". +gv_compass_pt(w) --> "w". %! gv_edge_operator(+Directed:boolean)// . @@ -83,7 +83,7 @@ gv_compass_pt(w) --> `w`. % @arg Directed Whether an edge is directed (operator `->`) or % undirected (operator `--`). -gv_edge_operator(false) --> !, `--`. +gv_edge_operator(false) --> !, "--". gv_edge_operator(true) --> arrow(right, 2). @@ -107,11 +107,11 @@ gv_edge_operator(true) --> arrow(right, 2). gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> indent(I), - gv_node_id(FromId), ` `, + gv_node_id(FromId), " ", - gv_edge_operator(Directed), ` `, + gv_edge_operator(Directed), " ", - gv_node_id(ToId), ` `, + gv_node_id(ToId), " ", % We want `colorscheme/1` from the edges and % `directionality/1` from the graph. @@ -140,11 +140,11 @@ gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> gv_generic_attributes_statement(_, _, _, []) --> [], !. gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> indent(I), - gv_kind(Kind), ` `, + gv_kind(Kind), " ", gv_attribute_list(Kind, GraphAttrs, KindAttrs), line_feed. -%! gv_graph(+GraphTerm:compound)// +%! gv_graph(+Gif:compound)// % The follow graph attributes are supported, % beyond the GraphViz attributes for graphs: % * `directed(+boolean)` @@ -176,10 +176,10 @@ gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> % @tbd Assert attributes that are generic with respect to a subgraph. % @tbd Not all vertex and edge properties can be shared it seems (e.g., label). -gv_graph(graph(VTerms, ETerms, GAttrs)) --> - gv_graph(graph(VTerms, [], ETerms, GAttrs)). +gv_graph(graph(VTerms,ETerms,GAttrs)) --> + gv_graph(graph(VTerms,[],ETerms,GAttrs)). -gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> +gv_graph(graph(VTerms,RankedVTerms,ETerms,GAttrs1)) --> { shared_attributes(VTerms, SharedVAttrs, NewVTerms), shared_attributes(ETerms, SharedEAttrs, NewETerms), @@ -194,8 +194,8 @@ gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> % States that this file represents a graph according to the GraphViz format. indent(I), gv_strict(Strict), - gv_graph_type(Directed), ` `, - gv_id(GName), ` `, + gv_graph_type(Directed), " ", + gv_id(GName), " ", % The body of the DOT file appears between curly braces. bracketed( @@ -240,18 +240,18 @@ gv_graph0( (NewVTerms == [], RankedVTerms == []) } -> - `` + "" ; line_feed ), % The list of GraphViz nodes. '*'(gv_node_statement(NewI, GAttrs), NewVTerms, []), - ({NewVTerms == []} -> `` ; line_feed), + ({NewVTerms == []} -> "" ; line_feed), % The ranked GraphViz nodes (displayed at the same height). '*'(gv_ranked_node_collection(NewI, GAttrs), RankedVTerms, []), - ({RankedVTerms == []} -> `` ; line_feed), + ({RankedVTerms == []} -> "" ; line_feed), { findall( @@ -281,8 +281,8 @@ gv_graph0( %! gv_graph_type(+Directed:boolean)// . % The type of graph that is represented. -gv_graph_type(false) --> `graph`. -gv_graph_type(true) --> `digraph`. +gv_graph_type(false) --> "graph". +gv_graph_type(true) --> "digraph". %! gv_id(?Atom:atom)// is det. @@ -305,8 +305,9 @@ gv_graph_type(true) --> `digraph`. % This requires an XML grammar! % HTML strings (variant 4). -gv_id(Atom) --> - dcg_atom_codes(gv_html_like_label, Atom), !. +gv_id(Content) --> + {compound(Content)}, !, + gv_html_like_label, Content). % Alpha-numeric strings (variant 1). gv_id(Atom) --> {atom_codes(Atom, [H|T])}, @@ -353,19 +354,19 @@ gv_keyword(Codes):- % GraphViz has reserved keywords that cannot be used as identifiers. % GraphViz keywords are case-insensitive. -gv_keyword --> `digraph`. -gv_keyword --> `edge`. -gv_keyword --> `graph`. -gv_keyword --> `node`. -gv_keyword --> `strict`. -gv_keyword --> `subgraph`. +gv_keyword --> "digraph". +gv_keyword --> "edge". +gv_keyword --> "graph". +gv_keyword --> "node". +gv_keyword --> "strict". +gv_keyword --> "subgraph". %! gv_kind(+Kind:oneof([edge,graph,node]))// . -gv_kind(edge) --> `edge`. -gv_kind(graph) --> `graph`. -gv_kind(node) --> `node`. +gv_kind(edge) --> "edge". +gv_kind(graph) --> "graph". +gv_kind(node) --> "node". %! gv_node_id(+NodeId:atom)// . @@ -392,7 +393,7 @@ gv_node_id(Id) --> gv_node_statement(I, GraphAttrs, vertex(Id,_,VAttrs)) --> indent(I), - gv_node_id(Id), ` `, + gv_node_id(Id), " ", gv_attribute_list(node, GraphAttrs, VAttrs), line_feed. @@ -403,23 +404,23 @@ gv_port --> gv_port_angle, '?'(gv_port_location, []). gv_port --> - `:`, + ":", gv_compass_pt(_). gv_port_angle --> - `@`, + "@", gv_id(_). gv_port_location --> - `:`, + ":", gv_id(_). gv_port_location --> - `:`, + ":", bracketed( round, ( gv_id(_), - `,`, + ",", gv_id(_) ) ). @@ -436,7 +437,7 @@ gv_quoted_string([92,34|T]) --> !, gv_quoted_string(T). % Add the backslash escape character. gv_quoted_string([34|T]) --> !, - `\\\"`, + "\\\"", gv_quoted_string(T). % All other characters are allowed without escaping. gv_quoted_string([H|T]) --> @@ -455,7 +456,7 @@ gv_ranked_node_collection( % The rank attribute. {NewI is I + 1}, - indent(NewI), gv_attribute(rank=same), `;`, line_feed, + indent(NewI), gv_attribute(rank=same), ";", line_feed, '*'( gv_node_statement(NewI, GraphAttrs), @@ -475,7 +476,7 @@ gv_ranked_node_collection( % This only applies to directed graphs. gv_strict(false) --> []. -gv_strict(true) --> `strict `. +gv_strict(true) --> "strict ". diff --git a/gv_html.pl b/gv_html.pl index 3f0b08b..a308ac7 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -1,60 +1,223 @@ :- module( gv_html, [ - gv_html_like_label//1 % +Codes:list(code) + gv_html_like_label//1 % +Content:compound ] ). -/** GraphViz HTML +/** GraphViz: HTML-like labels + +Grammar taken from the GraphViz Web site: + +~~~{.txt} +label : text + | table +text : textitem + | text textitem +textitem : string + |
+ | text + | text + | text + | text + | text + | text + | text + | text +table : [ ] rows
[
] +rows : row + | rows row + | rows
row +row : cells +cells : cell + | cells cell + | cells cell +cell : label + | +~~~ @author Wouter Beek -@version 2013/07, 2013/09, 2014/03-2014/06 +@see http://www.graphviz.org/content/node-shapes#html +@version 2013/07, 2013/09, 2014/03-2014/06, 2014/11 */ +:- use_module(plDcg(dcg_abnf)). :- use_module(plDcg(dcg_content)). :- use_module(plHtml(html_dcg)). -%! gv_html_label(+Codes:list(code))// . +%! gv_html_like_label(?Content:compound)// . + +gv_html_like_label(Content) --> + bracketed(angular, label(Content)). + + +%! cell(?Contents:compound)// . +% Supported attributes for TD: +% ~~~{.txt} +% ALIGN="CENTER|LEFT|RIGHT|TEXT" +% BALIGN="CENTER|LEFT|RIGHT" +% BGCOLOR="color" +% BORDER="value" +% CELLPADDING="value" +% CELLSPACING="value" +% COLOR="color" +% COLSPAN="value" +% FIXEDSIZE="FALSE|TRUE" +% GRADIENTANGLE="value" +% HEIGHT="value" +% HREF="value" +% ID="value" +% PORT="portName" +% ROWSPAN="value" +% SIDES="value" +% STYLE="value" +% TARGET="value" +% TITLE="value" +% TOOLTIP="value" +% VALIGN="MIDDLE|BOTTOM|TOP" +% WIDTH="value" +% ~~~ % -% @see http://www.graphviz.org/doc/info/shapes.html#html - -gv_html_label --> gv_html_text, !. -gv_html_label --> gv_html_table, !. -gv_html_label --> []. - -gv_html_like_label --> bracketed(angular, gv_html_label). - -gv_html_like_label(Content) --> bracketed(angular, html_dcg(Content)). - -gv_html_table --> html_element(table, _, gv_html_rows). -gv_html_table --> html_element(font, _, html_element(table, _, gv_html_rows)). - -gv_html_rows --> gv_html_row, gv_html_rows. -gv_html_rows --> gv_html_row, html_element(hr, _), gv_html_rows. -gv_html_rows --> gv_html_row. - -gv_html_row --> html_element(tr, _, gv_html_cells). - -gv_html_cell --> html_element(td, _, gv_html_label). -gv_html_cell --> html_element(td, _, html_element(img, _)). - -gv_html_cells --> gv_html_cell, gv_html_cells. -gv_html_cells --> gv_html_cell. -gv_html_cells --> gv_html_cell, html_element(vr, _), gv_html_cells. - -gv_html_text --> gv_html_textitem, gv_html_text. -gv_html_text --> gv_html_textitem. - -gv_html_textitem --> html_string, !. -gv_html_textitem --> html_entity, !. -gv_html_textitem --> html_element(br, _), !. -gv_html_textitem --> html_element(font, _, gv_html_text), !. -gv_html_textitem --> html_element(i, _, gv_html_text), !. -gv_html_textitem --> html_element(b, _, gv_html_text), !. -gv_html_textitem --> html_element(u, _, gv_html_text), !. -gv_html_textitem --> html_element(sub, _, gv_html_text), !. -gv_html_textitem --> html_element(sup, _, gv_html_text), !. - +% Supported attributes for IMG: +% ~~~{.txt} +% SCALE="FALSE|TRUE|WIDTH|HEIGHT|BOTH" +% SRC="value" +% ~~~ + +cell(td(Contents)) --> + html_element(td, [], label(Contents)). +cell(td(img)) --> + html_element(td, [], html_element(img)). + + +%! cells(?Contents:list(compound))// . + +cells([H|T]) --> + cell(H), + cells(T). +cells([H,vr|T]) --> + cell(H), + html_element(vr), + cells(T). +cells([H]) --> + cell(H). + + +%! label(?Content:compound)// . +% GraphViz HTML-like label. + +label(Content) --> + text(Content). +label(Content) --> + table(Content). + + +%! row(?Contents:compound)// . + +row(tr(Contents)) --> + html_element(tr, [], cell(Contents)). + + +%! rows(?Contents:list)// . + +rows([H|T]) --> + row(H), + rows. +rows([H,hr|T]) --> + row(H), + html_element(hr), + rows(T). +rows([H]) --> + row(H). + + +%! table(?Contents:compound)// . +% Supported attributes for TABLE: +% ~~~{.txt} +% ALIGN="CENTER|LEFT|RIGHT" +% BGCOLOR="color" +% BORDER="value" +% CELLBORDER="value" +% CELLPADDING="value" +% CELLSPACING="value" +% COLOR="color" +% COLUMNS="value" +% FIXEDSIZE="FALSE|TRUE" +% GRADIENTANGLE="value" +% HEIGHT="value" +% HREF="value" +% ID="value" +% PORT="portName" +% ROWS="value" +% SIDES="value" +% STYLE="value" +% TARGET="value" +% TITLE="value" +% TOOLTIP="value" +% VALIGN="MIDDLE|BOTTOM|TOP" +% WIDTH="value" +% ~~~ +% +% Supported attributes for FONT: +% ~~~{.txt} +% COLOR="color" +% FACE="fontname" +% POINT-SIZE="value" +% ~~~ + +table(table(Attrs,Contents)) --> + html_element(table, Attrs, rows(Contents)). +table(table(font(Contents))) --> + html_element(font, [], html_element(table, [], rows(Contents))). + + +%! text(?Contents:list)// . + +text(Contents) --> + '+'(textitem, Contents, []). + + +%! textitem(?Content)// . +% Supported attributes for BR: +% ~~~{.txt} +% ALIGN="CENTER|LEFT|RIGHT" +% ~~~ + +textitem(string(String)) --> + html_string(String). +textitem(entity(Name)) --> + html_entity(Name). +textitem(br(Attrs)) --> + html_element(br, Attrs). +textitem(Compound) --> + {var(Compound)}, !, + html_element(Name, _, text(Content)), + { + supported_html_element(Name), + Compound =.. [Name,Content] + }. +textitem(Compound) --> + { + Compound =.. [Name,Content], + supported_html_element(Name) + }, + html_element(Name, _, text(Content)). + + + +% HELPERS + +%! supported_html_element(+Name:atom) is semidet. +%! supported_html_element(-Name:atom) is multi. + +supported_html_element(b). +supported_html_element(font). +supported_html_element(i). +supported_html_element(o). +supported_html_element(s). +supported_html_element(sub). +supported_html_element(sup). +supported_html_element(u). ```

44: 正在比较变动前 26f07e7 和变动后 f78b4f8

[back to content](#compare) ``` diff diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 727ea49..7096ef9 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 727ea49d47063b733ae499615fda6aa06c84fb6f +Subproject commit 7096ef9749edffe389df6a90d586930c8bf4df70 diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 3c7863d..67d419a 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -46,10 +46,11 @@ /** GraphViz attribute types @author Wouter Beek -@version 2014/06 +@version 2014/06, 2014/11 */ :- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_ascii)). :- use_module(plDcg(dcg_cardinal)). :- use_module(plDcg(dcg_content)). @@ -97,7 +98,7 @@ gv_attr_type(viewPort). % An *addDouble* is represented by a Prolog float. addDouble(Float) --> - '?'(`+`, []), + '?'(plus_sign, []), double(Float). @@ -106,7 +107,7 @@ addDouble(Float) --> % `point(X:float,Y:float,InputOnly:boolean)`. addPoint(Point) --> - '?'(`+`, []), + '?'(plus_sign, []), point(Point). @@ -147,10 +148,10 @@ backwards_compatible(invempty). backwards_compatible(open). -bool(false) --> `false`. -bool(false) --> `no`. -bool(true) --> `true`. -bool(true) --> `yes`. +bool(false) --> "false". +bool(false) --> "no". +bool(true) --> "true". +bool(true) --> "yes". %! clusterMode(+ClusterMode:atom)// . @@ -187,7 +188,7 @@ doubleList([H|T]) --> '*'(doubleList1, T, []). doubleList1(Float) --> - `:`, + ":", double(Float). @@ -242,16 +243,16 @@ pagedir('TR'). %! point(+Point:compound)// . % A *point* is represented by a compound of the following form: -% `point(X:float,Y:float,InputOnly:boolean)`. +% `point(X:float,Y:float,Changeable:boolean)`. -point(point(X,Y,InputOnly)) --> +point(point(X,Y,Changeable)) --> float(X), - `,`, + ",", float(Y), - input_only(InputOnly). + input_changeable(Changeable). -input_only(false) --> []. -input_only(true) --> `!`. +input_changeable(false) --> "". +input_changeable(true) --> "!". pointList(Points) --> @@ -292,9 +293,9 @@ rankdir('TB'). rect(rect(LowerLeftX,LowerLeftY,UpperRightX,UpperRightY)) --> - float(LowerLeftX), `,`, - float(LowerLeftY), `,`, - float(UpperRightX), `,`, + float(LowerLeftX), ",", + float(LowerLeftY), ",", + float(UpperRightX), ",", float(UpperRightY). @@ -414,4 +415,3 @@ style(node, wedged). % @tbd viewPort - diff --git a/gv_attrs.pl b/gv_attrs.pl index 1692915..df0922a 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -2,15 +2,17 @@ gv_attrs, [ gv_attr/3 % +Context:oneof([cluster,edge,graph,node,subgraph]) - % +Attr1:nvpair - % +Attr2:nvpair + % +Attribute1:nvpair + % -Attribute2:nvpair ] ). -/** GraphViz attributes v2 +/** GraphViz: Attributes + +Support for GraphViz attributes. @author Wouter Beek -@version 2014/06 +@version 2014/06, 2014/11 */ :- use_module(library(apply)). @@ -54,24 +56,40 @@ +%! gv_attr( +%! +Context:oneof([cluster,edge,graph,node,subgraph]), +%! +Attribute1:nvpair, +%! +Attribute2:nvpair +%! ) is det. +% Uses the default value in case Value is uninstantiated. +% Otherwise, performs a typecheck and converts the given value. + gv_attr(Context, N=V, N=V):- var(V), !, gv_attr(N, UsedBy, _, V, _, _), + % Check validity of context. memberchk(Context, UsedBy). gv_attr(Context, N=V1, N=V2):- - gv_attr(N, UsedBy, Types, _, Minimum, _), + gv_attr(N2, UsedBy, Types, _, Minimum, _), + % Check validity of context. memberchk(Context, UsedBy), + % Check validity of value type. member(Type, Types), - ( - Type == style - -> - Dcg =.. [Type,Context,V1] - ; - Dcg =.. [Type,V1] + ( Type == style + -> Dcg =.. [Type,Context,V1] + ; Dcg =.. [Type,V1] ), once(dcg_phrase(Dcg, V2)), + % Check validity of Value w.r.t. minimum value -- if available. check_minimum(V1, Minimum). + + +% HELPERS + +%! check_minimum(+Value:atom, +Minimum:number) is semidet. +% Trivially succeeds if no minimum value is available for a given attribute. + check_minimum(_, ''):- !. check_minimum(V, Min1):- atom_number(Min1, Min2), diff --git a/plDcg b/plDcg index be16501..2cd7321 160000 --- a/plDcg +++ b/plDcg @@ -1 +1 @@ -Subproject commit be165017993efcf781007c5d682a519fb5eaa31f +Subproject commit 2cd7321d6c8a84ca23d08670348914c4a8ca6bb0 ```

45: 正在比较变动前 f78b4f8 和变动后 3109362

[back to content](#compare) ``` diff diff --git a/.gitignore b/.gitignore index 7193a38..b25c15b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1 @@ *~ -*# -*.db -data/* diff --git a/.gitmodules b/.gitmodules index 844b1bd..a63cbff 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [submodule "plHtml"] path = plHtml url = https://github.com/wouterbeek/plHtml.git -[submodule "plDcg"] - path = plDcg - url = https://github.com/wouterbeek/plDcg.git diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 7096ef9..b1d2484 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 7096ef9749edffe389df6a90d586930c8bf4df70 +Subproject commit b1d2484486ad4876aecc1bf70b2963b12efca341 diff --git a/debug.pl b/debug.pl deleted file mode 100644 index 099cb84..0000000 --- a/debug.pl +++ /dev/null @@ -1,7 +0,0 @@ -% Loads debug tools for the plGraphViz library. - -:- [load]. - -:- use_module(debug_project). -:- debug_all_files. - diff --git a/debug_project.pl b/debug_project.pl deleted file mode 100644 index ab61534..0000000 --- a/debug_project.pl +++ /dev/null @@ -1,67 +0,0 @@ -:- module( - debug_project, - [ - debug_all_files/0 - ] -). - -/** Debug project - -Generic code for debugging a project: - * Load all subdirectories and Prolog files contained in those directories. - -@author Wouter Beek -@version 2014/10/31 -*/ - -:- use_module(library(ansi_term)). -:- use_module(library(apply)). - -:- use_module(os(dir_ext)). - -% Avoid errors when using gtrace/0 in threads. -:- initialization(guitracer). - - - -debug_all_files:- - absolute_file_name(project(.), Dir, [access(read),file_type(directory)]), - directory_files( - Dir, - Files1, - [ - file_types([prolog]), - include_directories(false), - include_self(false), - recursive(true) - ] - ), - exclude(do_not_load, Files1, Files2), - maplist(use_module0, Files2). -use_module0(File):- - print_message(informational, loading_module(File)), - use_module(File). - -do_not_load(File1):- - file_base_name(File1, File2), - file_name_extension(File3, pl, File2), - do_not_load0(File3). - -do_not_load0(dcg_ascii). -do_not_load0(dcg_unicode). -do_not_load0(debug). -do_not_load0(debug_project). -do_not_load0(index). -do_not_load0(load). -do_not_load0(load_project). -do_not_load0(rfc2616_basic). -do_not_load0(run). - - - -% MESSAGES - -:- multifile(prolog:message//1). - -prolog:message(loading_module(File)) --> - ['[M] ',File]. diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 67d419a..3c7863d 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -46,11 +46,10 @@ /** GraphViz attribute types @author Wouter Beek -@version 2014/06, 2014/11 +@version 2014/06 */ :- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_ascii)). :- use_module(plDcg(dcg_cardinal)). :- use_module(plDcg(dcg_content)). @@ -98,7 +97,7 @@ gv_attr_type(viewPort). % An *addDouble* is represented by a Prolog float. addDouble(Float) --> - '?'(plus_sign, []), + '?'(`+`, []), double(Float). @@ -107,7 +106,7 @@ addDouble(Float) --> % `point(X:float,Y:float,InputOnly:boolean)`. addPoint(Point) --> - '?'(plus_sign, []), + '?'(`+`, []), point(Point). @@ -148,10 +147,10 @@ backwards_compatible(invempty). backwards_compatible(open). -bool(false) --> "false". -bool(false) --> "no". -bool(true) --> "true". -bool(true) --> "yes". +bool(false) --> `false`. +bool(false) --> `no`. +bool(true) --> `true`. +bool(true) --> `yes`. %! clusterMode(+ClusterMode:atom)// . @@ -188,7 +187,7 @@ doubleList([H|T]) --> '*'(doubleList1, T, []). doubleList1(Float) --> - ":", + `:`, double(Float). @@ -243,16 +242,16 @@ pagedir('TR'). %! point(+Point:compound)// . % A *point* is represented by a compound of the following form: -% `point(X:float,Y:float,Changeable:boolean)`. +% `point(X:float,Y:float,InputOnly:boolean)`. -point(point(X,Y,Changeable)) --> +point(point(X,Y,InputOnly)) --> float(X), - ",", + `,`, float(Y), - input_changeable(Changeable). + input_only(InputOnly). -input_changeable(false) --> "". -input_changeable(true) --> "!". +input_only(false) --> []. +input_only(true) --> `!`. pointList(Points) --> @@ -293,9 +292,9 @@ rankdir('TB'). rect(rect(LowerLeftX,LowerLeftY,UpperRightX,UpperRightY)) --> - float(LowerLeftX), ",", - float(LowerLeftY), ",", - float(UpperRightX), ",", + float(LowerLeftX), `,`, + float(LowerLeftY), `,`, + float(UpperRightX), `,`, float(UpperRightY). @@ -415,3 +414,4 @@ style(node, wedged). % @tbd viewPort + diff --git a/gv_attrs.pl b/gv_attrs.pl index df0922a..1692915 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -2,17 +2,15 @@ gv_attrs, [ gv_attr/3 % +Context:oneof([cluster,edge,graph,node,subgraph]) - % +Attribute1:nvpair - % -Attribute2:nvpair + % +Attr1:nvpair + % +Attr2:nvpair ] ). -/** GraphViz: Attributes - -Support for GraphViz attributes. +/** GraphViz attributes v2 @author Wouter Beek -@version 2014/06, 2014/11 +@version 2014/06 */ :- use_module(library(apply)). @@ -56,40 +54,24 @@ Support for GraphViz attributes. -%! gv_attr( -%! +Context:oneof([cluster,edge,graph,node,subgraph]), -%! +Attribute1:nvpair, -%! +Attribute2:nvpair -%! ) is det. -% Uses the default value in case Value is uninstantiated. -% Otherwise, performs a typecheck and converts the given value. - gv_attr(Context, N=V, N=V):- var(V), !, gv_attr(N, UsedBy, _, V, _, _), - % Check validity of context. memberchk(Context, UsedBy). gv_attr(Context, N=V1, N=V2):- - gv_attr(N2, UsedBy, Types, _, Minimum, _), - % Check validity of context. + gv_attr(N, UsedBy, Types, _, Minimum, _), memberchk(Context, UsedBy), - % Check validity of value type. member(Type, Types), - ( Type == style - -> Dcg =.. [Type,Context,V1] - ; Dcg =.. [Type,V1] + ( + Type == style + -> + Dcg =.. [Type,Context,V1] + ; + Dcg =.. [Type,V1] ), once(dcg_phrase(Dcg, V2)), - % Check validity of Value w.r.t. minimum value -- if available. check_minimum(V1, Minimum). - - -% HELPERS - -%! check_minimum(+Value:atom, +Minimum:number) is semidet. -% Trivially succeeds if no minimum value is available for a given attribute. - check_minimum(_, ''):- !. check_minimum(V, Min1):- atom_number(Min1, Min2), diff --git a/gv_dot.pl b/gv_dot.pl index bde2962..5f33e5c 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -1,7 +1,7 @@ :- module( gv_dot, [ - gv_graph//1 % +Gif:compound + gv_graph//1 % +GraphTerm:compound ] ). @@ -39,7 +39,7 @@ In GraphViz vertices are called 'nodes'. % We assume that the attribute has already been validated. gv_attribute(Name=Val) --> - gv_id(Name), "=", gv_id(Val), ";". + gv_id(Name), `=`, gv_id(Val), `;`. %! gv_attribute_list( @@ -63,16 +63,16 @@ gv_attribute_list(Context, _, Attrs1) --> % compass_pt : (n | ne | e | se | s | sw | w | nw | c | _) % ~~~ -gv_compass_pt('_') --> "_". -gv_compass_pt(c) --> "c". -gv_compass_pt(e) --> "e". -gv_compass_pt(n) --> "n". -gv_compass_pt(ne) --> "ne". -gv_compass_pt(nw) --> "nw". -gv_compass_pt(s) --> "s". -gv_compass_pt(se) --> "se". -gv_compass_pt(sw) --> "sw". -gv_compass_pt(w) --> "w". +gv_compass_pt('_') --> `_`. +gv_compass_pt(c) --> `c`. +gv_compass_pt(e) --> `e`. +gv_compass_pt(n) --> `n`. +gv_compass_pt(ne) --> `ne`. +gv_compass_pt(nw) --> `nw`. +gv_compass_pt(s) --> `s`. +gv_compass_pt(se) --> `se`. +gv_compass_pt(sw) --> `sw`. +gv_compass_pt(w) --> `w`. %! gv_edge_operator(+Directed:boolean)// . @@ -83,7 +83,7 @@ gv_compass_pt(w) --> "w". % @arg Directed Whether an edge is directed (operator `->`) or % undirected (operator `--`). -gv_edge_operator(false) --> !, "--". +gv_edge_operator(false) --> !, `--`. gv_edge_operator(true) --> arrow(right, 2). @@ -107,11 +107,11 @@ gv_edge_operator(true) --> arrow(right, 2). gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> indent(I), - gv_node_id(FromId), " ", + gv_node_id(FromId), ` `, - gv_edge_operator(Directed), " ", + gv_edge_operator(Directed), ` `, - gv_node_id(ToId), " ", + gv_node_id(ToId), ` `, % We want `colorscheme/1` from the edges and % `directionality/1` from the graph. @@ -140,11 +140,11 @@ gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> gv_generic_attributes_statement(_, _, _, []) --> [], !. gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> indent(I), - gv_kind(Kind), " ", + gv_kind(Kind), ` `, gv_attribute_list(Kind, GraphAttrs, KindAttrs), line_feed. -%! gv_graph(+Gif:compound)// +%! gv_graph(+GraphTerm:compound)// % The follow graph attributes are supported, % beyond the GraphViz attributes for graphs: % * `directed(+boolean)` @@ -176,10 +176,10 @@ gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> % @tbd Assert attributes that are generic with respect to a subgraph. % @tbd Not all vertex and edge properties can be shared it seems (e.g., label). -gv_graph(graph(VTerms,ETerms,GAttrs)) --> - gv_graph(graph(VTerms,[],ETerms,GAttrs)). +gv_graph(graph(VTerms, ETerms, GAttrs)) --> + gv_graph(graph(VTerms, [], ETerms, GAttrs)). -gv_graph(graph(VTerms,RankedVTerms,ETerms,GAttrs1)) --> +gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> { shared_attributes(VTerms, SharedVAttrs, NewVTerms), shared_attributes(ETerms, SharedEAttrs, NewETerms), @@ -194,8 +194,8 @@ gv_graph(graph(VTerms,RankedVTerms,ETerms,GAttrs1)) --> % States that this file represents a graph according to the GraphViz format. indent(I), gv_strict(Strict), - gv_graph_type(Directed), " ", - gv_id(GName), " ", + gv_graph_type(Directed), ` `, + gv_id(GName), ` `, % The body of the DOT file appears between curly braces. bracketed( @@ -240,18 +240,18 @@ gv_graph0( (NewVTerms == [], RankedVTerms == []) } -> - "" + `` ; line_feed ), % The list of GraphViz nodes. '*'(gv_node_statement(NewI, GAttrs), NewVTerms, []), - ({NewVTerms == []} -> "" ; line_feed), + ({NewVTerms == []} -> `` ; line_feed), % The ranked GraphViz nodes (displayed at the same height). '*'(gv_ranked_node_collection(NewI, GAttrs), RankedVTerms, []), - ({RankedVTerms == []} -> "" ; line_feed), + ({RankedVTerms == []} -> `` ; line_feed), { findall( @@ -281,8 +281,8 @@ gv_graph0( %! gv_graph_type(+Directed:boolean)// . % The type of graph that is represented. -gv_graph_type(false) --> "graph". -gv_graph_type(true) --> "digraph". +gv_graph_type(false) --> `graph`. +gv_graph_type(true) --> `digraph`. %! gv_id(?Atom:atom)// is det. @@ -305,9 +305,8 @@ gv_graph_type(true) --> "digraph". % This requires an XML grammar! % HTML strings (variant 4). -gv_id(Content) --> - {compound(Content)}, !, - gv_html_like_label, Content). +gv_id(Atom) --> + dcg_atom_codes(gv_html_like_label, Atom), !. % Alpha-numeric strings (variant 1). gv_id(Atom) --> {atom_codes(Atom, [H|T])}, @@ -354,19 +353,19 @@ gv_keyword(Codes):- % GraphViz has reserved keywords that cannot be used as identifiers. % GraphViz keywords are case-insensitive. -gv_keyword --> "digraph". -gv_keyword --> "edge". -gv_keyword --> "graph". -gv_keyword --> "node". -gv_keyword --> "strict". -gv_keyword --> "subgraph". +gv_keyword --> `digraph`. +gv_keyword --> `edge`. +gv_keyword --> `graph`. +gv_keyword --> `node`. +gv_keyword --> `strict`. +gv_keyword --> `subgraph`. %! gv_kind(+Kind:oneof([edge,graph,node]))// . -gv_kind(edge) --> "edge". -gv_kind(graph) --> "graph". -gv_kind(node) --> "node". +gv_kind(edge) --> `edge`. +gv_kind(graph) --> `graph`. +gv_kind(node) --> `node`. %! gv_node_id(+NodeId:atom)// . @@ -393,7 +392,7 @@ gv_node_id(Id) --> gv_node_statement(I, GraphAttrs, vertex(Id,_,VAttrs)) --> indent(I), - gv_node_id(Id), " ", + gv_node_id(Id), ` `, gv_attribute_list(node, GraphAttrs, VAttrs), line_feed. @@ -404,23 +403,23 @@ gv_port --> gv_port_angle, '?'(gv_port_location, []). gv_port --> - ":", + `:`, gv_compass_pt(_). gv_port_angle --> - "@", + `@`, gv_id(_). gv_port_location --> - ":", + `:`, gv_id(_). gv_port_location --> - ":", + `:`, bracketed( round, ( gv_id(_), - ",", + `,`, gv_id(_) ) ). @@ -437,7 +436,7 @@ gv_quoted_string([92,34|T]) --> !, gv_quoted_string(T). % Add the backslash escape character. gv_quoted_string([34|T]) --> !, - "\\\"", + `\\\"`, gv_quoted_string(T). % All other characters are allowed without escaping. gv_quoted_string([H|T]) --> @@ -456,7 +455,7 @@ gv_ranked_node_collection( % The rank attribute. {NewI is I + 1}, - indent(NewI), gv_attribute(rank=same), ";", line_feed, + indent(NewI), gv_attribute(rank=same), `;`, line_feed, '*'( gv_node_statement(NewI, GraphAttrs), @@ -476,7 +475,7 @@ gv_ranked_node_collection( % This only applies to directed graphs. gv_strict(false) --> []. -gv_strict(true) --> "strict ". +gv_strict(true) --> `strict `. diff --git a/gv_file.pl b/gv_file.pl index 00c9eb0..789bd56 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -31,7 +31,7 @@ and GraphViz output files or SVG DOM structures. :- use_module(library(option)). :- use_module(library(process)). -:- use_module(generics(codes_ext)). +:- use_module(generics(code_ext)). :- use_module(generics(db_ext)). :- use_module(os(file_ext)). :- use_module(os(run_ext)). diff --git a/gv_html.pl b/gv_html.pl index a308ac7..3f0b08b 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -1,223 +1,60 @@ :- module( gv_html, [ - gv_html_like_label//1 % +Content:compound + gv_html_like_label//1 % +Codes:list(code) ] ). -/** GraphViz: HTML-like labels - -Grammar taken from the GraphViz Web site: - -~~~{.txt} -label : text - | table -text : textitem - | text textitem -textitem : string - |
- | text - | text - | text - | text - | text - | text - | text - | text -table : [ ] rows
[
] -rows : row - | rows row - | rows
row -row : cells -cells : cell - | cells cell - | cells cell -cell : label - | -~~~ +/** GraphViz HTML @author Wouter Beek -@see http://www.graphviz.org/content/node-shapes#html -@version 2013/07, 2013/09, 2014/03-2014/06, 2014/11 +@version 2013/07, 2013/09, 2014/03-2014/06 */ -:- use_module(plDcg(dcg_abnf)). :- use_module(plDcg(dcg_content)). :- use_module(plHtml(html_dcg)). -%! gv_html_like_label(?Content:compound)// . - -gv_html_like_label(Content) --> - bracketed(angular, label(Content)). - - -%! cell(?Contents:compound)// . -% Supported attributes for TD: -% ~~~{.txt} -% ALIGN="CENTER|LEFT|RIGHT|TEXT" -% BALIGN="CENTER|LEFT|RIGHT" -% BGCOLOR="color" -% BORDER="value" -% CELLPADDING="value" -% CELLSPACING="value" -% COLOR="color" -% COLSPAN="value" -% FIXEDSIZE="FALSE|TRUE" -% GRADIENTANGLE="value" -% HEIGHT="value" -% HREF="value" -% ID="value" -% PORT="portName" -% ROWSPAN="value" -% SIDES="value" -% STYLE="value" -% TARGET="value" -% TITLE="value" -% TOOLTIP="value" -% VALIGN="MIDDLE|BOTTOM|TOP" -% WIDTH="value" -% ~~~ +%! gv_html_label(+Codes:list(code))// . % -% Supported attributes for IMG: -% ~~~{.txt} -% SCALE="FALSE|TRUE|WIDTH|HEIGHT|BOTH" -% SRC="value" -% ~~~ - -cell(td(Contents)) --> - html_element(td, [], label(Contents)). -cell(td(img)) --> - html_element(td, [], html_element(img)). - - -%! cells(?Contents:list(compound))// . - -cells([H|T]) --> - cell(H), - cells(T). -cells([H,vr|T]) --> - cell(H), - html_element(vr), - cells(T). -cells([H]) --> - cell(H). - - -%! label(?Content:compound)// . -% GraphViz HTML-like label. - -label(Content) --> - text(Content). -label(Content) --> - table(Content). - - -%! row(?Contents:compound)// . - -row(tr(Contents)) --> - html_element(tr, [], cell(Contents)). - - -%! rows(?Contents:list)// . - -rows([H|T]) --> - row(H), - rows. -rows([H,hr|T]) --> - row(H), - html_element(hr), - rows(T). -rows([H]) --> - row(H). - - -%! table(?Contents:compound)// . -% Supported attributes for TABLE: -% ~~~{.txt} -% ALIGN="CENTER|LEFT|RIGHT" -% BGCOLOR="color" -% BORDER="value" -% CELLBORDER="value" -% CELLPADDING="value" -% CELLSPACING="value" -% COLOR="color" -% COLUMNS="value" -% FIXEDSIZE="FALSE|TRUE" -% GRADIENTANGLE="value" -% HEIGHT="value" -% HREF="value" -% ID="value" -% PORT="portName" -% ROWS="value" -% SIDES="value" -% STYLE="value" -% TARGET="value" -% TITLE="value" -% TOOLTIP="value" -% VALIGN="MIDDLE|BOTTOM|TOP" -% WIDTH="value" -% ~~~ -% -% Supported attributes for FONT: -% ~~~{.txt} -% COLOR="color" -% FACE="fontname" -% POINT-SIZE="value" -% ~~~ - -table(table(Attrs,Contents)) --> - html_element(table, Attrs, rows(Contents)). -table(table(font(Contents))) --> - html_element(font, [], html_element(table, [], rows(Contents))). - - -%! text(?Contents:list)// . - -text(Contents) --> - '+'(textitem, Contents, []). - - -%! textitem(?Content)// . -% Supported attributes for BR: -% ~~~{.txt} -% ALIGN="CENTER|LEFT|RIGHT" -% ~~~ - -textitem(string(String)) --> - html_string(String). -textitem(entity(Name)) --> - html_entity(Name). -textitem(br(Attrs)) --> - html_element(br, Attrs). -textitem(Compound) --> - {var(Compound)}, !, - html_element(Name, _, text(Content)), - { - supported_html_element(Name), - Compound =.. [Name,Content] - }. -textitem(Compound) --> - { - Compound =.. [Name,Content], - supported_html_element(Name) - }, - html_element(Name, _, text(Content)). - - - -% HELPERS - -%! supported_html_element(+Name:atom) is semidet. -%! supported_html_element(-Name:atom) is multi. - -supported_html_element(b). -supported_html_element(font). -supported_html_element(i). -supported_html_element(o). -supported_html_element(s). -supported_html_element(sub). -supported_html_element(sup). -supported_html_element(u). +% @see http://www.graphviz.org/doc/info/shapes.html#html + +gv_html_label --> gv_html_text, !. +gv_html_label --> gv_html_table, !. +gv_html_label --> []. + +gv_html_like_label --> bracketed(angular, gv_html_label). + +gv_html_like_label(Content) --> bracketed(angular, html_dcg(Content)). + +gv_html_table --> html_element(table, _, gv_html_rows). +gv_html_table --> html_element(font, _, html_element(table, _, gv_html_rows)). + +gv_html_rows --> gv_html_row, gv_html_rows. +gv_html_rows --> gv_html_row, html_element(hr, _), gv_html_rows. +gv_html_rows --> gv_html_row. + +gv_html_row --> html_element(tr, _, gv_html_cells). + +gv_html_cell --> html_element(td, _, gv_html_label). +gv_html_cell --> html_element(td, _, html_element(img, _)). + +gv_html_cells --> gv_html_cell, gv_html_cells. +gv_html_cells --> gv_html_cell. +gv_html_cells --> gv_html_cell, html_element(vr, _), gv_html_cells. + +gv_html_text --> gv_html_textitem, gv_html_text. +gv_html_text --> gv_html_textitem. + +gv_html_textitem --> html_string, !. +gv_html_textitem --> html_entity, !. +gv_html_textitem --> html_element(br, _), !. +gv_html_textitem --> html_element(font, _, gv_html_text), !. +gv_html_textitem --> html_element(i, _, gv_html_text), !. +gv_html_textitem --> html_element(b, _, gv_html_text), !. +gv_html_textitem --> html_element(u, _, gv_html_text), !. +gv_html_textitem --> html_element(sub, _, gv_html_text), !. +gv_html_textitem --> html_element(sup, _, gv_html_text), !. + diff --git a/load.pl b/load.pl index 1681cd0..4b117d1 100644 --- a/load.pl +++ b/load.pl @@ -1,13 +1,12 @@ -% Load file for the plGraphViz library. +% Load file for plGraphViz. -:- dynamic(user:project/3). -:- multifile(user:project/3). - user:project(plGraphViz, 'GraphViz support for SWI-Prolog.'). +:- dynamic(user:prolog/3). +:- multifile(user:prolog/3). + user:project(plGraphViz, 'GraphViz support for SWI-Prolog.', plGraphViz). :- use_module(load_project). -:- load_project([ +:- load_project(plGraphViz, [ plc-'Prolog-Library-Collection', - plDcg, plHtml ]). diff --git a/load_project.pl b/load_project.pl index e2196b7..5599b5e 100644 --- a/load_project.pl +++ b/load_project.pl @@ -1,7 +1,8 @@ :- module( load_project, [ - load_project/1, % +ChildProjects:list(or([atom,pair(atom)])) + load_project/2, % +Parent:atom + % +ChildProjects:list(or([atom,pair(atom)])) load_subproject/2, % +ParentFileSearchPath:atom % +Child:or([atom,pair(atom)]) set_data_subdirectory/1 % +ParentDirectory:atom @@ -16,7 +17,7 @@ Generic code for loading a project: * Load the index of subprojects onto the file search path. @author Wouter Beek -@version 2014/08/20 +@version 2014/06/14 */ :- use_module(library(ansi_term)). % Colorized terminal messages. @@ -29,11 +30,11 @@ Generic code for loading a project: -load_project(ChildProjects):- - parent_alias(ParentFsp), +load_project(Parent, ChildProjects):- + parent_alias(Parent, ParentFsp), % Entry point. - source_file(load_project(_), ThisFile), + source_file(load_project(_,_), ThisFile), file_directory_name(ThisFile, ThisDir), assert(user:file_search_path(ParentFsp, ThisDir)), assert(user:file_search_path(project, ThisDir)), @@ -91,12 +92,11 @@ load_project_index(Fsp):- load_project_index(_). -%! parent_alias(-ParentFsp:atom) is det. +%! parent_alias(+Parent:atom, -ParentFsp:atom) is det. -parent_alias(ParentFsp):- - user:project(_, _, ParentFsp), !. -parent_alias(ParentFsp):- - user:project(ParentFsp, _). +parent_alias(Parent, ParentFsp):- + user:project(Parent, _, ParentFsp), !. +parent_alias(Parent, Parent). %! set_data_subdirectory(+ParentDirectory:atom) is det. @@ -108,8 +108,6 @@ set_data_subdirectory(ParentDir):- -% Messages - :- multifile(prolog:message//1). prolog:message(missing_subproject_directory(ChildFsp,ChildDir)) --> diff --git a/plDcg b/plDcg deleted file mode 160000 index 2cd7321..0000000 --- a/plDcg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2cd7321d6c8a84ca23d08670348914c4a8ca6bb0 diff --git a/plHtml b/plHtml index e3abeed..24fff7b 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit e3abeed4041392013965598145806ee33081f76f +Subproject commit 24fff7bcf90b6bc4fbf317d504be899dc1b869cb diff --git a/run.pl b/run.pl deleted file mode 100644 index 8bba736..0000000 --- a/run.pl +++ /dev/null @@ -1,9 +0,0 @@ -% Standalone execution of the plGraphViz library. - -:- if(current_prolog_flag(argv, ['--debug'|_])). - :- ensure_loaded(debug). -:- else. - :- set_prolog_flag(verbose, silent). - :- ensure_loaded(load). -:- endif. - ```

46: 正在比较变动前 3109362 和变动后 df0ab09

[back to content](#compare) ``` diff diff --git a/.gitignore b/.gitignore index b25c15b..7193a38 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ *~ +*# +*.db +data/* diff --git a/.gitmodules b/.gitmodules index a63cbff..844b1bd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "plHtml"] path = plHtml url = https://github.com/wouterbeek/plHtml.git +[submodule "plDcg"] + path = plDcg + url = https://github.com/wouterbeek/plDcg.git diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index b1d2484..7096ef9 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit b1d2484486ad4876aecc1bf70b2963b12efca341 +Subproject commit 7096ef9749edffe389df6a90d586930c8bf4df70 diff --git a/debug.pl b/debug.pl new file mode 100644 index 0000000..099cb84 --- /dev/null +++ b/debug.pl @@ -0,0 +1,7 @@ +% Loads debug tools for the plGraphViz library. + +:- [load]. + +:- use_module(debug_project). +:- debug_all_files. + diff --git a/debug_project.pl b/debug_project.pl new file mode 100644 index 0000000..ab61534 --- /dev/null +++ b/debug_project.pl @@ -0,0 +1,67 @@ +:- module( + debug_project, + [ + debug_all_files/0 + ] +). + +/** Debug project + +Generic code for debugging a project: + * Load all subdirectories and Prolog files contained in those directories. + +@author Wouter Beek +@version 2014/10/31 +*/ + +:- use_module(library(ansi_term)). +:- use_module(library(apply)). + +:- use_module(os(dir_ext)). + +% Avoid errors when using gtrace/0 in threads. +:- initialization(guitracer). + + + +debug_all_files:- + absolute_file_name(project(.), Dir, [access(read),file_type(directory)]), + directory_files( + Dir, + Files1, + [ + file_types([prolog]), + include_directories(false), + include_self(false), + recursive(true) + ] + ), + exclude(do_not_load, Files1, Files2), + maplist(use_module0, Files2). +use_module0(File):- + print_message(informational, loading_module(File)), + use_module(File). + +do_not_load(File1):- + file_base_name(File1, File2), + file_name_extension(File3, pl, File2), + do_not_load0(File3). + +do_not_load0(dcg_ascii). +do_not_load0(dcg_unicode). +do_not_load0(debug). +do_not_load0(debug_project). +do_not_load0(index). +do_not_load0(load). +do_not_load0(load_project). +do_not_load0(rfc2616_basic). +do_not_load0(run). + + + +% MESSAGES + +:- multifile(prolog:message//1). + +prolog:message(loading_module(File)) --> + ['[M] ',File]. diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 3c7863d..67d419a 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -46,10 +46,11 @@ /** GraphViz attribute types @author Wouter Beek -@version 2014/06 +@version 2014/06, 2014/11 */ :- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_ascii)). :- use_module(plDcg(dcg_cardinal)). :- use_module(plDcg(dcg_content)). @@ -97,7 +98,7 @@ gv_attr_type(viewPort). % An *addDouble* is represented by a Prolog float. addDouble(Float) --> - '?'(`+`, []), + '?'(plus_sign, []), double(Float). @@ -106,7 +107,7 @@ addDouble(Float) --> % `point(X:float,Y:float,InputOnly:boolean)`. addPoint(Point) --> - '?'(`+`, []), + '?'(plus_sign, []), point(Point). @@ -147,10 +148,10 @@ backwards_compatible(invempty). backwards_compatible(open). -bool(false) --> `false`. -bool(false) --> `no`. -bool(true) --> `true`. -bool(true) --> `yes`. +bool(false) --> "false". +bool(false) --> "no". +bool(true) --> "true". +bool(true) --> "yes". %! clusterMode(+ClusterMode:atom)// . @@ -187,7 +188,7 @@ doubleList([H|T]) --> '*'(doubleList1, T, []). doubleList1(Float) --> - `:`, + ":", double(Float). @@ -242,16 +243,16 @@ pagedir('TR'). %! point(+Point:compound)// . % A *point* is represented by a compound of the following form: -% `point(X:float,Y:float,InputOnly:boolean)`. +% `point(X:float,Y:float,Changeable:boolean)`. -point(point(X,Y,InputOnly)) --> +point(point(X,Y,Changeable)) --> float(X), - `,`, + ",", float(Y), - input_only(InputOnly). + input_changeable(Changeable). -input_only(false) --> []. -input_only(true) --> `!`. +input_changeable(false) --> "". +input_changeable(true) --> "!". pointList(Points) --> @@ -292,9 +293,9 @@ rankdir('TB'). rect(rect(LowerLeftX,LowerLeftY,UpperRightX,UpperRightY)) --> - float(LowerLeftX), `,`, - float(LowerLeftY), `,`, - float(UpperRightX), `,`, + float(LowerLeftX), ",", + float(LowerLeftY), ",", + float(UpperRightX), ",", float(UpperRightY). @@ -414,4 +415,3 @@ style(node, wedged). % @tbd viewPort - diff --git a/gv_attrs.pl b/gv_attrs.pl index 1692915..df0922a 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -2,15 +2,17 @@ gv_attrs, [ gv_attr/3 % +Context:oneof([cluster,edge,graph,node,subgraph]) - % +Attr1:nvpair - % +Attr2:nvpair + % +Attribute1:nvpair + % -Attribute2:nvpair ] ). -/** GraphViz attributes v2 +/** GraphViz: Attributes + +Support for GraphViz attributes. @author Wouter Beek -@version 2014/06 +@version 2014/06, 2014/11 */ :- use_module(library(apply)). @@ -54,24 +56,40 @@ +%! gv_attr( +%! +Context:oneof([cluster,edge,graph,node,subgraph]), +%! +Attribute1:nvpair, +%! +Attribute2:nvpair +%! ) is det. +% Uses the default value in case Value is uninstantiated. +% Otherwise, performs a typecheck and converts the given value. + gv_attr(Context, N=V, N=V):- var(V), !, gv_attr(N, UsedBy, _, V, _, _), + % Check validity of context. memberchk(Context, UsedBy). gv_attr(Context, N=V1, N=V2):- - gv_attr(N, UsedBy, Types, _, Minimum, _), + gv_attr(N2, UsedBy, Types, _, Minimum, _), + % Check validity of context. memberchk(Context, UsedBy), + % Check validity of value type. member(Type, Types), - ( - Type == style - -> - Dcg =.. [Type,Context,V1] - ; - Dcg =.. [Type,V1] + ( Type == style + -> Dcg =.. [Type,Context,V1] + ; Dcg =.. [Type,V1] ), once(dcg_phrase(Dcg, V2)), + % Check validity of Value w.r.t. minimum value -- if available. check_minimum(V1, Minimum). + + +% HELPERS + +%! check_minimum(+Value:atom, +Minimum:number) is semidet. +% Trivially succeeds if no minimum value is available for a given attribute. + check_minimum(_, ''):- !. check_minimum(V, Min1):- atom_number(Min1, Min2), diff --git a/gv_dot.pl b/gv_dot.pl index 5f33e5c..bde2962 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -1,7 +1,7 @@ :- module( gv_dot, [ - gv_graph//1 % +GraphTerm:compound + gv_graph//1 % +Gif:compound ] ). @@ -39,7 +39,7 @@ In GraphViz vertices are called 'nodes'. % We assume that the attribute has already been validated. gv_attribute(Name=Val) --> - gv_id(Name), `=`, gv_id(Val), `;`. + gv_id(Name), "=", gv_id(Val), ";". %! gv_attribute_list( @@ -63,16 +63,16 @@ gv_attribute_list(Context, _, Attrs1) --> % compass_pt : (n | ne | e | se | s | sw | w | nw | c | _) % ~~~ -gv_compass_pt('_') --> `_`. -gv_compass_pt(c) --> `c`. -gv_compass_pt(e) --> `e`. -gv_compass_pt(n) --> `n`. -gv_compass_pt(ne) --> `ne`. -gv_compass_pt(nw) --> `nw`. -gv_compass_pt(s) --> `s`. -gv_compass_pt(se) --> `se`. -gv_compass_pt(sw) --> `sw`. -gv_compass_pt(w) --> `w`. +gv_compass_pt('_') --> "_". +gv_compass_pt(c) --> "c". +gv_compass_pt(e) --> "e". +gv_compass_pt(n) --> "n". +gv_compass_pt(ne) --> "ne". +gv_compass_pt(nw) --> "nw". +gv_compass_pt(s) --> "s". +gv_compass_pt(se) --> "se". +gv_compass_pt(sw) --> "sw". +gv_compass_pt(w) --> "w". %! gv_edge_operator(+Directed:boolean)// . @@ -83,7 +83,7 @@ gv_compass_pt(w) --> `w`. % @arg Directed Whether an edge is directed (operator `->`) or % undirected (operator `--`). -gv_edge_operator(false) --> !, `--`. +gv_edge_operator(false) --> !, "--". gv_edge_operator(true) --> arrow(right, 2). @@ -107,11 +107,11 @@ gv_edge_operator(true) --> arrow(right, 2). gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> indent(I), - gv_node_id(FromId), ` `, + gv_node_id(FromId), " ", - gv_edge_operator(Directed), ` `, + gv_edge_operator(Directed), " ", - gv_node_id(ToId), ` `, + gv_node_id(ToId), " ", % We want `colorscheme/1` from the edges and % `directionality/1` from the graph. @@ -140,11 +140,11 @@ gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> gv_generic_attributes_statement(_, _, _, []) --> [], !. gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> indent(I), - gv_kind(Kind), ` `, + gv_kind(Kind), " ", gv_attribute_list(Kind, GraphAttrs, KindAttrs), line_feed. -%! gv_graph(+GraphTerm:compound)// +%! gv_graph(+Gif:compound)// % The follow graph attributes are supported, % beyond the GraphViz attributes for graphs: % * `directed(+boolean)` @@ -176,10 +176,10 @@ gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> % @tbd Assert attributes that are generic with respect to a subgraph. % @tbd Not all vertex and edge properties can be shared it seems (e.g., label). -gv_graph(graph(VTerms, ETerms, GAttrs)) --> - gv_graph(graph(VTerms, [], ETerms, GAttrs)). +gv_graph(graph(VTerms,ETerms,GAttrs)) --> + gv_graph(graph(VTerms,[],ETerms,GAttrs)). -gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> +gv_graph(graph(VTerms,RankedVTerms,ETerms,GAttrs1)) --> { shared_attributes(VTerms, SharedVAttrs, NewVTerms), shared_attributes(ETerms, SharedEAttrs, NewETerms), @@ -194,8 +194,8 @@ gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> % States that this file represents a graph according to the GraphViz format. indent(I), gv_strict(Strict), - gv_graph_type(Directed), ` `, - gv_id(GName), ` `, + gv_graph_type(Directed), " ", + gv_id(GName), " ", % The body of the DOT file appears between curly braces. bracketed( @@ -240,18 +240,18 @@ gv_graph0( (NewVTerms == [], RankedVTerms == []) } -> - `` + "" ; line_feed ), % The list of GraphViz nodes. '*'(gv_node_statement(NewI, GAttrs), NewVTerms, []), - ({NewVTerms == []} -> `` ; line_feed), + ({NewVTerms == []} -> "" ; line_feed), % The ranked GraphViz nodes (displayed at the same height). '*'(gv_ranked_node_collection(NewI, GAttrs), RankedVTerms, []), - ({RankedVTerms == []} -> `` ; line_feed), + ({RankedVTerms == []} -> "" ; line_feed), { findall( @@ -281,8 +281,8 @@ gv_graph0( %! gv_graph_type(+Directed:boolean)// . % The type of graph that is represented. -gv_graph_type(false) --> `graph`. -gv_graph_type(true) --> `digraph`. +gv_graph_type(false) --> "graph". +gv_graph_type(true) --> "digraph". %! gv_id(?Atom:atom)// is det. @@ -305,8 +305,9 @@ gv_graph_type(true) --> `digraph`. % This requires an XML grammar! % HTML strings (variant 4). -gv_id(Atom) --> - dcg_atom_codes(gv_html_like_label, Atom), !. +gv_id(Content) --> + {compound(Content)}, !, + gv_html_like_label, Content). % Alpha-numeric strings (variant 1). gv_id(Atom) --> {atom_codes(Atom, [H|T])}, @@ -353,19 +354,19 @@ gv_keyword(Codes):- % GraphViz has reserved keywords that cannot be used as identifiers. % GraphViz keywords are case-insensitive. -gv_keyword --> `digraph`. -gv_keyword --> `edge`. -gv_keyword --> `graph`. -gv_keyword --> `node`. -gv_keyword --> `strict`. -gv_keyword --> `subgraph`. +gv_keyword --> "digraph". +gv_keyword --> "edge". +gv_keyword --> "graph". +gv_keyword --> "node". +gv_keyword --> "strict". +gv_keyword --> "subgraph". %! gv_kind(+Kind:oneof([edge,graph,node]))// . -gv_kind(edge) --> `edge`. -gv_kind(graph) --> `graph`. -gv_kind(node) --> `node`. +gv_kind(edge) --> "edge". +gv_kind(graph) --> "graph". +gv_kind(node) --> "node". %! gv_node_id(+NodeId:atom)// . @@ -392,7 +393,7 @@ gv_node_id(Id) --> gv_node_statement(I, GraphAttrs, vertex(Id,_,VAttrs)) --> indent(I), - gv_node_id(Id), ` `, + gv_node_id(Id), " ", gv_attribute_list(node, GraphAttrs, VAttrs), line_feed. @@ -403,23 +404,23 @@ gv_port --> gv_port_angle, '?'(gv_port_location, []). gv_port --> - `:`, + ":", gv_compass_pt(_). gv_port_angle --> - `@`, + "@", gv_id(_). gv_port_location --> - `:`, + ":", gv_id(_). gv_port_location --> - `:`, + ":", bracketed( round, ( gv_id(_), - `,`, + ",", gv_id(_) ) ). @@ -436,7 +437,7 @@ gv_quoted_string([92,34|T]) --> !, gv_quoted_string(T). % Add the backslash escape character. gv_quoted_string([34|T]) --> !, - `\\\"`, + "\\\"", gv_quoted_string(T). % All other characters are allowed without escaping. gv_quoted_string([H|T]) --> @@ -455,7 +456,7 @@ gv_ranked_node_collection( % The rank attribute. {NewI is I + 1}, - indent(NewI), gv_attribute(rank=same), `;`, line_feed, + indent(NewI), gv_attribute(rank=same), ";", line_feed, '*'( gv_node_statement(NewI, GraphAttrs), @@ -475,7 +476,7 @@ gv_ranked_node_collection( % This only applies to directed graphs. gv_strict(false) --> []. -gv_strict(true) --> `strict `. +gv_strict(true) --> "strict ". diff --git a/gv_html.pl b/gv_html.pl index 3f0b08b..a308ac7 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -1,60 +1,223 @@ :- module( gv_html, [ - gv_html_like_label//1 % +Codes:list(code) + gv_html_like_label//1 % +Content:compound ] ). -/** GraphViz HTML +/** GraphViz: HTML-like labels + +Grammar taken from the GraphViz Web site: + +~~~{.txt} +label : text + | table +text : textitem + | text textitem +textitem : string + |
+ | text + | text + | text + | text + | text + | text + | text + | text +table : [ ] rows
[
] +rows : row + | rows row + | rows
row +row : cells +cells : cell + | cells cell + | cells cell +cell : label + | +~~~ @author Wouter Beek -@version 2013/07, 2013/09, 2014/03-2014/06 +@see http://www.graphviz.org/content/node-shapes#html +@version 2013/07, 2013/09, 2014/03-2014/06, 2014/11 */ +:- use_module(plDcg(dcg_abnf)). :- use_module(plDcg(dcg_content)). :- use_module(plHtml(html_dcg)). -%! gv_html_label(+Codes:list(code))// . +%! gv_html_like_label(?Content:compound)// . + +gv_html_like_label(Content) --> + bracketed(angular, label(Content)). + + +%! cell(?Contents:compound)// . +% Supported attributes for TD: +% ~~~{.txt} +% ALIGN="CENTER|LEFT|RIGHT|TEXT" +% BALIGN="CENTER|LEFT|RIGHT" +% BGCOLOR="color" +% BORDER="value" +% CELLPADDING="value" +% CELLSPACING="value" +% COLOR="color" +% COLSPAN="value" +% FIXEDSIZE="FALSE|TRUE" +% GRADIENTANGLE="value" +% HEIGHT="value" +% HREF="value" +% ID="value" +% PORT="portName" +% ROWSPAN="value" +% SIDES="value" +% STYLE="value" +% TARGET="value" +% TITLE="value" +% TOOLTIP="value" +% VALIGN="MIDDLE|BOTTOM|TOP" +% WIDTH="value" +% ~~~ % -% @see http://www.graphviz.org/doc/info/shapes.html#html - -gv_html_label --> gv_html_text, !. -gv_html_label --> gv_html_table, !. -gv_html_label --> []. - -gv_html_like_label --> bracketed(angular, gv_html_label). - -gv_html_like_label(Content) --> bracketed(angular, html_dcg(Content)). - -gv_html_table --> html_element(table, _, gv_html_rows). -gv_html_table --> html_element(font, _, html_element(table, _, gv_html_rows)). - -gv_html_rows --> gv_html_row, gv_html_rows. -gv_html_rows --> gv_html_row, html_element(hr, _), gv_html_rows. -gv_html_rows --> gv_html_row. - -gv_html_row --> html_element(tr, _, gv_html_cells). - -gv_html_cell --> html_element(td, _, gv_html_label). -gv_html_cell --> html_element(td, _, html_element(img, _)). - -gv_html_cells --> gv_html_cell, gv_html_cells. -gv_html_cells --> gv_html_cell. -gv_html_cells --> gv_html_cell, html_element(vr, _), gv_html_cells. - -gv_html_text --> gv_html_textitem, gv_html_text. -gv_html_text --> gv_html_textitem. - -gv_html_textitem --> html_string, !. -gv_html_textitem --> html_entity, !. -gv_html_textitem --> html_element(br, _), !. -gv_html_textitem --> html_element(font, _, gv_html_text), !. -gv_html_textitem --> html_element(i, _, gv_html_text), !. -gv_html_textitem --> html_element(b, _, gv_html_text), !. -gv_html_textitem --> html_element(u, _, gv_html_text), !. -gv_html_textitem --> html_element(sub, _, gv_html_text), !. -gv_html_textitem --> html_element(sup, _, gv_html_text), !. - +% Supported attributes for IMG: +% ~~~{.txt} +% SCALE="FALSE|TRUE|WIDTH|HEIGHT|BOTH" +% SRC="value" +% ~~~ + +cell(td(Contents)) --> + html_element(td, [], label(Contents)). +cell(td(img)) --> + html_element(td, [], html_element(img)). + + +%! cells(?Contents:list(compound))// . + +cells([H|T]) --> + cell(H), + cells(T). +cells([H,vr|T]) --> + cell(H), + html_element(vr), + cells(T). +cells([H]) --> + cell(H). + + +%! label(?Content:compound)// . +% GraphViz HTML-like label. + +label(Content) --> + text(Content). +label(Content) --> + table(Content). + + +%! row(?Contents:compound)// . + +row(tr(Contents)) --> + html_element(tr, [], cell(Contents)). + + +%! rows(?Contents:list)// . + +rows([H|T]) --> + row(H), + rows. +rows([H,hr|T]) --> + row(H), + html_element(hr), + rows(T). +rows([H]) --> + row(H). + + +%! table(?Contents:compound)// . +% Supported attributes for TABLE: +% ~~~{.txt} +% ALIGN="CENTER|LEFT|RIGHT" +% BGCOLOR="color" +% BORDER="value" +% CELLBORDER="value" +% CELLPADDING="value" +% CELLSPACING="value" +% COLOR="color" +% COLUMNS="value" +% FIXEDSIZE="FALSE|TRUE" +% GRADIENTANGLE="value" +% HEIGHT="value" +% HREF="value" +% ID="value" +% PORT="portName" +% ROWS="value" +% SIDES="value" +% STYLE="value" +% TARGET="value" +% TITLE="value" +% TOOLTIP="value" +% VALIGN="MIDDLE|BOTTOM|TOP" +% WIDTH="value" +% ~~~ +% +% Supported attributes for FONT: +% ~~~{.txt} +% COLOR="color" +% FACE="fontname" +% POINT-SIZE="value" +% ~~~ + +table(table(Attrs,Contents)) --> + html_element(table, Attrs, rows(Contents)). +table(table(font(Contents))) --> + html_element(font, [], html_element(table, [], rows(Contents))). + + +%! text(?Contents:list)// . + +text(Contents) --> + '+'(textitem, Contents, []). + + +%! textitem(?Content)// . +% Supported attributes for BR: +% ~~~{.txt} +% ALIGN="CENTER|LEFT|RIGHT" +% ~~~ + +textitem(string(String)) --> + html_string(String). +textitem(entity(Name)) --> + html_entity(Name). +textitem(br(Attrs)) --> + html_element(br, Attrs). +textitem(Compound) --> + {var(Compound)}, !, + html_element(Name, _, text(Content)), + { + supported_html_element(Name), + Compound =.. [Name,Content] + }. +textitem(Compound) --> + { + Compound =.. [Name,Content], + supported_html_element(Name) + }, + html_element(Name, _, text(Content)). + + + +% HELPERS + +%! supported_html_element(+Name:atom) is semidet. +%! supported_html_element(-Name:atom) is multi. + +supported_html_element(b). +supported_html_element(font). +supported_html_element(i). +supported_html_element(o). +supported_html_element(s). +supported_html_element(sub). +supported_html_element(sup). +supported_html_element(u). diff --git a/load.pl b/load.pl index 4b117d1..1681cd0 100644 --- a/load.pl +++ b/load.pl @@ -1,12 +1,13 @@ -% Load file for plGraphViz. +% Load file for the plGraphViz library. -:- dynamic(user:prolog/3). -:- multifile(user:prolog/3). - user:project(plGraphViz, 'GraphViz support for SWI-Prolog.', plGraphViz). +:- dynamic(user:project/3). +:- multifile(user:project/3). + user:project(plGraphViz, 'GraphViz support for SWI-Prolog.'). :- use_module(load_project). -:- load_project(plGraphViz, [ +:- load_project([ plc-'Prolog-Library-Collection', + plDcg, plHtml ]). diff --git a/load_project.pl b/load_project.pl index 5599b5e..e2196b7 100644 --- a/load_project.pl +++ b/load_project.pl @@ -1,8 +1,7 @@ :- module( load_project, [ - load_project/2, % +Parent:atom - % +ChildProjects:list(or([atom,pair(atom)])) + load_project/1, % +ChildProjects:list(or([atom,pair(atom)])) load_subproject/2, % +ParentFileSearchPath:atom % +Child:or([atom,pair(atom)]) set_data_subdirectory/1 % +ParentDirectory:atom @@ -17,7 +16,7 @@ Generic code for loading a project: * Load the index of subprojects onto the file search path. @author Wouter Beek -@version 2014/06/14 +@version 2014/08/20 */ :- use_module(library(ansi_term)). % Colorized terminal messages. @@ -30,11 +29,11 @@ Generic code for loading a project: -load_project(Parent, ChildProjects):- - parent_alias(Parent, ParentFsp), +load_project(ChildProjects):- + parent_alias(ParentFsp), % Entry point. - source_file(load_project(_,_), ThisFile), + source_file(load_project(_), ThisFile), file_directory_name(ThisFile, ThisDir), assert(user:file_search_path(ParentFsp, ThisDir)), assert(user:file_search_path(project, ThisDir)), @@ -92,11 +91,12 @@ load_project_index(Fsp):- load_project_index(_). -%! parent_alias(+Parent:atom, -ParentFsp:atom) is det. +%! parent_alias(-ParentFsp:atom) is det. -parent_alias(Parent, ParentFsp):- - user:project(Parent, _, ParentFsp), !. -parent_alias(Parent, Parent). +parent_alias(ParentFsp):- + user:project(_, _, ParentFsp), !. +parent_alias(ParentFsp):- + user:project(ParentFsp, _). %! set_data_subdirectory(+ParentDirectory:atom) is det. @@ -108,6 +108,8 @@ set_data_subdirectory(ParentDir):- +% Messages + :- multifile(prolog:message//1). prolog:message(missing_subproject_directory(ChildFsp,ChildDir)) --> diff --git a/plDcg b/plDcg new file mode 160000 index 0000000..2cd7321 --- /dev/null +++ b/plDcg @@ -0,0 +1 @@ +Subproject commit 2cd7321d6c8a84ca23d08670348914c4a8ca6bb0 diff --git a/plHtml b/plHtml index 24fff7b..e3abeed 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit 24fff7bcf90b6bc4fbf317d504be899dc1b869cb +Subproject commit e3abeed4041392013965598145806ee33081f76f diff --git a/run.pl b/run.pl new file mode 100644 index 0000000..8bba736 --- /dev/null +++ b/run.pl @@ -0,0 +1,9 @@ +% Standalone execution of the plGraphViz library. + +:- if(current_prolog_flag(argv, ['--debug'|_])). + :- ensure_loaded(debug). +:- else. + :- set_prolog_flag(verbose, silent). + :- ensure_loaded(load). +:- endif. + ```

47: 正在比较变动前 df0ab09 和变动后 73e976b

[back to content](#compare) ``` diff diff --git a/.gitmodules b/.gitmodules index 844b1bd..ba7e7a9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,12 @@ [submodule "plDcg"] path = plDcg url = https://github.com/wouterbeek/plDcg.git +[submodule "plSvg"] + path = plSvg + url = https://github.com/wouterbeek/plSvg.git +[submodule "plHttp"] + path = plHttp + url = https://github.com/wouterbeek/plHttp.git +[submodule "plUri"] + path = plUri + url = https://github.com/wouterbeek/plUri.git diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 7096ef9..130d471 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 7096ef9749edffe389df6a90d586930c8bf4df70 +Subproject commit 130d471fdafe35858114ff8f9cde3acf66380d99 diff --git a/gv_attrs.pl b/gv_attrs.pl index df0922a..f0c1c5d 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -21,6 +21,7 @@ Support for GraphViz attributes. :- use_module(generics(db_ext)). :- use_module(os(file_ext)). +:- use_module(os(file_gnu)). :- use_module(plDcg(dcg_content)). :- use_module(plDcg(dcg_generics)). diff --git a/gv_color.pl b/gv_color.pl index c5fccd4..4176444 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -17,12 +17,13 @@ */ :- use_module(library(apply)). -:- use_module(library(lists)). +:- use_module(library(lists), except([delete/3])). :- use_module(library(persistency)). :- use_module(library(xpath)). :- use_module(generics(db_ext)). :- use_module(os(file_ext)). +:- use_module(os(file_gnu)). :- use_module(plDcg(dcg_abnf)). :- use_module(plDcg(dcg_cardinal)). diff --git a/gv_dot.pl b/gv_dot.pl index bde2962..0cdc571 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -19,7 +19,7 @@ In GraphViz vertices are called 'nodes'. */ :- use_module(library(apply)). -:- use_module(library(lists)). +:- use_module(library(lists), except([delete/3])). :- use_module(library(ordsets)). :- use_module(plDcg(dcg_abnf)). diff --git a/load.pl b/load.pl index 1681cd0..67dfe22 100644 --- a/load.pl +++ b/load.pl @@ -1,13 +1,16 @@ % Load file for the plGraphViz library. -:- dynamic(user:project/3). -:- multifile(user:project/3). +:- dynamic(user:project/2). +:- multifile(user:project/2). user:project(plGraphViz, 'GraphViz support for SWI-Prolog.'). :- use_module(load_project). :- load_project([ plc-'Prolog-Library-Collection', plDcg, - plHtml + plHtml, + plHttp, + plSvg, + plUri ]). diff --git a/plDcg b/plDcg index 2cd7321..3689d78 160000 --- a/plDcg +++ b/plDcg @@ -1 +1 @@ -Subproject commit 2cd7321d6c8a84ca23d08670348914c4a8ca6bb0 +Subproject commit 3689d7838cef5ed6e8156e3c8ec39eb7b5f25b78 diff --git a/plHtml b/plHtml index e3abeed..27b7b71 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit e3abeed4041392013965598145806ee33081f76f +Subproject commit 27b7b715694daabdce26c56beb799e8d949a3ff5 diff --git a/plHttp b/plHttp new file mode 160000 index 0000000..933ba4d --- /dev/null +++ b/plHttp @@ -0,0 +1 @@ +Subproject commit 933ba4d4c906128258ef192ede6003a101b81590 diff --git a/plSvg b/plSvg new file mode 160000 index 0000000..07ba12c --- /dev/null +++ b/plSvg @@ -0,0 +1 @@ +Subproject commit 07ba12c2c373fa41e1580b8c90ee17036680fce8 diff --git a/plUri b/plUri new file mode 160000 index 0000000..cf5d6e3 --- /dev/null +++ b/plUri @@ -0,0 +1 @@ +Subproject commit cf5d6e365ed7bfad0369691554c9895441ae334d ```

48: 正在比较变动前 73e976b 和变动后 090c25d

[back to content](#compare) ``` diff diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 130d471..1630ca0 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 130d471fdafe35858114ff8f9cde3acf66380d99 +Subproject commit 1630ca0c9622cbe3f9561de21d5e851baa333ca9 diff --git a/plDcg b/plDcg index 3689d78..df62444 160000 --- a/plDcg +++ b/plDcg @@ -1 +1 @@ -Subproject commit 3689d7838cef5ed6e8156e3c8ec39eb7b5f25b78 +Subproject commit df62444ffa0b58de4c7faf9b5630e58a18ee18ec diff --git a/plHtml b/plHtml index 27b7b71..429b725 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit 27b7b715694daabdce26c56beb799e8d949a3ff5 +Subproject commit 429b7256680588790310c3b6acf81da31d3fc3d2 diff --git a/plHttp b/plHttp index 933ba4d..faa8215 160000 --- a/plHttp +++ b/plHttp @@ -1 +1 @@ -Subproject commit 933ba4d4c906128258ef192ede6003a101b81590 +Subproject commit faa821576b6ab706060f6e8eab2a8a9210b8c842 diff --git a/plUri b/plUri index cf5d6e3..68dba15 160000 --- a/plUri +++ b/plUri @@ -1 +1 @@ -Subproject commit cf5d6e365ed7bfad0369691554c9895441ae334d +Subproject commit 68dba15c5cf7bb309165d2c9439c02bd22cfba95 ```

49: 正在比较变动前 090c25d 和变动后 daed8bf

[back to content](#compare) ``` diff diff --git a/.gitmodules b/.gitmodules index ba7e7a9..844b1bd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,12 +7,3 @@ [submodule "plDcg"] path = plDcg url = https://github.com/wouterbeek/plDcg.git -[submodule "plSvg"] - path = plSvg - url = https://github.com/wouterbeek/plSvg.git -[submodule "plHttp"] - path = plHttp - url = https://github.com/wouterbeek/plHttp.git -[submodule "plUri"] - path = plUri - url = https://github.com/wouterbeek/plUri.git diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 1630ca0..18fe981 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 1630ca0c9622cbe3f9561de21d5e851baa333ca9 +Subproject commit 18fe981c492d67be3670406e51602c23b97a6052 diff --git a/load_project.pl b/load_project.pl index e2196b7..3f0ebef 100644 --- a/load_project.pl +++ b/load_project.pl @@ -16,11 +16,12 @@ Generic code for loading a project: * Load the index of subprojects onto the file search path. @author Wouter Beek -@version 2014/08/20 +@version 2014/11/10 */ :- use_module(library(ansi_term)). % Colorized terminal messages. :- use_module(library(apply)). +:- use_module(library(pldoc)). :- dynamic(user:project/2). :- multifile(user:project/2). @@ -30,6 +31,8 @@ Generic code for loading a project: load_project(ChildProjects):- + doc_server(9999), + parent_alias(ParentFsp), % Entry point. diff --git a/plDcg b/plDcg index df62444..19020db 160000 --- a/plDcg +++ b/plDcg @@ -1 +1 @@ -Subproject commit df62444ffa0b58de4c7faf9b5630e58a18ee18ec +Subproject commit 19020db8046bf96d54938e6ba02d65dc2b6f8b50 diff --git a/plHtml b/plHtml index 429b725..2d6bb5a 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit 429b7256680588790310c3b6acf81da31d3fc3d2 +Subproject commit 2d6bb5a083f184570042eee68ddb8780caddb246 diff --git a/plHttp b/plHttp deleted file mode 160000 index faa8215..0000000 --- a/plHttp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit faa821576b6ab706060f6e8eab2a8a9210b8c842 diff --git a/plSvg b/plSvg deleted file mode 160000 index 07ba12c..0000000 --- a/plSvg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 07ba12c2c373fa41e1580b8c90ee17036680fce8 diff --git a/plUri b/plUri deleted file mode 160000 index 68dba15..0000000 --- a/plUri +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 68dba15c5cf7bb309165d2c9439c02bd22cfba95 ```

50: 正在比较变动前 daed8bf 和变动后 528b9af

[back to content](#compare) ``` diff diff --git a/.gitmodules b/.gitmodules index 844b1bd..6c22435 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "plDcg"] path = plDcg url = https://github.com/wouterbeek/plDcg.git +[submodule "plUri"] + path = plUri + url = https://github.com/wouterbeek/plUri.git diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 18fe981..ec4c91a 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 18fe981c492d67be3670406e51602c23b97a6052 +Subproject commit ec4c91a00704c0c8d9b4ed747cb9b1648355559b diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 67d419a..30761bb 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -51,6 +51,7 @@ :- use_module(plDcg(dcg_abnf)). :- use_module(plDcg(dcg_ascii)). +:- use_module(plDcg(dcg_atom)). :- use_module(plDcg(dcg_cardinal)). :- use_module(plDcg(dcg_content)). diff --git a/gv_attrs.pl b/gv_attrs.pl index f0c1c5d..649ef9c 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -23,6 +23,7 @@ Support for GraphViz attributes. :- use_module(os(file_ext)). :- use_module(os(file_gnu)). +:- use_module(plDcg(dcg_atom)). :- use_module(plDcg(dcg_content)). :- use_module(plDcg(dcg_generics)). @@ -71,7 +72,7 @@ gv_attr(Context, N=V, N=V):- % Check validity of context. memberchk(Context, UsedBy). gv_attr(Context, N=V1, N=V2):- - gv_attr(N2, UsedBy, Types, _, Minimum, _), + gv_attr(N, UsedBy, Types, _, Minimum, _), % Check validity of context. memberchk(Context, UsedBy), % Check validity of value type. diff --git a/gv_color.pl b/gv_color.pl index 4176444..61d26df 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -26,6 +26,7 @@ :- use_module(os(file_gnu)). :- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_atom)). :- use_module(plDcg(dcg_cardinal)). :- use_module(plDcg(dcg_content)). :- use_module(plDcg_rfc(rfc2616_basic)). diff --git a/gv_dot.pl b/gv_dot.pl index 0cdc571..e67c469 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -23,10 +23,13 @@ In GraphViz vertices are called 'nodes'. :- use_module(library(ordsets)). :- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_arrow)). :- use_module(plDcg(dcg_ascii)). +:- use_module(plDcg(dcg_bracket)). :- use_module(plDcg(dcg_content)). :- use_module(plDcg(dcg_generics)). :- use_module(plDcg(dcg_meta)). +:- use_module(plDcg(dcg_quote)). :- use_module(plGraphViz(gv_attrs)). :- use_module(plGraphViz(gv_html)). @@ -47,10 +50,10 @@ gv_attribute(Name=Val) --> %! +GraphAttributes:list(nvpair), %! +Attributes:list(nvpair) %! )// . -% ~~~{.abnf} +% ```abnf % attr_list = "[" [a_list] "]" [attr_list] % a_list = ID "=" ID [","] [a_list] -% ~~~ +% ``` % Attributes occur between square brackets. gv_attribute_list(Context, _, Attrs1) --> @@ -59,9 +62,9 @@ gv_attribute_list(Context, _, Attrs1) --> %! gv_compass_pt(+Direction:oneof(['_',c,e,n,ne,nw,s,se,sw,w]))// . -% ~~~ +% ``` % compass_pt : (n | ne | e | se | s | sw | w | nw | c | _) -% ~~~ +% ``` gv_compass_pt('_') --> "_". gv_compass_pt(c) --> "c". @@ -133,9 +136,9 @@ gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> % @arg GraphAttributes A list of name-value pairs. % @arg CategoryAttributes A list of name-value pairs. % -% ~~~ +% ``` % attr_stmt = (graph / node / edge) attr_list -% ~~~ +% ``` gv_generic_attributes_statement(_, _, _, []) --> [], !. gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> @@ -156,19 +159,19 @@ gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> % they are ignored in the input file. % Only in combinattion with directionality `directed`. % -% ~~~{.abnf} +% ```abnf % graph = ["strict"] ("graph" / "digraph") [ID] "{" stmt_list "}" -% ~~~ +% ``` % % `GraphTerm` is a compound term of the following form: -% ~~~{.pl} +% ```prolog % graph(VertexTerms,RankedVertexTerms,EdgeTerms,GraphAttributes) -% ~~~ +% ``` % % `RankedVertexTerms` is a list of compound terms of the following form: -% ~~~{.pl} +% ```prolog % rank(RankNode,ContentNodes) -% ~~~ +% ``` % % @tbd Add support for subgraphs (arbitrary nesting). % @tbd Add support for escape strings: @@ -307,7 +310,7 @@ gv_graph_type(true) --> "digraph". % HTML strings (variant 4). gv_id(Content) --> {compound(Content)}, !, - gv_html_like_label, Content). + gv_html_like_label(Content). % Alpha-numeric strings (variant 1). gv_id(Atom) --> {atom_codes(Atom, [H|T])}, @@ -331,14 +334,16 @@ gv_id(Atom) --> % Double-quoted strings (variant 3). % The quotes are not in the given atom. They are written anyway. gv_id(Atom) --> - quoted(double_quote, dcg_atom_codes(gv_quoted_string, Atom)), !. + quoted(dcg_atom_codes(gv_quoted_string, Atom)), !. -gv_id_first(X) --> ascii_letter(X). +gv_id_first(X) --> letter(X). gv_id_first(X) --> underscore(X). gv_id_rest([]) --> []. gv_id_rest([H|T]) --> - (ascii_alpha_numeric(H) ; underscore(H)), + ( alpha_numeric(H) + ; underscore(H) + ), gv_id_rest(T). @@ -463,7 +468,7 @@ gv_ranked_node_collection( [Rank_V_Term|Content_V_Terms], [] ), - + % We want to indent the closing curly brace. indent(I) )), diff --git a/gv_file.pl b/gv_file.pl index 789bd56..704e2d4 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -9,9 +9,6 @@ gif_to_gv_file/3, % +GraphInterchangeFormat:compound % ?ToFile:atom % +Options:list(nvpair) - gif_to_svg_dom/3, % +GraphInterchangeFormat:compound - % -SvgDom:list(compound) - % +Options:list(nvpair) open_dot/1 % +File:file ] ). @@ -35,7 +32,6 @@ and GraphViz output files or SVG DOM structures. :- use_module(generics(db_ext)). :- use_module(os(file_ext)). :- use_module(os(run_ext)). -:- use_module(svg(svg_file)). :- use_module(plGraphViz(gv_dot)). @@ -175,20 +171,6 @@ gif_to_gv_file(Gif, ToFile, Options):- codes_to_gv_file(Codes, ToFile, Options). -%! gif_to_svg_dom( -%! +GraphInterchangeFormat:compound, -%! -SvgDom:list(compound), -%! +Options:list(nvpair) -%! ) is det. - -gif_to_svg_dom(Gif, SvgDom, Options1):- - % Make sure the file type of the output file is SvgDom. - merge_options([to_file_type=svg], Options1, Options2), - gif_to_gv_file(Gif, ToFile, Options2), - file_to_svg(ToFile, SvgDom), - delete_file(ToFile). - - %! open_dot(+File:atom) is det. % Opens the given DOT file. % diff --git a/gv_html.pl b/gv_html.pl index a308ac7..08306f0 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -9,32 +9,32 @@ Grammar taken from the GraphViz Web site: -~~~{.txt} -label : text - | table -text : textitem - | text textitem -textitem : string - |
- | text - | text - | text - | text - | text - | text - | text - | text -table : [ ] rows
[
] -rows : row - | rows row - | rows
row -row : cells -cells : cell - | cells cell - | cells cell -cell : label - | -~~~ +``` +label : text + | table +text : textitem + | text textitem +textitem : string + |
+ | text + | text + | text + | text + | text + | text + | text + | text +table : [ ] rows
[
] +rows : row + | rows row + | rows
row +row: cells +cells : cell + | cells cell + | cells cell +cell: label + | +``` @author Wouter Beek @see http://www.graphviz.org/content/node-shapes#html @@ -42,6 +42,7 @@ cell : label */ :- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_bracket)). :- use_module(plDcg(dcg_content)). :- use_module(plHtml(html_dcg)). @@ -56,7 +57,7 @@ gv_html_like_label(Content) --> %! cell(?Contents:compound)// . % Supported attributes for TD: -% ~~~{.txt} +% ``` % ALIGN="CENTER|LEFT|RIGHT|TEXT" % BALIGN="CENTER|LEFT|RIGHT" % BGCOLOR="color" @@ -79,13 +80,13 @@ gv_html_like_label(Content) --> % TOOLTIP="value" % VALIGN="MIDDLE|BOTTOM|TOP" % WIDTH="value" -% ~~~ +% ``` % % Supported attributes for IMG: -% ~~~{.txt} +% ``` % SCALE="FALSE|TRUE|WIDTH|HEIGHT|BOTH" % SRC="value" -% ~~~ +% ``` cell(td(Contents)) --> html_element(td, [], label(Contents)). @@ -125,7 +126,7 @@ row(tr(Contents)) --> rows([H|T]) --> row(H), - rows. + rows(T). rows([H,hr|T]) --> row(H), html_element(hr), @@ -136,7 +137,7 @@ rows([H]) --> %! table(?Contents:compound)// . % Supported attributes for TABLE: -% ~~~{.txt} +% ``` % ALIGN="CENTER|LEFT|RIGHT" % BGCOLOR="color" % BORDER="value" @@ -159,14 +160,14 @@ rows([H]) --> % TOOLTIP="value" % VALIGN="MIDDLE|BOTTOM|TOP" % WIDTH="value" -% ~~~ +% ``` % % Supported attributes for FONT: -% ~~~{.txt} +% ``` % COLOR="color" % FACE="fontname" % POINT-SIZE="value" -% ~~~ +% ``` table(table(Attrs,Contents)) --> html_element(table, Attrs, rows(Contents)). @@ -182,9 +183,9 @@ text(Contents) --> %! textitem(?Content)// . % Supported attributes for BR: -% ~~~{.txt} +% ``` % ALIGN="CENTER|LEFT|RIGHT" -% ~~~ +% ``` textitem(string(String)) --> html_string(String). diff --git a/gv_numeral.pl b/gv_numeral.pl index 7870eb1..c115372 100644 --- a/gv_numeral.pl +++ b/gv_numeral.pl @@ -14,59 +14,67 @@ :- use_module(math(math_ext)). :- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_ascii)). :- use_module(plDcg(dcg_cardinal)). %! gv_numeral(?Value:number)// . -% ~~~{.bnf} +% +% # Syntax +% +% ```bnf % ('-')? ( '.' [0-9]+ | [0-9]+ ( '.' [0-9]* )? ) -% ~~~ +% ``` +% +% ## Generation +% +% In the generative case, three notations are allowed (also see below): +% 1. (non-zero integer-part) +% 2. (decimal-separator) (non-zero fractional) +% 3. (non-zero integer-part) (decimal-separator) (non-zero fractional) +% +% The following notations are explicitly excluded due to verbosity: +% - (non-zero integer-part) (decimal-separator) +% - (non-zero integer-part) (decimal-separator) (zero fractional) +% - (zero integer-part) (decimal-separator) (non-zero fractional) +% +% The following notations are also excluded, but since they violate +% well-formedness: +% - (non-zero integer-part) (non-zero fractional) +% - (decimal-separator) gv_numeral(N) --> - {nonvar(N)}, - {number_sign_parts(N, Sign, Abs)}, - ({Sign =:= -1} -> `-` ; ``), - gv_numeral_abs(Abs). + {var(N)}, !, + sign(Sign), + ( ".", + '+'(decimal_digit, Fractional, [convert1(weights_decimal)]), + {IntegerPart = 0} + ; '+'(decimal_digit, IntegerPart, [convert1(weights_decimal)]), + ( ".", + '*'(decimal_digit, Fractional, [convert1(weights_decimal)]) + ; {Fractional = 0} + ) + ), + { number_integer_parts(UnsignedN, IntegerPart, Fractional), + N is copysign(UnsignedN, Sign) + }. gv_numeral(N) --> - {var(N)}, - 'sign?'(Sign), - gv_numeral_abs(Abs), - {number_sign_parts(N, Sign, Abs)}. - - -gv_numeral_abs(N) --> - {nonvar(N)}, - {number_integer_parts(N, N1, N2)}, - ( - {N2 =:= 0} - -> - integer(N1) - ; - {N1 =:= 0} - -> - `.`, - integer(N2) - ; - integer(N1), - '?'((`.`, 'integer?'(N2)), []) + {number_sign_parts(N, Sign, UnsignedN)}, + sign(Sign), + {number_integer_parts(UnsignedN, IntegerPart, Fractional)}, + ( % [1] The fractional is zero, so only write the integer part + % and do not write the decimal separator. + {Fractional =:= 0} + -> integer(IntegerPart) + ; % [2] The integer part is zero, so only write the fractional part, + % preceded by the decimal separator. + {IntegerPart =:= 0} + -> ".", + integer(Fractional) + ; % [3] Both the integer part and the fractional are non-zero, + % so write both of them, with the decimal separator in-between. + integer(IntegerPart), + ".", + integer(Fractional) ). -gv_numeral_abs(N) --> - {var(N)}, - ( - `.`, - integer(N2) - -> - {N1 = 0} - ; - integer(N1), - ( - `.` - -> - 'integer?'(N2) - ; - {N2 = 0} - ) - ), - {number_integer_parts(N, N1, N2)}. - diff --git a/load.pl b/load.pl index 67dfe22..5cec32c 100644 --- a/load.pl +++ b/load.pl @@ -9,8 +9,6 @@ plc-'Prolog-Library-Collection', plDcg, plHtml, - plHttp, - plSvg, plUri ]). diff --git a/plDcg b/plDcg index 19020db..96e2615 160000 --- a/plDcg +++ b/plDcg @@ -1 +1 @@ -Subproject commit 19020db8046bf96d54938e6ba02d65dc2b6f8b50 +Subproject commit 96e261537773270a43d1ff4346273820282f21fb diff --git a/plHtml b/plHtml index 2d6bb5a..a7b736f 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit 2d6bb5a083f184570042eee68ddb8780caddb246 +Subproject commit a7b736fdf7c435f825193bbc54500a302b0bc4b1 diff --git a/plUri b/plUri new file mode 160000 index 0000000..59f582c --- /dev/null +++ b/plUri @@ -0,0 +1 @@ +Subproject commit 59f582c68cebc221f964ccb9805a869d05cb7856 ```

51: 正在比较变动前 528b9af 和变动后 e594ae6

[back to content](#compare) ``` diff diff --git a/gv_color.pl b/gv_color.pl index 61d26df..da34c1a 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -13,7 +13,7 @@ @author Wouter Beek @tbd Color value `transparent` is only available in the output formats ps, svg, fig, vmrl, and the bitmap formats. -@version 2014/06, 2014/10 +@version 2014/06, 2014/10-2014/11 */ :- use_module(library(apply)). @@ -51,10 +51,10 @@ % 3. `hsv(Hue:between(0.0,1.0),Saturation:between(0.0,1.0),Value:between(0.0,1.0))` color(rgb(Red,Green,Blue)) --> !, - `#`, + "#", '#'(3, hex_color, [Red,Green,Blue], []). color(rgbs(Red,Green,Blue,Alpha)) --> !, - `#`, + "#", '#'(4, hex_color, [Red,Green,Blue,Alpha], []). color(hsv(Hue,Saturation,Value)) --> !, '#'(3, hsv_color, [Hue,Saturation,Value], []). @@ -82,7 +82,7 @@ wc(Color-Float) --> '?'(wc_weight(Float), []). wc_weight(Float) --> - `;`, + ";", float(Float). ```

52: 正在比较变动前 e594ae6 和变动后 bbefbf7

[back to content](#compare) ``` diff diff --git a/gv_color.pl b/gv_color.pl index da34c1a..74c9060 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -25,11 +25,11 @@ :- use_module(os(file_ext)). :- use_module(os(file_gnu)). +:- use_module(plDcg(abnf_core_rules)). :- use_module(plDcg(dcg_abnf)). :- use_module(plDcg(dcg_atom)). :- use_module(plDcg(dcg_cardinal)). :- use_module(plDcg(dcg_content)). -:- use_module(plDcg_rfc(rfc2616_basic)). :- use_module(plHtml(html)). :- use_module(plHtml(html_table)). ```

53: 正在比较变动前 bbefbf7 和变动后 0cc5421

[back to content](#compare) ``` diff diff --git a/.gitignore b/.gitignore index 7193a38..b25c15b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1 @@ *~ -*# -*.db -data/* diff --git a/.gitmodules b/.gitmodules index 6c22435..a63cbff 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,9 +4,3 @@ [submodule "plHtml"] path = plHtml url = https://github.com/wouterbeek/plHtml.git -[submodule "plDcg"] - path = plDcg - url = https://github.com/wouterbeek/plDcg.git -[submodule "plUri"] - path = plUri - url = https://github.com/wouterbeek/plUri.git diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index ec4c91a..d7d21ad 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit ec4c91a00704c0c8d9b4ed747cb9b1648355559b +Subproject commit d7d21ad4d6d7cec98d8b0122f5303e691998f512 diff --git a/README.md b/README.md new file mode 100644 index 0000000..3c9e9cf --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +plGraphViz +========== + +Export graphs represented as Prolog terms to + [GraphViz](http://www.graphviz.org/). + +Author: [Wouter Beek](http://www.wouterbeek.com) + diff --git a/debug.pl b/debug.pl index 099cb84..d7339b9 100644 --- a/debug.pl +++ b/debug.pl @@ -1,7 +1,9 @@ -% Loads debug tools for the plGraphViz library. +% Debug file for library plGraphViz. + +:- style_check(+charset). +%:- style_check(+var_branches). :- [load]. :- use_module(debug_project). :- debug_all_files. - diff --git a/debug_project.pl b/debug_project.pl index ab61534..17195c1 100644 --- a/debug_project.pl +++ b/debug_project.pl @@ -11,7 +11,7 @@ Generic code for debugging a project: * Load all subdirectories and Prolog files contained in those directories. @author Wouter Beek -@version 2014/10/31 +@version 2014/11/19 */ :- use_module(library(ansi_term)). @@ -54,7 +54,6 @@ do_not_load0(debug_project). do_not_load0(index). do_not_load0(load). do_not_load0(load_project). -do_not_load0(rfc2616_basic). do_not_load0(run). diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 30761bb..3c7863d 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -46,12 +46,10 @@ /** GraphViz attribute types @author Wouter Beek -@version 2014/06, 2014/11 +@version 2014/06 */ :- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_ascii)). -:- use_module(plDcg(dcg_atom)). :- use_module(plDcg(dcg_cardinal)). :- use_module(plDcg(dcg_content)). @@ -99,7 +97,7 @@ gv_attr_type(viewPort). % An *addDouble* is represented by a Prolog float. addDouble(Float) --> - '?'(plus_sign, []), + '?'(`+`, []), double(Float). @@ -108,7 +106,7 @@ addDouble(Float) --> % `point(X:float,Y:float,InputOnly:boolean)`. addPoint(Point) --> - '?'(plus_sign, []), + '?'(`+`, []), point(Point). @@ -149,10 +147,10 @@ backwards_compatible(invempty). backwards_compatible(open). -bool(false) --> "false". -bool(false) --> "no". -bool(true) --> "true". -bool(true) --> "yes". +bool(false) --> `false`. +bool(false) --> `no`. +bool(true) --> `true`. +bool(true) --> `yes`. %! clusterMode(+ClusterMode:atom)// . @@ -189,7 +187,7 @@ doubleList([H|T]) --> '*'(doubleList1, T, []). doubleList1(Float) --> - ":", + `:`, double(Float). @@ -244,16 +242,16 @@ pagedir('TR'). %! point(+Point:compound)// . % A *point* is represented by a compound of the following form: -% `point(X:float,Y:float,Changeable:boolean)`. +% `point(X:float,Y:float,InputOnly:boolean)`. -point(point(X,Y,Changeable)) --> +point(point(X,Y,InputOnly)) --> float(X), - ",", + `,`, float(Y), - input_changeable(Changeable). + input_only(InputOnly). -input_changeable(false) --> "". -input_changeable(true) --> "!". +input_only(false) --> []. +input_only(true) --> `!`. pointList(Points) --> @@ -294,9 +292,9 @@ rankdir('TB'). rect(rect(LowerLeftX,LowerLeftY,UpperRightX,UpperRightY)) --> - float(LowerLeftX), ",", - float(LowerLeftY), ",", - float(UpperRightX), ",", + float(LowerLeftX), `,`, + float(LowerLeftY), `,`, + float(UpperRightX), `,`, float(UpperRightY). @@ -416,3 +414,4 @@ style(node, wedged). % @tbd viewPort + diff --git a/gv_attrs.pl b/gv_attrs.pl index 649ef9c..faf496c 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -2,17 +2,15 @@ gv_attrs, [ gv_attr/3 % +Context:oneof([cluster,edge,graph,node,subgraph]) - % +Attribute1:nvpair - % -Attribute2:nvpair + % +Attr1:nvpair + % +Attr2:nvpair ] ). -/** GraphViz: Attributes - -Support for GraphViz attributes. +/** GraphViz attributes v2 @author Wouter Beek -@version 2014/06, 2014/11 +@version 2014/06 */ :- use_module(library(apply)). @@ -21,11 +19,9 @@ Support for GraphViz attributes. :- use_module(generics(db_ext)). :- use_module(os(file_ext)). -:- use_module(os(file_gnu)). -:- use_module(plDcg(dcg_atom)). :- use_module(plDcg(dcg_content)). -:- use_module(plDcg(dcg_generics)). +:- use_module(plDcg(dcg_generic)). :- use_module(plHtml(html)). :- use_module(plHtml(html_table)). @@ -58,40 +54,24 @@ Support for GraphViz attributes. -%! gv_attr( -%! +Context:oneof([cluster,edge,graph,node,subgraph]), -%! +Attribute1:nvpair, -%! +Attribute2:nvpair -%! ) is det. -% Uses the default value in case Value is uninstantiated. -% Otherwise, performs a typecheck and converts the given value. - gv_attr(Context, N=V, N=V):- var(V), !, gv_attr(N, UsedBy, _, V, _, _), - % Check validity of context. memberchk(Context, UsedBy). gv_attr(Context, N=V1, N=V2):- gv_attr(N, UsedBy, Types, _, Minimum, _), - % Check validity of context. memberchk(Context, UsedBy), - % Check validity of value type. member(Type, Types), - ( Type == style - -> Dcg =.. [Type,Context,V1] - ; Dcg =.. [Type,V1] + ( + Type == style + -> + Dcg =.. [Type,Context,V1] + ; + Dcg =.. [Type,V1] ), once(dcg_phrase(Dcg, V2)), - % Check validity of Value w.r.t. minimum value -- if available. check_minimum(V1, Minimum). - - -% HELPERS - -%! check_minimum(+Value:atom, +Minimum:number) is semidet. -% Trivially succeeds if no minimum value is available for a given attribute. - check_minimum(_, ''):- !. check_minimum(V, Min1):- atom_number(Min1, Min2), diff --git a/gv_color.pl b/gv_color.pl index 74c9060..cb0cf8c 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -13,27 +13,27 @@ @author Wouter Beek @tbd Color value `transparent` is only available in the output formats ps, svg, fig, vmrl, and the bitmap formats. -@version 2014/06, 2014/10-2014/11 +@version 2014/06 */ :- use_module(library(apply)). -:- use_module(library(lists), except([delete/3])). +:- use_module(library(lists)). :- use_module(library(persistency)). :- use_module(library(xpath)). :- use_module(generics(db_ext)). :- use_module(os(file_ext)). -:- use_module(os(file_gnu)). -:- use_module(plDcg(abnf_core_rules)). :- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_atom)). :- use_module(plDcg(dcg_cardinal)). :- use_module(plDcg(dcg_content)). +:- use_module(plDcg_rfc(rfc2616_basic)). :- use_module(plHtml(html)). :- use_module(plHtml(html_table)). +:- use_module(plSparql_parse(sparql_char)). + :- db_add_novel(user:prolog_file_type(log, logging)). %! gv_color(?Colorscheme:oneof([svg,x11]), ?Color:atom) is nondet. @@ -51,10 +51,10 @@ % 3. `hsv(Hue:between(0.0,1.0),Saturation:between(0.0,1.0),Value:between(0.0,1.0))` color(rgb(Red,Green,Blue)) --> !, - "#", + `#`, '#'(3, hex_color, [Red,Green,Blue], []). color(rgbs(Red,Green,Blue,Alpha)) --> !, - "#", + `#`, '#'(4, hex_color, [Red,Green,Blue,Alpha], []). color(hsv(Hue,Saturation,Value)) --> !, '#'(3, hsv_color, [Hue,Saturation,Value], []). @@ -82,7 +82,7 @@ wc(Color-Float) --> '?'(wc_weight(Float), []). wc_weight(Float) --> - ";", + `;`, float(Float). @@ -142,13 +142,3 @@ gv_color_update(_):- gv_color_url('http://www.graphviz.org/doc/info/colors.html'). - -%! safe_db_attach(+File:atom) is det. - -safe_db_attach(File):- - exists_file(File), !, - db_attach(File, []). -safe_db_attach(File):- - touch_file(File), - safe_db_attach(File). - diff --git a/gv_dot.pl b/gv_dot.pl index e67c469..accd5bd 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -1,7 +1,7 @@ :- module( gv_dot, [ - gv_graph//1 % +Gif:compound + gv_graph//1 % +GraphTerm:compound ] ). @@ -19,17 +19,14 @@ In GraphViz vertices are called 'nodes'. */ :- use_module(library(apply)). -:- use_module(library(lists), except([delete/3])). +:- use_module(library(lists)). :- use_module(library(ordsets)). :- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_arrow)). :- use_module(plDcg(dcg_ascii)). -:- use_module(plDcg(dcg_bracket)). :- use_module(plDcg(dcg_content)). -:- use_module(plDcg(dcg_generics)). +:- use_module(plDcg(dcg_generic)). :- use_module(plDcg(dcg_meta)). -:- use_module(plDcg(dcg_quote)). :- use_module(plGraphViz(gv_attrs)). :- use_module(plGraphViz(gv_html)). @@ -42,7 +39,7 @@ In GraphViz vertices are called 'nodes'. % We assume that the attribute has already been validated. gv_attribute(Name=Val) --> - gv_id(Name), "=", gv_id(Val), ";". + gv_id(Name), `=`, gv_id(Val), `;`. %! gv_attribute_list( @@ -50,10 +47,10 @@ gv_attribute(Name=Val) --> %! +GraphAttributes:list(nvpair), %! +Attributes:list(nvpair) %! )// . -% ```abnf +% ~~~{.abnf} % attr_list = "[" [a_list] "]" [attr_list] % a_list = ID "=" ID [","] [a_list] -% ``` +% ~~~ % Attributes occur between square brackets. gv_attribute_list(Context, _, Attrs1) --> @@ -62,20 +59,20 @@ gv_attribute_list(Context, _, Attrs1) --> %! gv_compass_pt(+Direction:oneof(['_',c,e,n,ne,nw,s,se,sw,w]))// . -% ``` +% ~~~ % compass_pt : (n | ne | e | se | s | sw | w | nw | c | _) -% ``` +% ~~~ -gv_compass_pt('_') --> "_". -gv_compass_pt(c) --> "c". -gv_compass_pt(e) --> "e". -gv_compass_pt(n) --> "n". -gv_compass_pt(ne) --> "ne". -gv_compass_pt(nw) --> "nw". -gv_compass_pt(s) --> "s". -gv_compass_pt(se) --> "se". -gv_compass_pt(sw) --> "sw". -gv_compass_pt(w) --> "w". +gv_compass_pt('_') --> `_`. +gv_compass_pt(c) --> `c`. +gv_compass_pt(e) --> `e`. +gv_compass_pt(n) --> `n`. +gv_compass_pt(ne) --> `ne`. +gv_compass_pt(nw) --> `nw`. +gv_compass_pt(s) --> `s`. +gv_compass_pt(se) --> `se`. +gv_compass_pt(sw) --> `sw`. +gv_compass_pt(w) --> `w`. %! gv_edge_operator(+Directed:boolean)// . @@ -86,7 +83,7 @@ gv_compass_pt(w) --> "w". % @arg Directed Whether an edge is directed (operator `->`) or % undirected (operator `--`). -gv_edge_operator(false) --> !, "--". +gv_edge_operator(false) --> !, `--`. gv_edge_operator(true) --> arrow(right, 2). @@ -110,11 +107,11 @@ gv_edge_operator(true) --> arrow(right, 2). gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> indent(I), - gv_node_id(FromId), " ", + gv_node_id(FromId), ` `, - gv_edge_operator(Directed), " ", + gv_edge_operator(Directed), ` `, - gv_node_id(ToId), " ", + gv_node_id(ToId), ` `, % We want `colorscheme/1` from the edges and % `directionality/1` from the graph. @@ -136,18 +133,18 @@ gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> % @arg GraphAttributes A list of name-value pairs. % @arg CategoryAttributes A list of name-value pairs. % -% ``` +% ~~~ % attr_stmt = (graph / node / edge) attr_list -% ``` +% ~~~ gv_generic_attributes_statement(_, _, _, []) --> [], !. gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> indent(I), - gv_kind(Kind), " ", + gv_kind(Kind), ` `, gv_attribute_list(Kind, GraphAttrs, KindAttrs), line_feed. -%! gv_graph(+Gif:compound)// +%! gv_graph(+GraphTerm:compound)// % The follow graph attributes are supported, % beyond the GraphViz attributes for graphs: % * `directed(+boolean)` @@ -159,19 +156,19 @@ gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> % they are ignored in the input file. % Only in combinattion with directionality `directed`. % -% ```abnf +% ~~~{.abnf} % graph = ["strict"] ("graph" / "digraph") [ID] "{" stmt_list "}" -% ``` +% ~~~ % % `GraphTerm` is a compound term of the following form: -% ```prolog +% ~~~{.pl} % graph(VertexTerms,RankedVertexTerms,EdgeTerms,GraphAttributes) -% ``` +% ~~~ % % `RankedVertexTerms` is a list of compound terms of the following form: -% ```prolog +% ~~~{.pl} % rank(RankNode,ContentNodes) -% ``` +% ~~~ % % @tbd Add support for subgraphs (arbitrary nesting). % @tbd Add support for escape strings: @@ -179,10 +176,10 @@ gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> % @tbd Assert attributes that are generic with respect to a subgraph. % @tbd Not all vertex and edge properties can be shared it seems (e.g., label). -gv_graph(graph(VTerms,ETerms,GAttrs)) --> - gv_graph(graph(VTerms,[],ETerms,GAttrs)). +gv_graph(graph(VTerms, ETerms, GAttrs)) --> + gv_graph(graph(VTerms, [], ETerms, GAttrs)). -gv_graph(graph(VTerms,RankedVTerms,ETerms,GAttrs1)) --> +gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> { shared_attributes(VTerms, SharedVAttrs, NewVTerms), shared_attributes(ETerms, SharedEAttrs, NewETerms), @@ -197,8 +194,8 @@ gv_graph(graph(VTerms,RankedVTerms,ETerms,GAttrs1)) --> % States that this file represents a graph according to the GraphViz format. indent(I), gv_strict(Strict), - gv_graph_type(Directed), " ", - gv_id(GName), " ", + gv_graph_type(Directed), ` `, + gv_id(GName), ` `, % The body of the DOT file appears between curly braces. bracketed( @@ -243,18 +240,18 @@ gv_graph0( (NewVTerms == [], RankedVTerms == []) } -> - "" + `` ; line_feed ), % The list of GraphViz nodes. '*'(gv_node_statement(NewI, GAttrs), NewVTerms, []), - ({NewVTerms == []} -> "" ; line_feed), + ({NewVTerms == []} -> `` ; line_feed), % The ranked GraphViz nodes (displayed at the same height). '*'(gv_ranked_node_collection(NewI, GAttrs), RankedVTerms, []), - ({RankedVTerms == []} -> "" ; line_feed), + ({RankedVTerms == []} -> `` ; line_feed), { findall( @@ -284,8 +281,8 @@ gv_graph0( %! gv_graph_type(+Directed:boolean)// . % The type of graph that is represented. -gv_graph_type(false) --> "graph". -gv_graph_type(true) --> "digraph". +gv_graph_type(false) --> `graph`. +gv_graph_type(true) --> `digraph`. %! gv_id(?Atom:atom)// is det. @@ -308,9 +305,8 @@ gv_graph_type(true) --> "digraph". % This requires an XML grammar! % HTML strings (variant 4). -gv_id(Content) --> - {compound(Content)}, !, - gv_html_like_label(Content). +gv_id(Atom) --> + dcg_atom_codes(gv_html_like_label, Atom), !. % Alpha-numeric strings (variant 1). gv_id(Atom) --> {atom_codes(Atom, [H|T])}, @@ -334,16 +330,14 @@ gv_id(Atom) --> % Double-quoted strings (variant 3). % The quotes are not in the given atom. They are written anyway. gv_id(Atom) --> - quoted(dcg_atom_codes(gv_quoted_string, Atom)), !. + quoted(double_quote, dcg_atom_codes(gv_quoted_string, Atom)), !. -gv_id_first(X) --> letter(X). +gv_id_first(X) --> ascii_letter(X). gv_id_first(X) --> underscore(X). gv_id_rest([]) --> []. gv_id_rest([H|T]) --> - ( alpha_numeric(H) - ; underscore(H) - ), + (ascii_alpha_numeric(H) ; underscore(H)), gv_id_rest(T). @@ -359,19 +353,19 @@ gv_keyword(Codes):- % GraphViz has reserved keywords that cannot be used as identifiers. % GraphViz keywords are case-insensitive. -gv_keyword --> "digraph". -gv_keyword --> "edge". -gv_keyword --> "graph". -gv_keyword --> "node". -gv_keyword --> "strict". -gv_keyword --> "subgraph". +gv_keyword --> `digraph`. +gv_keyword --> `edge`. +gv_keyword --> `graph`. +gv_keyword --> `node`. +gv_keyword --> `strict`. +gv_keyword --> `subgraph`. %! gv_kind(+Kind:oneof([edge,graph,node]))// . -gv_kind(edge) --> "edge". -gv_kind(graph) --> "graph". -gv_kind(node) --> "node". +gv_kind(edge) --> `edge`. +gv_kind(graph) --> `graph`. +gv_kind(node) --> `node`. %! gv_node_id(+NodeId:atom)// . @@ -398,7 +392,7 @@ gv_node_id(Id) --> gv_node_statement(I, GraphAttrs, vertex(Id,_,VAttrs)) --> indent(I), - gv_node_id(Id), " ", + gv_node_id(Id), ` `, gv_attribute_list(node, GraphAttrs, VAttrs), line_feed. @@ -409,23 +403,23 @@ gv_port --> gv_port_angle, '?'(gv_port_location, []). gv_port --> - ":", + `:`, gv_compass_pt(_). gv_port_angle --> - "@", + `@`, gv_id(_). gv_port_location --> - ":", + `:`, gv_id(_). gv_port_location --> - ":", + `:`, bracketed( round, ( gv_id(_), - ",", + `,`, gv_id(_) ) ). @@ -442,7 +436,7 @@ gv_quoted_string([92,34|T]) --> !, gv_quoted_string(T). % Add the backslash escape character. gv_quoted_string([34|T]) --> !, - "\\\"", + `\\\"`, gv_quoted_string(T). % All other characters are allowed without escaping. gv_quoted_string([H|T]) --> @@ -461,14 +455,14 @@ gv_ranked_node_collection( % The rank attribute. {NewI is I + 1}, - indent(NewI), gv_attribute(rank=same), ";", line_feed, + indent(NewI), gv_attribute(rank=same), `;`, line_feed, '*'( gv_node_statement(NewI, GraphAttrs), [Rank_V_Term|Content_V_Terms], [] ), - + % We want to indent the closing curly brace. indent(I) )), @@ -481,7 +475,7 @@ gv_ranked_node_collection( % This only applies to directed graphs. gv_strict(false) --> []. -gv_strict(true) --> "strict ". +gv_strict(true) --> `strict `. diff --git a/gv_file.pl b/gv_file.pl index 704e2d4..bba87f9 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -9,6 +9,9 @@ gif_to_gv_file/3, % +GraphInterchangeFormat:compound % ?ToFile:atom % +Options:list(nvpair) + gif_to_svg_dom/3, % +GraphInterchangeFormat:compound + % -SvgDom:list(compound) + % +Options:list(nvpair) open_dot/1 % +File:file ] ). @@ -27,11 +30,13 @@ and GraphViz output files or SVG DOM structures. :- use_module(library(option)). :- use_module(library(process)). +:- use_module(library(predicate_options)). % Declarations. -:- use_module(generics(code_ext)). +:- use_module(generics(codes_ext)). :- use_module(generics(db_ext)). :- use_module(os(file_ext)). :- use_module(os(run_ext)). +:- use_module(svg(svg_file)). :- use_module(plGraphViz(gv_dot)). @@ -131,12 +136,15 @@ file_to_gv(FromFile, ToFile, Options):- prolog_file_type(ToExtension, graphviz_output), !, % The output file is either given or created. - ( var(ToFile) - -> user:prolog_file_type(ToExtension, ToFileType), - file_alternative(FromFile, _, _, ToExtension, ToFile) - ; is_absolute_file_name(ToFile), - % The given output file must match a certain file extension. - file_name_extension(_, ToExtension, ToFile) + ( + var(ToFile) + -> + user:prolog_file_type(ToExtension, ToFileType), + file_alternative(FromFile, _, _, ToExtension, ToFile) + ; + is_absolute_file_name(ToFile), + % The given output file must match a certain file extension. + file_name_extension(_, ToExtension, ToFile) ), % Now that we have the output file we can prevent the % file type / file extension translation predicates from bakctracking. @@ -146,8 +154,6 @@ file_to_gv(FromFile, ToFile, Options):- format(atom(OutputType), '-T~w', [ToExtension]), process_create( path(Method), - % @tbd Windows hack: - %%%%'C:\\Program Files (x86)\\Graphviz2.38\\bin\\dot.exe', [OutputType,FromFile,'-o',ToFile], [process(PID)] ), @@ -171,6 +177,20 @@ gif_to_gv_file(Gif, ToFile, Options):- codes_to_gv_file(Codes, ToFile, Options). +%! gif_to_svg_dom( +%! +GraphInterchangeFormat:compound, +%! -SvgDom:list(compound), +%! +Options:list(nvpair) +%! ) is det. + +gif_to_svg_dom(Gif, SvgDom, Options1):- + % Make sure the file type of the output file is SvgDom. + merge_options([to_file_type=svg], Options1, Options2), + gif_to_gv_file(Gif, ToFile, Options2), + file_to_svg(ToFile, SvgDom), + delete_file(ToFile). + + %! open_dot(+File:atom) is det. % Opens the given DOT file. % diff --git a/gv_html.pl b/gv_html.pl index 08306f0..3f0b08b 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -1,224 +1,60 @@ :- module( gv_html, [ - gv_html_like_label//1 % +Content:compound + gv_html_like_label//1 % +Codes:list(code) ] ). -/** GraphViz: HTML-like labels - -Grammar taken from the GraphViz Web site: - -``` -label : text - | table -text : textitem - | text textitem -textitem : string - |
- | text - | text - | text - | text - | text - | text - | text - | text -table : [ ] rows
[
] -rows : row - | rows row - | rows
row -row: cells -cells : cell - | cells cell - | cells cell -cell: label - | -``` +/** GraphViz HTML @author Wouter Beek -@see http://www.graphviz.org/content/node-shapes#html -@version 2013/07, 2013/09, 2014/03-2014/06, 2014/11 +@version 2013/07, 2013/09, 2014/03-2014/06 */ -:- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_bracket)). :- use_module(plDcg(dcg_content)). :- use_module(plHtml(html_dcg)). -%! gv_html_like_label(?Content:compound)// . - -gv_html_like_label(Content) --> - bracketed(angular, label(Content)). - - -%! cell(?Contents:compound)// . -% Supported attributes for TD: -% ``` -% ALIGN="CENTER|LEFT|RIGHT|TEXT" -% BALIGN="CENTER|LEFT|RIGHT" -% BGCOLOR="color" -% BORDER="value" -% CELLPADDING="value" -% CELLSPACING="value" -% COLOR="color" -% COLSPAN="value" -% FIXEDSIZE="FALSE|TRUE" -% GRADIENTANGLE="value" -% HEIGHT="value" -% HREF="value" -% ID="value" -% PORT="portName" -% ROWSPAN="value" -% SIDES="value" -% STYLE="value" -% TARGET="value" -% TITLE="value" -% TOOLTIP="value" -% VALIGN="MIDDLE|BOTTOM|TOP" -% WIDTH="value" -% ``` +%! gv_html_label(+Codes:list(code))// . % -% Supported attributes for IMG: -% ``` -% SCALE="FALSE|TRUE|WIDTH|HEIGHT|BOTH" -% SRC="value" -% ``` - -cell(td(Contents)) --> - html_element(td, [], label(Contents)). -cell(td(img)) --> - html_element(td, [], html_element(img)). - - -%! cells(?Contents:list(compound))// . - -cells([H|T]) --> - cell(H), - cells(T). -cells([H,vr|T]) --> - cell(H), - html_element(vr), - cells(T). -cells([H]) --> - cell(H). - - -%! label(?Content:compound)// . -% GraphViz HTML-like label. - -label(Content) --> - text(Content). -label(Content) --> - table(Content). - - -%! row(?Contents:compound)// . - -row(tr(Contents)) --> - html_element(tr, [], cell(Contents)). - - -%! rows(?Contents:list)// . - -rows([H|T]) --> - row(H), - rows(T). -rows([H,hr|T]) --> - row(H), - html_element(hr), - rows(T). -rows([H]) --> - row(H). - - -%! table(?Contents:compound)// . -% Supported attributes for TABLE: -% ``` -% ALIGN="CENTER|LEFT|RIGHT" -% BGCOLOR="color" -% BORDER="value" -% CELLBORDER="value" -% CELLPADDING="value" -% CELLSPACING="value" -% COLOR="color" -% COLUMNS="value" -% FIXEDSIZE="FALSE|TRUE" -% GRADIENTANGLE="value" -% HEIGHT="value" -% HREF="value" -% ID="value" -% PORT="portName" -% ROWS="value" -% SIDES="value" -% STYLE="value" -% TARGET="value" -% TITLE="value" -% TOOLTIP="value" -% VALIGN="MIDDLE|BOTTOM|TOP" -% WIDTH="value" -% ``` -% -% Supported attributes for FONT: -% ``` -% COLOR="color" -% FACE="fontname" -% POINT-SIZE="value" -% ``` - -table(table(Attrs,Contents)) --> - html_element(table, Attrs, rows(Contents)). -table(table(font(Contents))) --> - html_element(font, [], html_element(table, [], rows(Contents))). - - -%! text(?Contents:list)// . - -text(Contents) --> - '+'(textitem, Contents, []). - - -%! textitem(?Content)// . -% Supported attributes for BR: -% ``` -% ALIGN="CENTER|LEFT|RIGHT" -% ``` - -textitem(string(String)) --> - html_string(String). -textitem(entity(Name)) --> - html_entity(Name). -textitem(br(Attrs)) --> - html_element(br, Attrs). -textitem(Compound) --> - {var(Compound)}, !, - html_element(Name, _, text(Content)), - { - supported_html_element(Name), - Compound =.. [Name,Content] - }. -textitem(Compound) --> - { - Compound =.. [Name,Content], - supported_html_element(Name) - }, - html_element(Name, _, text(Content)). - - - -% HELPERS - -%! supported_html_element(+Name:atom) is semidet. -%! supported_html_element(-Name:atom) is multi. - -supported_html_element(b). -supported_html_element(font). -supported_html_element(i). -supported_html_element(o). -supported_html_element(s). -supported_html_element(sub). -supported_html_element(sup). -supported_html_element(u). +% @see http://www.graphviz.org/doc/info/shapes.html#html + +gv_html_label --> gv_html_text, !. +gv_html_label --> gv_html_table, !. +gv_html_label --> []. + +gv_html_like_label --> bracketed(angular, gv_html_label). + +gv_html_like_label(Content) --> bracketed(angular, html_dcg(Content)). + +gv_html_table --> html_element(table, _, gv_html_rows). +gv_html_table --> html_element(font, _, html_element(table, _, gv_html_rows)). + +gv_html_rows --> gv_html_row, gv_html_rows. +gv_html_rows --> gv_html_row, html_element(hr, _), gv_html_rows. +gv_html_rows --> gv_html_row. + +gv_html_row --> html_element(tr, _, gv_html_cells). + +gv_html_cell --> html_element(td, _, gv_html_label). +gv_html_cell --> html_element(td, _, html_element(img, _)). + +gv_html_cells --> gv_html_cell, gv_html_cells. +gv_html_cells --> gv_html_cell. +gv_html_cells --> gv_html_cell, html_element(vr, _), gv_html_cells. + +gv_html_text --> gv_html_textitem, gv_html_text. +gv_html_text --> gv_html_textitem. + +gv_html_textitem --> html_string, !. +gv_html_textitem --> html_entity, !. +gv_html_textitem --> html_element(br, _), !. +gv_html_textitem --> html_element(font, _, gv_html_text), !. +gv_html_textitem --> html_element(i, _, gv_html_text), !. +gv_html_textitem --> html_element(b, _, gv_html_text), !. +gv_html_textitem --> html_element(u, _, gv_html_text), !. +gv_html_textitem --> html_element(sub, _, gv_html_text), !. +gv_html_textitem --> html_element(sup, _, gv_html_text), !. + diff --git a/gv_numeral.pl b/gv_numeral.pl index c115372..7870eb1 100644 --- a/gv_numeral.pl +++ b/gv_numeral.pl @@ -14,67 +14,59 @@ :- use_module(math(math_ext)). :- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_ascii)). :- use_module(plDcg(dcg_cardinal)). %! gv_numeral(?Value:number)// . -% -% # Syntax -% -% ```bnf +% ~~~{.bnf} % ('-')? ( '.' [0-9]+ | [0-9]+ ( '.' [0-9]* )? ) -% ``` -% -% ## Generation -% -% In the generative case, three notations are allowed (also see below): -% 1. (non-zero integer-part) -% 2. (decimal-separator) (non-zero fractional) -% 3. (non-zero integer-part) (decimal-separator) (non-zero fractional) -% -% The following notations are explicitly excluded due to verbosity: -% - (non-zero integer-part) (decimal-separator) -% - (non-zero integer-part) (decimal-separator) (zero fractional) -% - (zero integer-part) (decimal-separator) (non-zero fractional) -% -% The following notations are also excluded, but since they violate -% well-formedness: -% - (non-zero integer-part) (non-zero fractional) -% - (decimal-separator) +% ~~~ gv_numeral(N) --> - {var(N)}, !, - sign(Sign), - ( ".", - '+'(decimal_digit, Fractional, [convert1(weights_decimal)]), - {IntegerPart = 0} - ; '+'(decimal_digit, IntegerPart, [convert1(weights_decimal)]), - ( ".", - '*'(decimal_digit, Fractional, [convert1(weights_decimal)]) - ; {Fractional = 0} - ) - ), - { number_integer_parts(UnsignedN, IntegerPart, Fractional), - N is copysign(UnsignedN, Sign) - }. + {nonvar(N)}, + {number_sign_parts(N, Sign, Abs)}, + ({Sign =:= -1} -> `-` ; ``), + gv_numeral_abs(Abs). gv_numeral(N) --> - {number_sign_parts(N, Sign, UnsignedN)}, - sign(Sign), - {number_integer_parts(UnsignedN, IntegerPart, Fractional)}, - ( % [1] The fractional is zero, so only write the integer part - % and do not write the decimal separator. - {Fractional =:= 0} - -> integer(IntegerPart) - ; % [2] The integer part is zero, so only write the fractional part, - % preceded by the decimal separator. - {IntegerPart =:= 0} - -> ".", - integer(Fractional) - ; % [3] Both the integer part and the fractional are non-zero, - % so write both of them, with the decimal separator in-between. - integer(IntegerPart), - ".", - integer(Fractional) + {var(N)}, + 'sign?'(Sign), + gv_numeral_abs(Abs), + {number_sign_parts(N, Sign, Abs)}. + + +gv_numeral_abs(N) --> + {nonvar(N)}, + {number_integer_parts(N, N1, N2)}, + ( + {N2 =:= 0} + -> + integer(N1) + ; + {N1 =:= 0} + -> + `.`, + integer(N2) + ; + integer(N1), + '?'((`.`, 'integer?'(N2)), []) ). +gv_numeral_abs(N) --> + {var(N)}, + ( + `.`, + integer(N2) + -> + {N1 = 0} + ; + integer(N1), + ( + `.` + -> + 'integer?'(N2) + ; + {N2 = 0} + ) + ), + {number_integer_parts(N, N1, N2)}. + diff --git a/load.pl b/load.pl index 5cec32c..4b117d1 100644 --- a/load.pl +++ b/load.pl @@ -1,14 +1,12 @@ -% Load file for the plGraphViz library. +% Load file for plGraphViz. -:- dynamic(user:project/2). -:- multifile(user:project/2). - user:project(plGraphViz, 'GraphViz support for SWI-Prolog.'). +:- dynamic(user:prolog/3). +:- multifile(user:prolog/3). + user:project(plGraphViz, 'GraphViz support for SWI-Prolog.', plGraphViz). :- use_module(load_project). -:- load_project([ +:- load_project(plGraphViz, [ plc-'Prolog-Library-Collection', - plDcg, - plHtml, - plUri + plHtml ]). diff --git a/plDcg b/plDcg deleted file mode 160000 index 96e2615..0000000 --- a/plDcg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 96e261537773270a43d1ff4346273820282f21fb diff --git a/plHtml b/plHtml index a7b736f..18e657b 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit a7b736fdf7c435f825193bbc54500a302b0bc4b1 +Subproject commit 18e657b22a84d5e98a317ddec58314964ff68bcd diff --git a/plUri b/plUri deleted file mode 160000 index 59f582c..0000000 --- a/plUri +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 59f582c68cebc221f964ccb9805a869d05cb7856 diff --git a/run.pl b/run.pl deleted file mode 100644 index 8bba736..0000000 --- a/run.pl +++ /dev/null @@ -1,9 +0,0 @@ -% Standalone execution of the plGraphViz library. - -:- if(current_prolog_flag(argv, ['--debug'|_])). - :- ensure_loaded(debug). -:- else. - :- set_prolog_flag(verbose, silent). - :- ensure_loaded(load). -:- endif. - ```

54: 正在比较变动前 0cc5421 和变动后 dbc602d

[back to content](#compare) ``` diff diff --git a/.gitignore b/.gitignore index b25c15b..7193a38 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ *~ +*# +*.db +data/* diff --git a/.gitmodules b/.gitmodules index a63cbff..6c22435 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,9 @@ [submodule "plHtml"] path = plHtml url = https://github.com/wouterbeek/plHtml.git +[submodule "plDcg"] + path = plDcg + url = https://github.com/wouterbeek/plDcg.git +[submodule "plUri"] + path = plUri + url = https://github.com/wouterbeek/plUri.git diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index d7d21ad..2774ee9 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit d7d21ad4d6d7cec98d8b0122f5303e691998f512 +Subproject commit 2774ee9cba6ac2353150322c744e65857634e575 diff --git a/debug.pl b/debug.pl index d7339b9..12b4526 100644 --- a/debug.pl +++ b/debug.pl @@ -1,9 +1,7 @@ % Debug file for library plGraphViz. -:- style_check(+charset). -%:- style_check(+var_branches). - :- [load]. :- use_module(debug_project). :- debug_all_files. + diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 3c7863d..30761bb 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -46,10 +46,12 @@ /** GraphViz attribute types @author Wouter Beek -@version 2014/06 +@version 2014/06, 2014/11 */ :- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_ascii)). +:- use_module(plDcg(dcg_atom)). :- use_module(plDcg(dcg_cardinal)). :- use_module(plDcg(dcg_content)). @@ -97,7 +99,7 @@ gv_attr_type(viewPort). % An *addDouble* is represented by a Prolog float. addDouble(Float) --> - '?'(`+`, []), + '?'(plus_sign, []), double(Float). @@ -106,7 +108,7 @@ addDouble(Float) --> % `point(X:float,Y:float,InputOnly:boolean)`. addPoint(Point) --> - '?'(`+`, []), + '?'(plus_sign, []), point(Point). @@ -147,10 +149,10 @@ backwards_compatible(invempty). backwards_compatible(open). -bool(false) --> `false`. -bool(false) --> `no`. -bool(true) --> `true`. -bool(true) --> `yes`. +bool(false) --> "false". +bool(false) --> "no". +bool(true) --> "true". +bool(true) --> "yes". %! clusterMode(+ClusterMode:atom)// . @@ -187,7 +189,7 @@ doubleList([H|T]) --> '*'(doubleList1, T, []). doubleList1(Float) --> - `:`, + ":", double(Float). @@ -242,16 +244,16 @@ pagedir('TR'). %! point(+Point:compound)// . % A *point* is represented by a compound of the following form: -% `point(X:float,Y:float,InputOnly:boolean)`. +% `point(X:float,Y:float,Changeable:boolean)`. -point(point(X,Y,InputOnly)) --> +point(point(X,Y,Changeable)) --> float(X), - `,`, + ",", float(Y), - input_only(InputOnly). + input_changeable(Changeable). -input_only(false) --> []. -input_only(true) --> `!`. +input_changeable(false) --> "". +input_changeable(true) --> "!". pointList(Points) --> @@ -292,9 +294,9 @@ rankdir('TB'). rect(rect(LowerLeftX,LowerLeftY,UpperRightX,UpperRightY)) --> - float(LowerLeftX), `,`, - float(LowerLeftY), `,`, - float(UpperRightX), `,`, + float(LowerLeftX), ",", + float(LowerLeftY), ",", + float(UpperRightX), ",", float(UpperRightY). @@ -414,4 +416,3 @@ style(node, wedged). % @tbd viewPort - diff --git a/gv_attrs.pl b/gv_attrs.pl index faf496c..649ef9c 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -2,15 +2,17 @@ gv_attrs, [ gv_attr/3 % +Context:oneof([cluster,edge,graph,node,subgraph]) - % +Attr1:nvpair - % +Attr2:nvpair + % +Attribute1:nvpair + % -Attribute2:nvpair ] ). -/** GraphViz attributes v2 +/** GraphViz: Attributes + +Support for GraphViz attributes. @author Wouter Beek -@version 2014/06 +@version 2014/06, 2014/11 */ :- use_module(library(apply)). @@ -19,9 +21,11 @@ :- use_module(generics(db_ext)). :- use_module(os(file_ext)). +:- use_module(os(file_gnu)). +:- use_module(plDcg(dcg_atom)). :- use_module(plDcg(dcg_content)). -:- use_module(plDcg(dcg_generic)). +:- use_module(plDcg(dcg_generics)). :- use_module(plHtml(html)). :- use_module(plHtml(html_table)). @@ -54,24 +58,40 @@ +%! gv_attr( +%! +Context:oneof([cluster,edge,graph,node,subgraph]), +%! +Attribute1:nvpair, +%! +Attribute2:nvpair +%! ) is det. +% Uses the default value in case Value is uninstantiated. +% Otherwise, performs a typecheck and converts the given value. + gv_attr(Context, N=V, N=V):- var(V), !, gv_attr(N, UsedBy, _, V, _, _), + % Check validity of context. memberchk(Context, UsedBy). gv_attr(Context, N=V1, N=V2):- gv_attr(N, UsedBy, Types, _, Minimum, _), + % Check validity of context. memberchk(Context, UsedBy), + % Check validity of value type. member(Type, Types), - ( - Type == style - -> - Dcg =.. [Type,Context,V1] - ; - Dcg =.. [Type,V1] + ( Type == style + -> Dcg =.. [Type,Context,V1] + ; Dcg =.. [Type,V1] ), once(dcg_phrase(Dcg, V2)), + % Check validity of Value w.r.t. minimum value -- if available. check_minimum(V1, Minimum). + + +% HELPERS + +%! check_minimum(+Value:atom, +Minimum:number) is semidet. +% Trivially succeeds if no minimum value is available for a given attribute. + check_minimum(_, ''):- !. check_minimum(V, Min1):- atom_number(Min1, Min2), diff --git a/gv_color.pl b/gv_color.pl index cb0cf8c..c48817c 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -13,27 +13,27 @@ @author Wouter Beek @tbd Color value `transparent` is only available in the output formats ps, svg, fig, vmrl, and the bitmap formats. -@version 2014/06 +@version 2014/06, 2014/10-2014/11 */ :- use_module(library(apply)). -:- use_module(library(lists)). +:- use_module(library(lists), except([delete/3])). :- use_module(library(persistency)). :- use_module(library(xpath)). :- use_module(generics(db_ext)). :- use_module(os(file_ext)). +:- use_module(os(file_gnu)). +:- use_module(plDcg(abnf_core_rules)). :- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_atom)). :- use_module(plDcg(dcg_cardinal)). :- use_module(plDcg(dcg_content)). -:- use_module(plDcg_rfc(rfc2616_basic)). :- use_module(plHtml(html)). :- use_module(plHtml(html_table)). -:- use_module(plSparql_parse(sparql_char)). - :- db_add_novel(user:prolog_file_type(log, logging)). %! gv_color(?Colorscheme:oneof([svg,x11]), ?Color:atom) is nondet. @@ -51,10 +51,10 @@ % 3. `hsv(Hue:between(0.0,1.0),Saturation:between(0.0,1.0),Value:between(0.0,1.0))` color(rgb(Red,Green,Blue)) --> !, - `#`, + "#", '#'(3, hex_color, [Red,Green,Blue], []). color(rgbs(Red,Green,Blue,Alpha)) --> !, - `#`, + "#", '#'(4, hex_color, [Red,Green,Blue,Alpha], []). color(hsv(Hue,Saturation,Value)) --> !, '#'(3, hsv_color, [Hue,Saturation,Value], []). @@ -82,7 +82,7 @@ wc(Color-Float) --> '?'(wc_weight(Float), []). wc_weight(Float) --> - `;`, + ";", float(Float). diff --git a/gv_dot.pl b/gv_dot.pl index accd5bd..e67c469 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -1,7 +1,7 @@ :- module( gv_dot, [ - gv_graph//1 % +GraphTerm:compound + gv_graph//1 % +Gif:compound ] ). @@ -19,14 +19,17 @@ In GraphViz vertices are called 'nodes'. */ :- use_module(library(apply)). -:- use_module(library(lists)). +:- use_module(library(lists), except([delete/3])). :- use_module(library(ordsets)). :- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_arrow)). :- use_module(plDcg(dcg_ascii)). +:- use_module(plDcg(dcg_bracket)). :- use_module(plDcg(dcg_content)). -:- use_module(plDcg(dcg_generic)). +:- use_module(plDcg(dcg_generics)). :- use_module(plDcg(dcg_meta)). +:- use_module(plDcg(dcg_quote)). :- use_module(plGraphViz(gv_attrs)). :- use_module(plGraphViz(gv_html)). @@ -39,7 +42,7 @@ In GraphViz vertices are called 'nodes'. % We assume that the attribute has already been validated. gv_attribute(Name=Val) --> - gv_id(Name), `=`, gv_id(Val), `;`. + gv_id(Name), "=", gv_id(Val), ";". %! gv_attribute_list( @@ -47,10 +50,10 @@ gv_attribute(Name=Val) --> %! +GraphAttributes:list(nvpair), %! +Attributes:list(nvpair) %! )// . -% ~~~{.abnf} +% ```abnf % attr_list = "[" [a_list] "]" [attr_list] % a_list = ID "=" ID [","] [a_list] -% ~~~ +% ``` % Attributes occur between square brackets. gv_attribute_list(Context, _, Attrs1) --> @@ -59,20 +62,20 @@ gv_attribute_list(Context, _, Attrs1) --> %! gv_compass_pt(+Direction:oneof(['_',c,e,n,ne,nw,s,se,sw,w]))// . -% ~~~ +% ``` % compass_pt : (n | ne | e | se | s | sw | w | nw | c | _) -% ~~~ +% ``` -gv_compass_pt('_') --> `_`. -gv_compass_pt(c) --> `c`. -gv_compass_pt(e) --> `e`. -gv_compass_pt(n) --> `n`. -gv_compass_pt(ne) --> `ne`. -gv_compass_pt(nw) --> `nw`. -gv_compass_pt(s) --> `s`. -gv_compass_pt(se) --> `se`. -gv_compass_pt(sw) --> `sw`. -gv_compass_pt(w) --> `w`. +gv_compass_pt('_') --> "_". +gv_compass_pt(c) --> "c". +gv_compass_pt(e) --> "e". +gv_compass_pt(n) --> "n". +gv_compass_pt(ne) --> "ne". +gv_compass_pt(nw) --> "nw". +gv_compass_pt(s) --> "s". +gv_compass_pt(se) --> "se". +gv_compass_pt(sw) --> "sw". +gv_compass_pt(w) --> "w". %! gv_edge_operator(+Directed:boolean)// . @@ -83,7 +86,7 @@ gv_compass_pt(w) --> `w`. % @arg Directed Whether an edge is directed (operator `->`) or % undirected (operator `--`). -gv_edge_operator(false) --> !, `--`. +gv_edge_operator(false) --> !, "--". gv_edge_operator(true) --> arrow(right, 2). @@ -107,11 +110,11 @@ gv_edge_operator(true) --> arrow(right, 2). gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> indent(I), - gv_node_id(FromId), ` `, + gv_node_id(FromId), " ", - gv_edge_operator(Directed), ` `, + gv_edge_operator(Directed), " ", - gv_node_id(ToId), ` `, + gv_node_id(ToId), " ", % We want `colorscheme/1` from the edges and % `directionality/1` from the graph. @@ -133,18 +136,18 @@ gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> % @arg GraphAttributes A list of name-value pairs. % @arg CategoryAttributes A list of name-value pairs. % -% ~~~ +% ``` % attr_stmt = (graph / node / edge) attr_list -% ~~~ +% ``` gv_generic_attributes_statement(_, _, _, []) --> [], !. gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> indent(I), - gv_kind(Kind), ` `, + gv_kind(Kind), " ", gv_attribute_list(Kind, GraphAttrs, KindAttrs), line_feed. -%! gv_graph(+GraphTerm:compound)// +%! gv_graph(+Gif:compound)// % The follow graph attributes are supported, % beyond the GraphViz attributes for graphs: % * `directed(+boolean)` @@ -156,19 +159,19 @@ gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> % they are ignored in the input file. % Only in combinattion with directionality `directed`. % -% ~~~{.abnf} +% ```abnf % graph = ["strict"] ("graph" / "digraph") [ID] "{" stmt_list "}" -% ~~~ +% ``` % % `GraphTerm` is a compound term of the following form: -% ~~~{.pl} +% ```prolog % graph(VertexTerms,RankedVertexTerms,EdgeTerms,GraphAttributes) -% ~~~ +% ``` % % `RankedVertexTerms` is a list of compound terms of the following form: -% ~~~{.pl} +% ```prolog % rank(RankNode,ContentNodes) -% ~~~ +% ``` % % @tbd Add support for subgraphs (arbitrary nesting). % @tbd Add support for escape strings: @@ -176,10 +179,10 @@ gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> % @tbd Assert attributes that are generic with respect to a subgraph. % @tbd Not all vertex and edge properties can be shared it seems (e.g., label). -gv_graph(graph(VTerms, ETerms, GAttrs)) --> - gv_graph(graph(VTerms, [], ETerms, GAttrs)). +gv_graph(graph(VTerms,ETerms,GAttrs)) --> + gv_graph(graph(VTerms,[],ETerms,GAttrs)). -gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> +gv_graph(graph(VTerms,RankedVTerms,ETerms,GAttrs1)) --> { shared_attributes(VTerms, SharedVAttrs, NewVTerms), shared_attributes(ETerms, SharedEAttrs, NewETerms), @@ -194,8 +197,8 @@ gv_graph(graph(VTerms, RankedVTerms, ETerms, GAttrs1)) --> % States that this file represents a graph according to the GraphViz format. indent(I), gv_strict(Strict), - gv_graph_type(Directed), ` `, - gv_id(GName), ` `, + gv_graph_type(Directed), " ", + gv_id(GName), " ", % The body of the DOT file appears between curly braces. bracketed( @@ -240,18 +243,18 @@ gv_graph0( (NewVTerms == [], RankedVTerms == []) } -> - `` + "" ; line_feed ), % The list of GraphViz nodes. '*'(gv_node_statement(NewI, GAttrs), NewVTerms, []), - ({NewVTerms == []} -> `` ; line_feed), + ({NewVTerms == []} -> "" ; line_feed), % The ranked GraphViz nodes (displayed at the same height). '*'(gv_ranked_node_collection(NewI, GAttrs), RankedVTerms, []), - ({RankedVTerms == []} -> `` ; line_feed), + ({RankedVTerms == []} -> "" ; line_feed), { findall( @@ -281,8 +284,8 @@ gv_graph0( %! gv_graph_type(+Directed:boolean)// . % The type of graph that is represented. -gv_graph_type(false) --> `graph`. -gv_graph_type(true) --> `digraph`. +gv_graph_type(false) --> "graph". +gv_graph_type(true) --> "digraph". %! gv_id(?Atom:atom)// is det. @@ -305,8 +308,9 @@ gv_graph_type(true) --> `digraph`. % This requires an XML grammar! % HTML strings (variant 4). -gv_id(Atom) --> - dcg_atom_codes(gv_html_like_label, Atom), !. +gv_id(Content) --> + {compound(Content)}, !, + gv_html_like_label(Content). % Alpha-numeric strings (variant 1). gv_id(Atom) --> {atom_codes(Atom, [H|T])}, @@ -330,14 +334,16 @@ gv_id(Atom) --> % Double-quoted strings (variant 3). % The quotes are not in the given atom. They are written anyway. gv_id(Atom) --> - quoted(double_quote, dcg_atom_codes(gv_quoted_string, Atom)), !. + quoted(dcg_atom_codes(gv_quoted_string, Atom)), !. -gv_id_first(X) --> ascii_letter(X). +gv_id_first(X) --> letter(X). gv_id_first(X) --> underscore(X). gv_id_rest([]) --> []. gv_id_rest([H|T]) --> - (ascii_alpha_numeric(H) ; underscore(H)), + ( alpha_numeric(H) + ; underscore(H) + ), gv_id_rest(T). @@ -353,19 +359,19 @@ gv_keyword(Codes):- % GraphViz has reserved keywords that cannot be used as identifiers. % GraphViz keywords are case-insensitive. -gv_keyword --> `digraph`. -gv_keyword --> `edge`. -gv_keyword --> `graph`. -gv_keyword --> `node`. -gv_keyword --> `strict`. -gv_keyword --> `subgraph`. +gv_keyword --> "digraph". +gv_keyword --> "edge". +gv_keyword --> "graph". +gv_keyword --> "node". +gv_keyword --> "strict". +gv_keyword --> "subgraph". %! gv_kind(+Kind:oneof([edge,graph,node]))// . -gv_kind(edge) --> `edge`. -gv_kind(graph) --> `graph`. -gv_kind(node) --> `node`. +gv_kind(edge) --> "edge". +gv_kind(graph) --> "graph". +gv_kind(node) --> "node". %! gv_node_id(+NodeId:atom)// . @@ -392,7 +398,7 @@ gv_node_id(Id) --> gv_node_statement(I, GraphAttrs, vertex(Id,_,VAttrs)) --> indent(I), - gv_node_id(Id), ` `, + gv_node_id(Id), " ", gv_attribute_list(node, GraphAttrs, VAttrs), line_feed. @@ -403,23 +409,23 @@ gv_port --> gv_port_angle, '?'(gv_port_location, []). gv_port --> - `:`, + ":", gv_compass_pt(_). gv_port_angle --> - `@`, + "@", gv_id(_). gv_port_location --> - `:`, + ":", gv_id(_). gv_port_location --> - `:`, + ":", bracketed( round, ( gv_id(_), - `,`, + ",", gv_id(_) ) ). @@ -436,7 +442,7 @@ gv_quoted_string([92,34|T]) --> !, gv_quoted_string(T). % Add the backslash escape character. gv_quoted_string([34|T]) --> !, - `\\\"`, + "\\\"", gv_quoted_string(T). % All other characters are allowed without escaping. gv_quoted_string([H|T]) --> @@ -455,14 +461,14 @@ gv_ranked_node_collection( % The rank attribute. {NewI is I + 1}, - indent(NewI), gv_attribute(rank=same), `;`, line_feed, + indent(NewI), gv_attribute(rank=same), ";", line_feed, '*'( gv_node_statement(NewI, GraphAttrs), [Rank_V_Term|Content_V_Terms], [] ), - + % We want to indent the closing curly brace. indent(I) )), @@ -475,7 +481,7 @@ gv_ranked_node_collection( % This only applies to directed graphs. gv_strict(false) --> []. -gv_strict(true) --> `strict `. +gv_strict(true) --> "strict ". diff --git a/gv_file.pl b/gv_file.pl index bba87f9..704e2d4 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -9,9 +9,6 @@ gif_to_gv_file/3, % +GraphInterchangeFormat:compound % ?ToFile:atom % +Options:list(nvpair) - gif_to_svg_dom/3, % +GraphInterchangeFormat:compound - % -SvgDom:list(compound) - % +Options:list(nvpair) open_dot/1 % +File:file ] ). @@ -30,13 +27,11 @@ and GraphViz output files or SVG DOM structures. :- use_module(library(option)). :- use_module(library(process)). -:- use_module(library(predicate_options)). % Declarations. -:- use_module(generics(codes_ext)). +:- use_module(generics(code_ext)). :- use_module(generics(db_ext)). :- use_module(os(file_ext)). :- use_module(os(run_ext)). -:- use_module(svg(svg_file)). :- use_module(plGraphViz(gv_dot)). @@ -136,15 +131,12 @@ file_to_gv(FromFile, ToFile, Options):- prolog_file_type(ToExtension, graphviz_output), !, % The output file is either given or created. - ( - var(ToFile) - -> - user:prolog_file_type(ToExtension, ToFileType), - file_alternative(FromFile, _, _, ToExtension, ToFile) - ; - is_absolute_file_name(ToFile), - % The given output file must match a certain file extension. - file_name_extension(_, ToExtension, ToFile) + ( var(ToFile) + -> user:prolog_file_type(ToExtension, ToFileType), + file_alternative(FromFile, _, _, ToExtension, ToFile) + ; is_absolute_file_name(ToFile), + % The given output file must match a certain file extension. + file_name_extension(_, ToExtension, ToFile) ), % Now that we have the output file we can prevent the % file type / file extension translation predicates from bakctracking. @@ -154,6 +146,8 @@ file_to_gv(FromFile, ToFile, Options):- format(atom(OutputType), '-T~w', [ToExtension]), process_create( path(Method), + % @tbd Windows hack: + %%%%'C:\\Program Files (x86)\\Graphviz2.38\\bin\\dot.exe', [OutputType,FromFile,'-o',ToFile], [process(PID)] ), @@ -177,20 +171,6 @@ gif_to_gv_file(Gif, ToFile, Options):- codes_to_gv_file(Codes, ToFile, Options). -%! gif_to_svg_dom( -%! +GraphInterchangeFormat:compound, -%! -SvgDom:list(compound), -%! +Options:list(nvpair) -%! ) is det. - -gif_to_svg_dom(Gif, SvgDom, Options1):- - % Make sure the file type of the output file is SvgDom. - merge_options([to_file_type=svg], Options1, Options2), - gif_to_gv_file(Gif, ToFile, Options2), - file_to_svg(ToFile, SvgDom), - delete_file(ToFile). - - %! open_dot(+File:atom) is det. % Opens the given DOT file. % diff --git a/gv_html.pl b/gv_html.pl index 3f0b08b..08306f0 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -1,60 +1,224 @@ :- module( gv_html, [ - gv_html_like_label//1 % +Codes:list(code) + gv_html_like_label//1 % +Content:compound ] ). -/** GraphViz HTML +/** GraphViz: HTML-like labels + +Grammar taken from the GraphViz Web site: + +``` +label : text + | table +text : textitem + | text textitem +textitem : string + |
+ | text + | text + | text + | text + | text + | text + | text + | text +table : [ ] rows
[
] +rows : row + | rows row + | rows
row +row: cells +cells : cell + | cells cell + | cells cell +cell: label + | +``` @author Wouter Beek -@version 2013/07, 2013/09, 2014/03-2014/06 +@see http://www.graphviz.org/content/node-shapes#html +@version 2013/07, 2013/09, 2014/03-2014/06, 2014/11 */ +:- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_bracket)). :- use_module(plDcg(dcg_content)). :- use_module(plHtml(html_dcg)). -%! gv_html_label(+Codes:list(code))// . +%! gv_html_like_label(?Content:compound)// . + +gv_html_like_label(Content) --> + bracketed(angular, label(Content)). + + +%! cell(?Contents:compound)// . +% Supported attributes for TD: +% ``` +% ALIGN="CENTER|LEFT|RIGHT|TEXT" +% BALIGN="CENTER|LEFT|RIGHT" +% BGCOLOR="color" +% BORDER="value" +% CELLPADDING="value" +% CELLSPACING="value" +% COLOR="color" +% COLSPAN="value" +% FIXEDSIZE="FALSE|TRUE" +% GRADIENTANGLE="value" +% HEIGHT="value" +% HREF="value" +% ID="value" +% PORT="portName" +% ROWSPAN="value" +% SIDES="value" +% STYLE="value" +% TARGET="value" +% TITLE="value" +% TOOLTIP="value" +% VALIGN="MIDDLE|BOTTOM|TOP" +% WIDTH="value" +% ``` % -% @see http://www.graphviz.org/doc/info/shapes.html#html - -gv_html_label --> gv_html_text, !. -gv_html_label --> gv_html_table, !. -gv_html_label --> []. - -gv_html_like_label --> bracketed(angular, gv_html_label). - -gv_html_like_label(Content) --> bracketed(angular, html_dcg(Content)). - -gv_html_table --> html_element(table, _, gv_html_rows). -gv_html_table --> html_element(font, _, html_element(table, _, gv_html_rows)). - -gv_html_rows --> gv_html_row, gv_html_rows. -gv_html_rows --> gv_html_row, html_element(hr, _), gv_html_rows. -gv_html_rows --> gv_html_row. - -gv_html_row --> html_element(tr, _, gv_html_cells). - -gv_html_cell --> html_element(td, _, gv_html_label). -gv_html_cell --> html_element(td, _, html_element(img, _)). - -gv_html_cells --> gv_html_cell, gv_html_cells. -gv_html_cells --> gv_html_cell. -gv_html_cells --> gv_html_cell, html_element(vr, _), gv_html_cells. - -gv_html_text --> gv_html_textitem, gv_html_text. -gv_html_text --> gv_html_textitem. - -gv_html_textitem --> html_string, !. -gv_html_textitem --> html_entity, !. -gv_html_textitem --> html_element(br, _), !. -gv_html_textitem --> html_element(font, _, gv_html_text), !. -gv_html_textitem --> html_element(i, _, gv_html_text), !. -gv_html_textitem --> html_element(b, _, gv_html_text), !. -gv_html_textitem --> html_element(u, _, gv_html_text), !. -gv_html_textitem --> html_element(sub, _, gv_html_text), !. -gv_html_textitem --> html_element(sup, _, gv_html_text), !. - +% Supported attributes for IMG: +% ``` +% SCALE="FALSE|TRUE|WIDTH|HEIGHT|BOTH" +% SRC="value" +% ``` + +cell(td(Contents)) --> + html_element(td, [], label(Contents)). +cell(td(img)) --> + html_element(td, [], html_element(img)). + + +%! cells(?Contents:list(compound))// . + +cells([H|T]) --> + cell(H), + cells(T). +cells([H,vr|T]) --> + cell(H), + html_element(vr), + cells(T). +cells([H]) --> + cell(H). + + +%! label(?Content:compound)// . +% GraphViz HTML-like label. + +label(Content) --> + text(Content). +label(Content) --> + table(Content). + + +%! row(?Contents:compound)// . + +row(tr(Contents)) --> + html_element(tr, [], cell(Contents)). + + +%! rows(?Contents:list)// . + +rows([H|T]) --> + row(H), + rows(T). +rows([H,hr|T]) --> + row(H), + html_element(hr), + rows(T). +rows([H]) --> + row(H). + + +%! table(?Contents:compound)// . +% Supported attributes for TABLE: +% ``` +% ALIGN="CENTER|LEFT|RIGHT" +% BGCOLOR="color" +% BORDER="value" +% CELLBORDER="value" +% CELLPADDING="value" +% CELLSPACING="value" +% COLOR="color" +% COLUMNS="value" +% FIXEDSIZE="FALSE|TRUE" +% GRADIENTANGLE="value" +% HEIGHT="value" +% HREF="value" +% ID="value" +% PORT="portName" +% ROWS="value" +% SIDES="value" +% STYLE="value" +% TARGET="value" +% TITLE="value" +% TOOLTIP="value" +% VALIGN="MIDDLE|BOTTOM|TOP" +% WIDTH="value" +% ``` +% +% Supported attributes for FONT: +% ``` +% COLOR="color" +% FACE="fontname" +% POINT-SIZE="value" +% ``` + +table(table(Attrs,Contents)) --> + html_element(table, Attrs, rows(Contents)). +table(table(font(Contents))) --> + html_element(font, [], html_element(table, [], rows(Contents))). + + +%! text(?Contents:list)// . + +text(Contents) --> + '+'(textitem, Contents, []). + + +%! textitem(?Content)// . +% Supported attributes for BR: +% ``` +% ALIGN="CENTER|LEFT|RIGHT" +% ``` + +textitem(string(String)) --> + html_string(String). +textitem(entity(Name)) --> + html_entity(Name). +textitem(br(Attrs)) --> + html_element(br, Attrs). +textitem(Compound) --> + {var(Compound)}, !, + html_element(Name, _, text(Content)), + { + supported_html_element(Name), + Compound =.. [Name,Content] + }. +textitem(Compound) --> + { + Compound =.. [Name,Content], + supported_html_element(Name) + }, + html_element(Name, _, text(Content)). + + + +% HELPERS + +%! supported_html_element(+Name:atom) is semidet. +%! supported_html_element(-Name:atom) is multi. + +supported_html_element(b). +supported_html_element(font). +supported_html_element(i). +supported_html_element(o). +supported_html_element(s). +supported_html_element(sub). +supported_html_element(sup). +supported_html_element(u). diff --git a/gv_numeral.pl b/gv_numeral.pl index 7870eb1..c115372 100644 --- a/gv_numeral.pl +++ b/gv_numeral.pl @@ -14,59 +14,67 @@ :- use_module(math(math_ext)). :- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_ascii)). :- use_module(plDcg(dcg_cardinal)). %! gv_numeral(?Value:number)// . -% ~~~{.bnf} +% +% # Syntax +% +% ```bnf % ('-')? ( '.' [0-9]+ | [0-9]+ ( '.' [0-9]* )? ) -% ~~~ +% ``` +% +% ## Generation +% +% In the generative case, three notations are allowed (also see below): +% 1. (non-zero integer-part) +% 2. (decimal-separator) (non-zero fractional) +% 3. (non-zero integer-part) (decimal-separator) (non-zero fractional) +% +% The following notations are explicitly excluded due to verbosity: +% - (non-zero integer-part) (decimal-separator) +% - (non-zero integer-part) (decimal-separator) (zero fractional) +% - (zero integer-part) (decimal-separator) (non-zero fractional) +% +% The following notations are also excluded, but since they violate +% well-formedness: +% - (non-zero integer-part) (non-zero fractional) +% - (decimal-separator) gv_numeral(N) --> - {nonvar(N)}, - {number_sign_parts(N, Sign, Abs)}, - ({Sign =:= -1} -> `-` ; ``), - gv_numeral_abs(Abs). + {var(N)}, !, + sign(Sign), + ( ".", + '+'(decimal_digit, Fractional, [convert1(weights_decimal)]), + {IntegerPart = 0} + ; '+'(decimal_digit, IntegerPart, [convert1(weights_decimal)]), + ( ".", + '*'(decimal_digit, Fractional, [convert1(weights_decimal)]) + ; {Fractional = 0} + ) + ), + { number_integer_parts(UnsignedN, IntegerPart, Fractional), + N is copysign(UnsignedN, Sign) + }. gv_numeral(N) --> - {var(N)}, - 'sign?'(Sign), - gv_numeral_abs(Abs), - {number_sign_parts(N, Sign, Abs)}. - - -gv_numeral_abs(N) --> - {nonvar(N)}, - {number_integer_parts(N, N1, N2)}, - ( - {N2 =:= 0} - -> - integer(N1) - ; - {N1 =:= 0} - -> - `.`, - integer(N2) - ; - integer(N1), - '?'((`.`, 'integer?'(N2)), []) + {number_sign_parts(N, Sign, UnsignedN)}, + sign(Sign), + {number_integer_parts(UnsignedN, IntegerPart, Fractional)}, + ( % [1] The fractional is zero, so only write the integer part + % and do not write the decimal separator. + {Fractional =:= 0} + -> integer(IntegerPart) + ; % [2] The integer part is zero, so only write the fractional part, + % preceded by the decimal separator. + {IntegerPart =:= 0} + -> ".", + integer(Fractional) + ; % [3] Both the integer part and the fractional are non-zero, + % so write both of them, with the decimal separator in-between. + integer(IntegerPart), + ".", + integer(Fractional) ). -gv_numeral_abs(N) --> - {var(N)}, - ( - `.`, - integer(N2) - -> - {N1 = 0} - ; - integer(N1), - ( - `.` - -> - 'integer?'(N2) - ; - {N2 = 0} - ) - ), - {number_integer_parts(N, N1, N2)}. - diff --git a/load.pl b/load.pl index 4b117d1..5cec32c 100644 --- a/load.pl +++ b/load.pl @@ -1,12 +1,14 @@ -% Load file for plGraphViz. +% Load file for the plGraphViz library. -:- dynamic(user:prolog/3). -:- multifile(user:prolog/3). - user:project(plGraphViz, 'GraphViz support for SWI-Prolog.', plGraphViz). +:- dynamic(user:project/2). +:- multifile(user:project/2). + user:project(plGraphViz, 'GraphViz support for SWI-Prolog.'). :- use_module(load_project). -:- load_project(plGraphViz, [ +:- load_project([ plc-'Prolog-Library-Collection', - plHtml + plDcg, + plHtml, + plUri ]). diff --git a/plDcg b/plDcg new file mode 160000 index 0000000..ad6c88a --- /dev/null +++ b/plDcg @@ -0,0 +1 @@ +Subproject commit ad6c88a86234c50ffb31bdbfd50edf5709654f75 diff --git a/plHtml b/plHtml index 18e657b..f96e87b 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit 18e657b22a84d5e98a317ddec58314964ff68bcd +Subproject commit f96e87bb4e4fa525f5e84814914834625ac9f715 diff --git a/plUri b/plUri new file mode 160000 index 0000000..ec0a88e --- /dev/null +++ b/plUri @@ -0,0 +1 @@ +Subproject commit ec0a88e1040ea624b09904f9a76c258775e98bff diff --git a/run.pl b/run.pl new file mode 100644 index 0000000..8bba736 --- /dev/null +++ b/run.pl @@ -0,0 +1,9 @@ +% Standalone execution of the plGraphViz library. + +:- if(current_prolog_flag(argv, ['--debug'|_])). + :- ensure_loaded(debug). +:- else. + :- set_prolog_flag(verbose, silent). + :- ensure_loaded(load). +:- endif. + ```

55: 正在比较变动前 dbc602d 和变动后 a2456df

[back to content](#compare) ``` diff diff --git a/gv_color.pl b/gv_color.pl index c48817c..0510f98 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -22,6 +22,7 @@ :- use_module(library(xpath)). :- use_module(generics(db_ext)). +:- use_module(generics(persistent_db_ext)). :- use_module(os(file_ext)). :- use_module(os(file_gnu)). @@ -121,9 +122,7 @@ gv_color_file(File):- gv_color_init:- gv_color_file(File), - safe_db_attach(File), - file_age(File, Age), - gv_color_update(Age). + persistent_db_init(File, gv_color_update). %! gv_color_update(+Age:float) is det. diff --git a/plHtml b/plHtml index f96e87b..c98f740 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit f96e87bb4e4fa525f5e84814914834625ac9f715 +Subproject commit c98f740d593fff74bfa3cf3d08af13c857daa899 ```

56: 正在比较变动前 a2456df 和变动后 20c6017

[back to content](#compare) ``` diff diff --git a/gv_numeral.pl b/gv_numeral.pl index c115372..d36fa59 100644 --- a/gv_numeral.pl +++ b/gv_numeral.pl @@ -61,7 +61,7 @@ gv_numeral(N) --> }. gv_numeral(N) --> {number_sign_parts(N, Sign, UnsignedN)}, - sign(Sign), + sign_negative(Sign), {number_integer_parts(UnsignedN, IntegerPart, Fractional)}, ( % [1] The fractional is zero, so only write the integer part % and do not write the decimal separator. ```

57: 正在比较变动前 20c6017 和变动后 f694d77

[back to content](#compare) ``` diff diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 2774ee9..58f43f0 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 2774ee9cba6ac2353150322c744e65857634e575 +Subproject commit 58f43f0e2fca088206582a18b868fe85a7603432 diff --git a/plDcg b/plDcg index ad6c88a..c61080f 160000 --- a/plDcg +++ b/plDcg @@ -1 +1 @@ -Subproject commit ad6c88a86234c50ffb31bdbfd50edf5709654f75 +Subproject commit c61080f3d8df6ba6d48b0d70f5ba52047c8cbd29 diff --git a/plUri b/plUri index ec0a88e..66a7652 160000 --- a/plUri +++ b/plUri @@ -1 +1 @@ -Subproject commit ec0a88e1040ea624b09904f9a76c258775e98bff +Subproject commit 66a7652bc1ab6a4dc1fc790b09894d6c51d42dcf ```

58: 正在比较变动前 f694d77 和变动后 af5d96d

[back to content](#compare) ``` diff diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 58f43f0..1b264ab 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 58f43f0e2fca088206582a18b868fe85a7603432 +Subproject commit 1b264ab8b668b44035c96f320f8798f7940ad2fa diff --git a/README.md b/README.md index 3c9e9cf..f89c694 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,113 @@ plGraphViz ========== -Export graphs represented as Prolog terms to +Easily export graphs represented as Prolog terms to [GraphViz](http://www.graphviz.org/). -Author: [Wouter Beek](http://www.wouterbeek.com) +### Example + +~~~prolog +$ swipl run.pl +?- use_module(plGraphViz(gv_file)). +?- graph_to_gv_file( + graph([vertex(1,[]),vertex(2,[])],[edge(1,2,[])],[]), + File, + [method(sfdp),output(png)] + ). + File = 'PATH/plGraphViz/data/tmp.png' +~~~ + +The graphic can be saved to a different file by instantiating + the `File` argument. + +![](https://raw.githubusercontent.com/wouterbeek/plGraphViz/master/example1.png "Example graph.") + +--- + +### Method option + +Option `method(+atom)` sets the drawing method that is used by GraphViz + to place the vertices and edges. +The following values are supported. + +| **Value** | **Description** | +| `circo` | Circular layout. | +| `dot` (default) | Directed graph. | +| `fdp` | Undirected graph. | +| `neato` | Undirected graph. | +| `osage` | Tree map. | +| `sfdp` | Large undirected graph. | +| `twopi` | Radical layouts. | + +--- + +### Output type option + +Option `output(+atom)` sets the type of file the graph is written to. +The following values are supported. + +| **Value** | **Description** | +|:---------------------:|:--------------------------------------| +| `bmp` | Windows Bitmap Format | +| `canon` | | +| `dot` | | +| `gv`, `xdot`, `xdot1.2`, `xdot1.4` | DOT | +| `cgimage` | CGImage bitmap format | +| `cmap` | Client-side imagemap (deprecated) | +| `eps` | Encapsulated PostScript | +| `exr` | OpenEXR | +| `fig` | | +| `gd`, `gd2` | GD/GD2 formats | +| `gif` | | +| `gtk` | GTK canvas | +| `ico` | Icon Image File Format | +| `imap` | | +| `cmapx` | Server-side and client-side imagemaps | +| `imap_np`, `cmapx_np` | Server-side and client-side imagemaps | +| `ismap` | Server-side imagemap (deprecated) | +| `jp2` | JPEG 2000 | +| `jpg`, `jpeg`, `jpe` | JPEG | +| `pct`, `pict` | PICT | +| `pdf` (default) | Portable Document Format (PDF) | +| `pic` | Kernighan's PIC graphics language | +| `plain`, `plain-ext` | Simple text format | +| `png` | Portable Network Graphics format | +| `pov` | POV-Ray markup language (prototype) | +| `ps` | PostScript | +| `ps2` | PostScript for PDF | +| `psd` | PSD | +| `sgi` | SGI | +| `svg`, `svgz` | Scalable Vector Graphics | +| `tga` | Truevision TGA | +| `tif`, `tiff` | TIFF (Tag Image File Format) | +| `tk` | TK graphics | +| `vml`, `vmlz` | Vector Markup Language (VML) | +| `vrml` | VRML | +| `wbmp` | Wireless BitMap format | +| `webp` | Image format for the Web | +| `xlib`, `x11` | Xlib canvas | + +--- + +### HTML-like labels + +Example of using HTML-like labels: + +~~~prolog +graph_to_gv_file( + graph( + [vertex(1,[]),vertex(2,[label=html(table([tr([td(a),td(b)]),tr([td(c),td(d)])]))])], + [edge(1,2,[label='From 1 to 2.'])], + [] + ), + File, + [] +). +~~~ + +![](https://raw.githubusercontent.com/wouterbeek/plGraphViz/master/example2.png "Example graph with HTML-like labels.") + +--- + +Developed during 2013-2014 by [Wouter Beek](http://www.wouterbeek.com). diff --git a/example1.png b/example1.png new file mode 100644 index 0000000..31e7ba6 Binary files /dev/null and b/example1.png differ diff --git a/example2.png b/example2.png new file mode 100644 index 0000000..6e44b16 Binary files /dev/null and b/example2.png differ diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 30761bb..3237b4b 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -54,11 +54,14 @@ :- use_module(plDcg(dcg_atom)). :- use_module(plDcg(dcg_cardinal)). :- use_module(plDcg(dcg_content)). +:- use_module(plDcg(dcg_quote)). :- use_module(plGraphViz(gv_html)). + + %! gv_attr_type(?Type:atom) is nondet. gv_attr_type(addDouble). @@ -95,6 +98,7 @@ gv_attr_type(style). gv_attr_type(viewPort). + %! addDouble(+Float:float)// . % An *addDouble* is represented by a Prolog float. @@ -103,6 +107,7 @@ addDouble(Float) --> double(Float). + %! addPoint(+Point:compound)// . % An *addPoint* is represented by a compound of the following form: % `point(X:float,Y:float,InputOnly:boolean)`. @@ -112,6 +117,7 @@ addPoint(Point) --> point(Point). + %! arrowType(+ArrowType:atom)// . arrowType(V) --> @@ -149,12 +155,16 @@ backwards_compatible(invempty). backwards_compatible(open). + +%! bool(+Value:boolean)// . + bool(false) --> "false". bool(false) --> "no". bool(true) --> "true". bool(true) --> "yes". + %! clusterMode(+ClusterMode:atom)// . clusterMode(V) --> @@ -166,6 +176,7 @@ clusterMode(local). clusterMode(none). + %! dirType(+DirectionType:oneof([back,both,forward,none]))// . dirType(DirType) --> @@ -178,44 +189,57 @@ dirType(forward). dirType(none). + +%! double(+Double:float)// . + double(Double1) --> % float//1 will check for float type. {Double2 is Double1 * 1.0}, float(Double2). -doubleList([H|T]) --> - double(H), - '*'(doubleList1, T, []). -doubleList1(Float) --> - ":", - double(Float). +%! doubleList(+Doubles:list(float))// . + +doubleList(L) --> + '+'(double, L, [separator(colon)]). + %! escString(+String:atom)// . % @tbd Support for context-dependent replacements. escString(String) --> - atom(String). + quoted(atom(String)). + % @tbd layerList + % @tbd layerRange + +%! lblString(+String:compound)// . + +lblString(html(V)) --> + gv_html_like_label(V). lblString(V) --> escString(V). -lblString(V) --> - gv_html_like_label(V). + +%! int(+Integer:integer)// . + int(V) --> integer(V). + +%! outputMode(+OutputMode:atom)// . + outputMode(V) --> {outputMode(V)}, atom(V). @@ -225,9 +249,13 @@ outputMode(edgesfirst). outputMode(nodesfirst). + % @tbd packMode + +%! pagedir(+PageDirection:atom)// . + pagedir(V) --> {pagedir(V)}, atom(V). @@ -242,6 +270,7 @@ pagedir('TL'). pagedir('TR'). + %! point(+Point:compound)// . % A *point* is represented by a compound of the following form: % `point(X:float,Y:float,Changeable:boolean)`. @@ -256,13 +285,20 @@ input_changeable(false) --> "". input_changeable(true) --> "!". + +%! pointList(+Points:list(compound))// . + pointList(Points) --> '*'(point, Points, []). + % @tbd portPos + +%! quadType(+QuadType:atom)// . + quadType(V) --> {quadType(V)}, atom(V). @@ -272,6 +308,9 @@ quadType(none). quadType(normal). + +%! rankType(+RankType:atom)// . + rankType(V) --> {rankType(V)}, atom(V). @@ -283,6 +322,9 @@ rankType(sink). rankType(source). + +%! rankdir(+RankDirection:atom)// . + rankdir(V) --> {rankdir(V)}, atom(V). @@ -293,6 +335,9 @@ rankdir('RL'). rankdir('TB'). + +%! rect(+Rectangle:compound)// . + rect(rect(LowerLeftX,LowerLeftY,UpperRightX,UpperRightY)) --> float(LowerLeftX), ",", float(LowerLeftY), ",", @@ -300,6 +345,9 @@ rect(rect(LowerLeftX,LowerLeftY,UpperRightX,UpperRightY)) --> float(UpperRightY). + +%! shape(+Shape:atom)// . + shape(V) --> {polygon_based_shape(V)}, atom(V). @@ -361,6 +409,9 @@ polygon_based_shape(tripleoctagon). polygon_based_shape(utr). + +%! smoothType(+SmoothType:atom)// . + smoothType(V) --> {smoothType(V)}, atom(V). @@ -374,19 +425,23 @@ smoothType(spring). smoothType(triangle). + % @tbd splineType + % @tbd startType -%! string(?Content:atom)// . + +%! string(?String:atom)// . % A GraphViz string. string(Content) --> atom(Content). + %! style(?Context:oneof([cluster,edge,node]), ?Style:atom) is nondet. style(Context, Style) --> @@ -415,4 +470,5 @@ style(node, striped). style(node, wedged). + % @tbd viewPort diff --git a/gv_attrs.pl b/gv_attrs.pl index 649ef9c..e3ba03c 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -1,9 +1,8 @@ :- module( gv_attrs, [ - gv_attr/3 % +Context:oneof([cluster,edge,graph,node,subgraph]) - % +Attribute1:nvpair - % -Attribute2:nvpair + gv_attr_value//2 % +Context:oneof([cluster,edge,graph,node,subgraph]) + % +Attribute:nvpair ] ). @@ -25,6 +24,7 @@ Support for GraphViz attributes. :- use_module(plDcg(dcg_atom)). :- use_module(plDcg(dcg_content)). +:- use_module(plDcg(dcg_meta)). :- use_module(plDcg(dcg_generics)). :- use_module(plHtml(html)). @@ -58,32 +58,45 @@ Support for GraphViz attributes. -%! gv_attr( + + +%! gv_attr_value( %! +Context:oneof([cluster,edge,graph,node,subgraph]), -%! +Attribute1:nvpair, -%! +Attribute2:nvpair -%! ) is det. +%! +Attribute:nvpair +%! )// is det. % Uses the default value in case Value is uninstantiated. % Otherwise, performs a typecheck and converts the given value. -gv_attr(Context, N=V, N=V):- - var(V), !, - gv_attr(N, UsedBy, _, V, _, _), - % Check validity of context. - memberchk(Context, UsedBy). -gv_attr(Context, N=V1, N=V2):- - gv_attr(N, UsedBy, Types, _, Minimum, _), - % Check validity of context. - memberchk(Context, UsedBy), - % Check validity of value type. - member(Type, Types), - ( Type == style - -> Dcg =.. [Type,Context,V1] - ; Dcg =.. [Type,V1] - ), - once(dcg_phrase(Dcg, V2)), - % Check validity of Value w.r.t. minimum value -- if available. - check_minimum(V1, Minimum). +% Use the default if no value is given. +gv_attr_value(Context, Name=Value) --> + { + var(Value), !, + gv_attr(Name, UsedBy, _, DefaultValue, _, _), + % Check validity of context. + memberchk(Context, UsedBy) + }, + gv_attr_value(Context, Name=DefaultValue). +gv_attr_value(Context, Name=Value) --> + { + % Check the validity of the context argument. + gv_attr(Name, UsedBy, Types, _, Minimum, _), + memberchk(Context, UsedBy), + + % Pick a value type non-deterministically. + member(Type, Types), + + % The `style` type is the only one that requires the context argument. + ( Type == style + -> Dcg =.. [Type,Context] + ; Dcg =.. [Type] + ), + + % Check validity of Value w.r.t. minimum value -- if available. + check_minimum(Value, Minimum) + }, + dcg_call(Dcg, Value). + + diff --git a/gv_dot.pl b/gv_dot.pl index e67c469..6db4451 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -13,9 +13,16 @@ Methods for writing to the GraphViz DOT format. In GraphViz vertices are called 'nodes'. +~~~abnf +attr_list = "[" [a_list] "]" [attr_list] +a_list = ID "=" ID [","] [a_list] +~~~ + +--- + @author Wouter Beek @see http://www.graphviz.org/content/dot-language -@version 2013/07, 2013/09, 2014/03-2014/06 +@version 2013/07, 2013/09, 2014/03-2014/06, 2014/11 */ :- use_module(library(apply)). @@ -37,28 +44,21 @@ In GraphViz vertices are called 'nodes'. -%! gv_attribute(+Attribute:nvpair)// is det. -% A single GraphViz attribute. -% We assume that the attribute has already been validated. -gv_attribute(Name=Val) --> - gv_id(Name), "=", gv_id(Val), ";". +%! gv_attr( +%! +Context:oneof([edge,graph,node]), +%! +Attribute:nvpair +%! )// is det. +% A single GraphViz attribute. +% We assume that the attribute has already been validated. -%! gv_attribute_list( -%! +Context:oneof([cluster,edge,graph,node,subgraph]), -%! +GraphAttributes:list(nvpair), -%! +Attributes:list(nvpair) -%! )// . -% ```abnf -% attr_list = "[" [a_list] "]" [attr_list] -% a_list = ID "=" ID [","] [a_list] -% ``` +gv_attr(Context, Name=Value) --> + gv_id(Name), + "=", + gv_attr_value(Context, Name=Value), + ";". -% Attributes occur between square brackets. -gv_attribute_list(Context, _, Attrs1) --> - {maplist(gv_attr(Context), Attrs1, Attrs2)}, - bracketed(square, '*'(gv_attribute, Attrs2, [])). %! gv_compass_pt(+Direction:oneof(['_',c,e,n,ne,nw,s,se,sw,w]))// . @@ -78,6 +78,7 @@ gv_compass_pt(sw) --> "sw". gv_compass_pt(w) --> "w". + %! gv_edge_operator(+Directed:boolean)// . % The binary edge operator between two vertices. % The operator that is used depends on whether the graph is directed or @@ -90,10 +91,10 @@ gv_edge_operator(false) --> !, "--". gv_edge_operator(true) --> arrow(right, 2). + %! gv_edge_statement( %! +Indent:nonneg, %! +Directed:boolean, -%! +GraphAttributes:list(nvpair), %! +EdgeTerm:compound %! )// is det. % A GraphViz statement describing an edge. @@ -108,7 +109,7 @@ gv_edge_operator(true) --> arrow(right, 2). % at the from and/or to location. % @tbd Add support for multiple, consecutive occurrences of gv_edge_rhs//2. -gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> +gv_edge_statement(I, Directed, edge(FromId,ToId,EAttrs)) --> indent(I), gv_node_id(FromId), " ", @@ -118,14 +119,14 @@ gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> % We want `colorscheme/1` from the edges and % `directionality/1` from the graph. - gv_attribute_list(edge, GAttrs, EAttrs), + bracketed(square, '*'(gv_attr(edge), EAttrs, [])), line_feed. + %! gv_generic_attributes_statement( %! +Kind:oneof([edge,graph,node]), %! +Indent:integer, -%! +GraphAttributes:list(nvpair), %! +CategoryAttributes:list(nvpair) %! )// % A GraphViz statement describing generic attributes for a category of items. @@ -140,11 +141,13 @@ gv_edge_statement(I, Directed, GAttrs, edge(FromId,ToId,EAttrs)) --> % attr_stmt = (graph / node / edge) attr_list % ``` -gv_generic_attributes_statement(_, _, _, []) --> [], !. -gv_generic_attributes_statement(Kind, I, GraphAttrs, KindAttrs) --> +gv_generic_attributes_statement(_, _, []) --> [], !. +gv_generic_attributes_statement(Kind, I, KindAttrs) --> indent(I), gv_kind(Kind), " ", - gv_attribute_list(Kind, GraphAttrs, KindAttrs), line_feed. + bracketed(square, '*'(gv_attr(Kind), KindAttrs, [])), + line_feed. + %! gv_graph(+Gif:compound)// @@ -224,13 +227,13 @@ gv_graph0( {NewI is I + 1}, % Attributes that apply to the graph as a whole. - gv_generic_attributes_statement(graph, NewI, GAttrs, GAttrs), + gv_generic_attributes_statement(graph, NewI, GAttrs), % Attributes that are the same for all nodes. - gv_generic_attributes_statement(node, NewI, GAttrs, SharedVAttrs), + gv_generic_attributes_statement(node, NewI, SharedVAttrs), % Attributes that are the same for all edges. - gv_generic_attributes_statement(edge, NewI, GAttrs, SharedEAttrs), + gv_generic_attributes_statement(edge, NewI, SharedEAttrs), % Only add a line_feed if some content was already written % and some content is about to be written. @@ -249,19 +252,19 @@ gv_graph0( ), % The list of GraphViz nodes. - '*'(gv_node_statement(NewI, GAttrs), NewVTerms, []), + '*'(gv_node_statement(NewI), NewVTerms, []), ({NewVTerms == []} -> "" ; line_feed), % The ranked GraphViz nodes (displayed at the same height). - '*'(gv_ranked_node_collection(NewI, GAttrs), RankedVTerms, []), + '*'(gv_ranked_node_collection(NewI), RankedVTerms, []), ({RankedVTerms == []} -> "" ; line_feed), { findall( edge(FromId,ToId,[]), ( - nth0(Index1, RankedVTerms, rank(vertex(FromId,_,_),_)), - nth0(Index2, RankedVTerms, rank(vertex(ToId,_,_),_)), + nth0(Index1, RankedVTerms, rank(vertex(FromId,_),_)), + nth0(Index2, RankedVTerms, rank(vertex(ToId,_),_)), % We assume that the rank vertices are nicely ordered. succ(Index1, Index2) ), @@ -270,10 +273,10 @@ gv_graph0( }, % The rank edges. - '*'(gv_edge_statement(NewI, Directed, GAttrs), RankEdges, []), + '*'(gv_edge_statement(NewI, Directed), RankEdges, []), % The non-rank edges. - '*'(gv_edge_statement(NewI, Directed, GAttrs), NewETerms, []), + '*'(gv_edge_statement(NewI, Directed), NewETerms, []), % Note that we do not include a line_feed here. @@ -281,6 +284,7 @@ gv_graph0( indent(I). + %! gv_graph_type(+Directed:boolean)// . % The type of graph that is represented. @@ -288,6 +292,7 @@ gv_graph_type(false) --> "graph". gv_graph_type(true) --> "digraph". + %! gv_id(?Atom:atom)// is det. % Parse a GraphViz identifier. % There are 4 variants: @@ -347,6 +352,7 @@ gv_id_rest([H|T]) --> gv_id_rest(T). + %! gv_keyword(+Codes:list(code)) is semidet. % Succeeds if the given codes for a GraphViz reserved keyword. @@ -367,6 +373,7 @@ gv_keyword --> "strict". gv_keyword --> "subgraph". + %! gv_kind(+Kind:oneof([edge,graph,node]))// . gv_kind(edge) --> "edge". @@ -374,6 +381,7 @@ gv_kind(graph) --> "graph". gv_kind(node) --> "node". + %! gv_node_id(+NodeId:atom)// . % GraphViz node identifiers can be of the following two types: % 1. A GraphViz identifier, see gv_id//1. @@ -389,17 +397,16 @@ gv_node_id(Id) --> % gv_port. -%! gv_node_statement( -%! +Indent:integer, -%! +GraphAttributes, -%! +VertexTerm:compound -%! )// . + +%! gv_node_statement(+Indent:nonneg, +VertexTerm:compound)// . % A GraphViz statement describing a vertex (GraphViz calls vertices 'nodes'). -gv_node_statement(I, GraphAttrs, vertex(Id,_,VAttrs)) --> +gv_node_statement(I, vertex(Id,VAttrs)) --> indent(I), gv_node_id(Id), " ", - gv_attribute_list(node, GraphAttrs, VAttrs), line_feed. + bracketed(square, '*'(gv_attr(node), VAttrs, [])), + line_feed. + gv_port --> @@ -431,6 +438,7 @@ gv_port_location --> ). + gv_quoted_string([]) --> []. % Just to be sure, we do not allow the double quote % that closes the string to be escaped. @@ -450,21 +458,22 @@ gv_quoted_string([H|T]) --> gv_quoted_string(T). -gv_ranked_node_collection( - I, - GraphAttrs, - rank(Rank_V_Term,Content_V_Terms) -) --> + +gv_ranked_node_collection(I, rank(Rank_V_Term,Content_V_Terms)) --> indent(I), bracketed(curly, ( line_feed, % The rank attribute. {NewI is I + 1}, - indent(NewI), gv_attribute(rank=same), ";", line_feed, + indent(NewI), + gv_attr(subgraph, rank=same), + ";", + line_feed, + % Vertice statements. '*'( - gv_node_statement(NewI, GraphAttrs), + gv_node_statement(NewI), [Rank_V_Term|Content_V_Terms], [] ), @@ -475,6 +484,7 @@ gv_ranked_node_collection( line_feed. + %! gv_strict(+Strict:boolean)// is det. % The keyword denoting that the graph is strict, i.e., has no self-arcs and % no multi-edges. @@ -485,7 +495,9 @@ gv_strict(true) --> "strict ". -% Helpers + + +% HELPERS add_default_nvpair(Attrs1, N, Default, Attrs2):- add_default_nvpair(Attrs1, N, Default, _, Attrs2). @@ -508,12 +520,15 @@ extract_shared(Argss, Shared):- remove_shared_attributes(Shared, Args1, Args2):- ord_subtract(Args1, Shared, Args2). -shared_attributes(Terms1, Shared, Terms2):- - maplist(term_components(Func), Terms1, Args1, Args2, Args3a), - extract_shared(Args3a, Shared), - maplist(remove_shared_attributes(Shared), Args3a, Args3b), - maplist(term_components(Func), Terms2, Args1, Args2, Args3b). +shared_attributes(Terms1, SharedAs, Terms2):- + maplist(term_to_attrs, Terms1, As1), + extract_shared(As1, SharedAs), + maplist(remove_shared_attributes(SharedAs), As1, As2), + maplist(term_change_attrs, Terms1, As2, Terms2). + +term_change_attrs(edge(From,To,_), A, edge(From,To,A)). +term_change_attrs(vertex(Id,_), A, vertex(Id,A)). -term_components(Func, Term, Arg1, Arg2, Arg3):- - Term =.. [Func,Arg1,Arg2,Arg3]. +term_to_attrs(edge(_,_,A), A). +term_to_attrs(vertex(_,A), A). diff --git a/gv_file.pl b/gv_file.pl index 704e2d4..a7901e4 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -1,14 +1,14 @@ :- module( gv_file, [ - file_to_gv/2, % +File:atom + file_to_gv/2, % +InputFile:atom % +Options:list(nvpair) - file_to_gv/3, % +FromFile:atom - % ?ToFile:atom + file_to_gv/3, % +InputFile:atom + % ?OutputFile:atom % +Options:list(nvpair) - gif_to_gv_file/3, % +GraphInterchangeFormat:compound - % ?ToFile:atom - % +Options:list(nvpair) + graph_to_gv_file/3, % +Graph:compound + % ?OutputFile:atom + % +Options:list(nvpair) open_dot/1 % +File:file ] ). @@ -35,44 +35,6 @@ and GraphViz output files or SVG DOM structures. :- use_module(plGraphViz(gv_dot)). -:- dynamic(user:file_type_program/2). -:- multifile(user:file_type_program/2). - -:- dynamic(user:module_uses/2). -:- multifile(user:module_uses/2). - -:- dynamic(user:prolog_file_type/2). -:- multifile(user:prolog_file_type/2). - -% Register DOT. -:- db_add_novel(user:prolog_file_type(dot, dot)). -:- db_add_novel(user:prolog_file_type(dot, graphviz)). -:- db_add_novel(user:file_type_program(dot, dotty)). -:- db_add_novel(user:file_type_program(dot, dotx)). -:- db_add_novel(user:module_uses(gv_file, file_type(dot))). - -% Register JPG/JPEG. -:- db_add_novel(user:prolog_file_type(jpeg, jpeg)). -:- db_add_novel(user:prolog_file_type(jpeg, graphviz_output)). -:- db_add_novel(user:prolog_file_type(jpg, jpeg)). -:- db_add_novel(user:prolog_file_type(jpg, graphviz_output)). - -% Register PDF. -:- db_add_novel(user:prolog_file_type(pdf, pdf)). -:- db_add_novel(user:prolog_file_type(pdf, graphviz_output)). - -% Register PNG. -:- db_add_novel(user:prolog_file_type(png, png)). -:- db_add_novel(user:prolog_file_type(png, graphviz_output)). - -% Register SVG. -:- db_add_novel(user:prolog_file_type(svg, graphviz_output)). -:- db_add_novel(user:prolog_file_type(svg, svg)). - -% Register XDOT. -:- db_add_novel(user:prolog_file_type(xdot, graphviz_output)). -:- db_add_novel(user:prolog_file_type(xdot, xdot)). - :- predicate_options(codes_to_gv_file/3, 3, [ pass_to(file_to_gv/3, 3) ]). @@ -80,13 +42,13 @@ and GraphViz output files or SVG DOM structures. pass_to(file_to_gv/3, 3) ]). :- predicate_options(file_to_gv/3, 3, [ - method(+oneof([dot,sfdp])), - to_file_type(+oneof([dot,jpeg,pdf,svg,xdot])) + method(+atom), + output(+atom) ]). :- predicate_options(gif_to_svg_dom/3, 3, [ - pass_to(gif_to_gv_file/3, 3) + pass_to(graph_to_gv_file/3, 3) ]). -:- predicate_options(gif_to_gv_file/3, 3, [ +:- predicate_options(graph_to_gv_file/3, 3, [ pass_to(codes_to_gv_file/3, 3) ]). @@ -94,81 +56,93 @@ and GraphViz output files or SVG DOM structures. %! codes_to_gv_file( %! +Codes:list(code), -%! ?ToFile:atom, +%! ?OutputFile:atom, %! +Options:list(nvpair) %! ) is det. -codes_to_gv_file(Codes, ToFile, Options):- - absolute_file_name(data(tmp), TmpFile, [access(write),file_type(dot)]), +codes_to_gv_file(Codes, OutputFile, Options):- + absolute_file_name(data(tmp), TmpFile, [access(write),extensions([dot])]), setup_call_cleanup( open(TmpFile, write, Write, [encoding(utf8)]), put_codes(Write, Codes), close(Write) ), - file_to_gv(TmpFile, ToFile, Options). + file_to_gv(TmpFile, OutputFile, Options). + -%! file_to_gv(+FromFile:atom, +Options:list(nvpair)) is det. +%! file_to_gv(+InputFile:atom, +Options:list(nvpair)) is det. -file_to_gv(FromFile, Options):- - file_to_gv(FromFile, _, Options). +file_to_gv(InputFile, Options):- + file_to_gv(InputFile, _, Options). -%! file_to_gv(+FromFile:atom, ?ToFile:atom, +Options:list(nvpair)) is det. +%! file_to_gv( +%! +InputFile:atom, +%! ?OutputFile:atom, +%! +Options:list(nvpair) +%! ) is det. % Converts a GraphViz DOT file to an image file, using a specific % visualization method. -file_to_gv(FromFile, ToFile, Options):- - option(to_file_type(dot), Options), !, - rename_file(FromFile, ToFile). -file_to_gv(FromFile, ToFile, Options):- - % The method option. +file_to_gv(InputFile, OutputFile, Options):- + option(output(dot), Options), !, + ( var(OutputFile) + -> OutputFile = InputFile + ; rename_file(InputFile, OutputFile) + ). +file_to_gv(InputFile, OutputFile, Options):- + % Typecheck for `method` option. option(method(Method), Options, dot), - must_be(oneof([dot,sfdp]), Method), + findall(Method0, gv_method(Method0), Methods), + must_be(oneof(Methods), Method), - % The file type option. - option(to_file_type(ToFileType), Options, pdf), - prolog_file_type(ToExtension, ToFileType), - prolog_file_type(ToExtension, graphviz_output), !, + % Typecheck for `output` option. + option(output(OutputType), Options, pdf), + findall(OutputType0, gv_output_type(OutputType0), OutputTypes), + must_be(oneof(OutputTypes), OutputType), % The output file is either given or created. - ( var(ToFile) - -> user:prolog_file_type(ToExtension, ToFileType), - file_alternative(FromFile, _, _, ToExtension, ToFile) - ; is_absolute_file_name(ToFile), + ( var(OutputFile) + -> file_alternative(InputFile, _, _, OutputType, OutputFile) + ; is_absolute_file_name(OutputFile), % The given output file must match a certain file extension. - file_name_extension(_, ToExtension, ToFile) + file_name_extension(_, OutputType, OutputFile) ), - % Now that we have the output file we can prevent the - % file type / file extension translation predicates from bakctracking. - !, % Run the GraphViz conversion command in the shell. - format(atom(OutputType), '-T~w', [ToExtension]), + format(atom(OutputTypeFlag), '-T~a', [OutputType]), + format(atom(OutputFileFlag), '-o~a', [OutputFile]), process_create( path(Method), % @tbd Windows hack: %%%%'C:\\Program Files (x86)\\Graphviz2.38\\bin\\dot.exe', - [OutputType,FromFile,'-o',ToFile], + [OutputTypeFlag,file(InputFile),OutputFileFlag], [process(PID)] ), process_wait(PID, exit(ShellStatus)), exit_code_handler('GraphViz', ShellStatus). -%! gif_to_gv_file(+Gif:compound, ?ToFile:atom, +Options:list(nvpair)) is det. + +%! graph_to_gv_file( +%! +Graph:compound, +%! ?OutputFile:atom, +%! +Options:list(nvpair) +%! ) is det. % Returns a file containing a GraphViz visualization of the given graph. % % The following options are supported: -% * =|method(+Method:oneof([dot,sfdp])|= +% * `method(+Method:atom` % The algorithm used by GraphViz for positioning the tree nodes. % Either =dot= (default) or =sfdp=. -% * =|to_file_type(+FileType:oneof([dot,jpeg,pdf,svg,xdot])|= +% * `output(+FileType:atom)` % The file type of the generated GraphViz file. % Default: `pdf`. -gif_to_gv_file(Gif, ToFile, Options):- +graph_to_gv_file(Gif, OutputFile, Options):- once(phrase(gv_graph(Gif), Codes)), - codes_to_gv_file(Codes, ToFile, Options). + codes_to_gv_file(Codes, OutputFile, Options). + %! open_dot(+File:atom) is det. @@ -181,3 +155,69 @@ open_dot(File):- once(find_program_by_file_type(dot, Program)), run_program(Program, [File]). + + + +% HELPERS + +gv_method(circo). +gv_method(dot). +gv_method(fdp). +gv_method(neato). +gv_method(osage). +gv_method(sfdp). +gv_method(twopi). + + + +gv_output_type(bmp). +gv_output_type(canon). +gv_output_type(dot). +gv_output_type(gv). +gv_output_type(xdot). +gv_output_type('xdot1.2'). +gv_output_type('xdot1.4'). +gv_output_type(cgimage). +gv_output_type(cmap). +gv_output_type(eps). +gv_output_type(exr). +gv_output_type(fig). +gv_output_type(gd). +gv_output_type(gd2). +gv_output_type(gif). +gv_output_type(gtk). +gv_output_type(ico). +gv_output_type(imap). +gv_output_type(cmapx). +gv_output_type(imap_np). +gv_output_type(cmapx_np). +gv_output_type(ismap). +gv_output_type(jp2). +gv_output_type(jpg). +gv_output_type(jpeg). +gv_output_type(jpe). +gv_output_type(pct). +gv_output_type(pict). +gv_output_type(pdf). +gv_output_type(pic). +gv_output_type(plain). +gv_output_type('plain-ext'). +gv_output_type(png). +gv_output_type(pov). +gv_output_type(ps). +gv_output_type(ps2). +gv_output_type(psd). +gv_output_type(sgi). +gv_output_type(svg). +gv_output_type(svgz). +gv_output_type(tga). +gv_output_type(tif). +gv_output_type(tiff). +gv_output_type(tk). +gv_output_type(vml). +gv_output_type(vmlz). +gv_output_type(vrml). +gv_output_type(wbmp). +gv_output_type(webp). +gv_output_type(xlib). +gv_output_type(x11). diff --git a/gv_html.pl b/gv_html.pl index 08306f0..9a4d33a 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -9,7 +9,7 @@ Grammar taken from the GraphViz Web site: -``` +~~~ label : text | table text : textitem @@ -34,7 +34,9 @@ cells : cell | cells cell cell: label | -``` +~~~ + +--- @author Wouter Beek @see http://www.graphviz.org/content/node-shapes#html @@ -49,49 +51,56 @@ cell: label + + %! gv_html_like_label(?Content:compound)// . gv_html_like_label(Content) --> bracketed(angular, label(Content)). + %! cell(?Contents:compound)// . -% Supported attributes for TD: -% ``` -% ALIGN="CENTER|LEFT|RIGHT|TEXT" -% BALIGN="CENTER|LEFT|RIGHT" -% BGCOLOR="color" -% BORDER="value" -% CELLPADDING="value" -% CELLSPACING="value" -% COLOR="color" -% COLSPAN="value" -% FIXEDSIZE="FALSE|TRUE" -% GRADIENTANGLE="value" -% HEIGHT="value" -% HREF="value" -% ID="value" -% PORT="portName" -% ROWSPAN="value" -% SIDES="value" -% STYLE="value" -% TARGET="value" -% TITLE="value" -% TOOLTIP="value" -% VALIGN="MIDDLE|BOTTOM|TOP" -% WIDTH="value" -% ``` +% Supported attributes for `TD`: +% - `ALIGN="CENTER|LEFT|RIGHT|TEXT"` +% - `BALIGN="CENTER|LEFT|RIGHT"` +% - `BGCOLOR="color"` +% - `BORDER="value"` +% - `CELLPADDING="value"` +% - `CELLSPACING="value"` +% - `COLOR="color"` +% - `COLSPAN="value"` +% - `FIXEDSIZE="FALSE|TRUE"` +% - `GRADIENTANGLE="value"` +% - `HEIGHT="value"` +% - `HREF="value"` +% - `ID="value"` +% - `PORT="portName"` +% - `ROWSPAN="value"` +% - `SIDES="value"` +% - `STYLE="value"` +% - `TARGET="value"` +% - `TITLE="value"` +% - `TOOLTIP="value"` +% - `VALIGN="MIDDLE|BOTTOM|TOP"` +% - `WIDTH="value"` % -% Supported attributes for IMG: -% ``` -% SCALE="FALSE|TRUE|WIDTH|HEIGHT|BOTH" -% SRC="value" -% ``` +% Supported attributes for `IMG`: +% - `SCALE="FALSE|TRUE|WIDTH|HEIGHT|BOTH"` +% - `SRC="value"` cell(td(Contents)) --> - html_element(td, [], label(Contents)). -cell(td(img)) --> - html_element(td, [], html_element(img)). + cell(td([],Contents)). +cell(td(Attrs1,Image)) --> + {( Image =.. [img,Attrs2] + -> true + ; Image == img + -> Attrs2 = [] + )}, + html_element(td, Attrs1, html_element(img,Attrs2)). +cell(td(Attrs,Contents)) --> + html_element(td, Attrs, label(Contents)). + %! cells(?Contents:list(compound))// . @@ -107,19 +116,22 @@ cells([H]) --> cell(H). + %! label(?Content:compound)// . % GraphViz HTML-like label. label(Content) --> - text(Content). -label(Content) --> table(Content). +label(Content) --> + text(Content). + %! row(?Contents:compound)// . row(tr(Contents)) --> - html_element(tr, [], cell(Contents)). + html_element(tr, [], cells(Contents)). + %! rows(?Contents:list)// . @@ -127,72 +139,108 @@ row(tr(Contents)) --> rows([H|T]) --> row(H), rows(T). -rows([H,hr|T]) --> - row(H), +rows([hr|T]) --> html_element(hr), rows(T). rows([H]) --> row(H). + %! table(?Contents:compound)// . -% Supported attributes for TABLE: -% ``` -% ALIGN="CENTER|LEFT|RIGHT" -% BGCOLOR="color" -% BORDER="value" -% CELLBORDER="value" -% CELLPADDING="value" -% CELLSPACING="value" -% COLOR="color" -% COLUMNS="value" -% FIXEDSIZE="FALSE|TRUE" -% GRADIENTANGLE="value" -% HEIGHT="value" -% HREF="value" -% ID="value" -% PORT="portName" -% ROWS="value" -% SIDES="value" -% STYLE="value" -% TARGET="value" -% TITLE="value" -% TOOLTIP="value" -% VALIGN="MIDDLE|BOTTOM|TOP" -% WIDTH="value" -% ``` +% ~~~ +% table : [ ] rows
[
] +% ~~~ % -% Supported attributes for FONT: -% ``` -% COLOR="color" -% FACE="fontname" -% POINT-SIZE="value" -% ``` - +% Supported attributes for `TABLE`: +% - `ALIGN="CENTER|LEFT|RIGHT"` +% - `BGCOLOR="color"` +% - `BORDER="value"` +% - `CELLBORDER="value"` +% - `CELLPADDING="value"` +% - `CELLSPACING="value"` +% - `COLOR="color"` +% - `COLUMNS="value"` +% - `FIXEDSIZE="FALSE|TRUE"` +% - `GRADIENTANGLE="value"` +% - `HEIGHT="value"` +% - `HREF="value"` +% - `ID="value"` +% - `PORT="portName"` +% - `ROWS="value"` +% - `SIDES="value"` +% - `STYLE="value"` +% - `TARGET="value"` +% - `TITLE="value"` +% - `TOOLTIP="value"` +% - `VALIGN="MIDDLE|BOTTOM|TOP"` +% - `WIDTH="value"` +% +% Supported attributes for `FONT`: +% - `COLOR="color"` +% Sets the color of the font within the scope of `...`, +% or the border color of the table or cell within the scope of +% `...
`, or `...`. +% This color can be overridden by a `COLOR` attribute in descendents. +% By default, the font color is determined by the `fontcolor` attribute +% of the corresponding node, edge or graph, and the border color is +% determined by the color attribute of the corresponding node, edge or +% graph. +% - `FACE="fontname"` +% - `POINT-SIZE="value"` + +table(table(Contents)) --> + table(table([],Contents)). table(table(Attrs,Contents)) --> html_element(table, Attrs, rows(Contents)). -table(table(font(Contents))) --> - html_element(font, [], html_element(table, [], rows(Contents))). +table(font(Table)) --> + table(font([],Table)). +table(font(Attrs1,Table)) --> + {( Table =.. [table,Attrs2,Contents] + -> true + ; Table =.. [table,Contents] + -> Attrs2 = [] + )}, + html_element(font, Attrs1, table(table(Attrs2,Contents))). + %! text(?Contents:list)// . +% ~~~ +% text : textitem +% | text textitem +% ~~~ text(Contents) --> + {is_list(Contents)}, !, '+'(textitem, Contents, []). - - -%! textitem(?Content)// . +text(Content) --> + text([Content]). + + + +%! textitem(?Content:compound)// . +% ~~~ +% textitem : string +% |
+% | text +% | text +% | text +% | text +% | text +% | text +% | text +% | text +% ~~~ +% % Supported attributes for BR: -% ``` -% ALIGN="CENTER|LEFT|RIGHT" -% ``` +% - `ALIGN="CENTER|LEFT|RIGHT"` -textitem(string(String)) --> - html_string(String). -textitem(entity(Name)) --> - html_entity(Name). +textitem(br) --> + textitem(br([])). textitem(br(Attrs)) --> html_element(br, Attrs). +% Compound term: parser. textitem(Compound) --> {var(Compound)}, !, html_element(Name, _, text(Content)), @@ -200,12 +248,17 @@ textitem(Compound) --> supported_html_element(Name), Compound =.. [Name,Content] }. +% Compound term: generator. textitem(Compound) --> { Compound =.. [Name,Content], supported_html_element(Name) }, html_element(Name, _, text(Content)). +textitem(String) --> + html_string(String). + + diff --git a/plDcg b/plDcg index c61080f..d2e4a8a 160000 --- a/plDcg +++ b/plDcg @@ -1 +1 @@ -Subproject commit c61080f3d8df6ba6d48b0d70f5ba52047c8cbd29 +Subproject commit d2e4a8a094b7c405222574a4f9fe8c472296d7e6 diff --git a/plHtml b/plHtml index c98f740..dfd7c27 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit c98f740d593fff74bfa3cf3d08af13c857daa899 +Subproject commit dfd7c27dfd102e8eb6bfd9c516fccfcd23b5abf0 diff --git a/plUri b/plUri index 66a7652..0be7e9c 160000 --- a/plUri +++ b/plUri @@ -1 +1 @@ -Subproject commit 66a7652bc1ab6a4dc1fc790b09894d6c51d42dcf +Subproject commit 0be7e9cae7b42dea30f08aa751438d382387b8a2 ```

59: 正在比较变动前 af5d96d 和变动后 ab4b616

[back to content](#compare) ``` diff diff --git a/README.md b/README.md index f89c694..fff981c 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,40 @@ plGraphViz Easily export graphs represented as Prolog terms to [GraphViz](http://www.graphviz.org/). +The Prolog terms have the following form: + +~~~prolog +graph(Vertices, Edges, GraphAttrs) +~~~ + +`Vertices` and `Edges` are lists of compounds terms of + the following form: + +~~~prolog +vertex(Id, VertexAttrs) +edges(FromId, ToId, EdgeAttrs) +~~~ + +`Id` identifies a vertex and need not occur in any of the edges + (i.e., unconnected vertices are allowed). +`FromId` and `ToId` may occur in the list of vertices, + in order to draw an edge between vertices with set attributes. + +Attributes have the form `Name=Value`. +`GraphAttrs` are attributes of the graph. +`VertexAttrs` are attributes of the vertex. +`EdgeAttrs` are attributes of the edge. + +Attribute values are given as Prolog terms as well, + and are type-checked before exporting. +Many of the GraphViz attributes are supported. +New ones are added on an as-needed bases + (open an issue on Github if you want to see a specific feature added). +Supports HTML-like labels, allowing complex tables to be shown + inside vertices. +Support for vertex clusters is currently under way. + +--- ### Example @@ -17,14 +51,14 @@ $ swipl run.pl File = 'PATH/plGraphViz/data/tmp.png' ~~~ +![](https://raw.githubusercontent.com/wouterbeek/plGraphViz/master/example1.png "Example graph.") + The graphic can be saved to a different file by instantiating the `File` argument. -![](https://raw.githubusercontent.com/wouterbeek/plGraphViz/master/example1.png "Example graph.") - --- -### Method option +### 'Method' option Option `method(+atom)` sets the drawing method that is used by GraphViz to place the vertices and edges. @@ -41,7 +75,7 @@ The following values are supported. --- -### Output type option +### 'Output' option Option `output(+atom)` sets the type of file the graph is written to. The following values are supported. ```

60: 正在比较变动前 ab4b616 和变动后 74bd19d

[back to content](#compare) ``` diff diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 3237b4b..4678991 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -438,7 +438,7 @@ smoothType(triangle). % A GraphViz string. string(Content) --> - atom(Content). + quoted(atom(Content)). diff --git a/gv_dot.pl b/gv_dot.pl index 6db4451..d01b656 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -1,7 +1,7 @@ :- module( gv_dot, [ - gv_graph//1 % +Gif:compound + gv_graph//1 % +Graph:compound ] ). @@ -150,7 +150,7 @@ gv_generic_attributes_statement(Kind, I, KindAttrs) --> -%! gv_graph(+Gif:compound)// +%! gv_graph(+Graph:compound)// % The follow graph attributes are supported, % beyond the GraphViz attributes for graphs: % * `directed(+boolean)` ```

61: 正在比较变动前 74bd19d 和变动后 8ffff6f

[back to content](#compare) ``` diff diff --git a/README.md b/README.md index fff981c..9413d36 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,14 @@ Support for vertex clusters is currently under way. --- +### Installation + +~~~shell +$ git clone https://github.com/wouterbeek/plGraphViz.git +$ cd plGraphViz +$ git submodule update --init +~~~ + ### Example ~~~prolog diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 4678991..3237b4b 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -438,7 +438,7 @@ smoothType(triangle). % A GraphViz string. string(Content) --> - quoted(atom(Content)). + atom(Content). diff --git a/gv_dot.pl b/gv_dot.pl index d01b656..6db4451 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -1,7 +1,7 @@ :- module( gv_dot, [ - gv_graph//1 % +Graph:compound + gv_graph//1 % +Gif:compound ] ). @@ -150,7 +150,7 @@ gv_generic_attributes_statement(Kind, I, KindAttrs) --> -%! gv_graph(+Graph:compound)// +%! gv_graph(+Gif:compound)// % The follow graph attributes are supported, % beyond the GraphViz attributes for graphs: % * `directed(+boolean)` ```

62: 正在比较变动前 8ffff6f 和变动后 ac3423a

[back to content](#compare) ``` diff diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 3237b4b..4678991 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -438,7 +438,7 @@ smoothType(triangle). % A GraphViz string. string(Content) --> - atom(Content). + quoted(atom(Content)). diff --git a/gv_dot.pl b/gv_dot.pl index 6db4451..d01b656 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -1,7 +1,7 @@ :- module( gv_dot, [ - gv_graph//1 % +Gif:compound + gv_graph//1 % +Graph:compound ] ). @@ -150,7 +150,7 @@ gv_generic_attributes_statement(Kind, I, KindAttrs) --> -%! gv_graph(+Gif:compound)// +%! gv_graph(+Graph:compound)// % The follow graph attributes are supported, % beyond the GraphViz attributes for graphs: % * `directed(+boolean)` ```

63: 正在比较变动前 ac3423a 和变动后 57932e4

[back to content](#compare) ``` diff diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 1b264ab..3c731a0 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 1b264ab8b668b44035c96f320f8798f7940ad2fa +Subproject commit 3c731a03db6ee32031815d24c505e784273f46ef ```

64: 正在比较变动前 57932e4 和变动后 315b16e

[back to content](#compare) ``` diff diff --git a/gv_file.pl b/gv_file.pl index a7901e4..efd8c89 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -45,7 +45,7 @@ and GraphViz output files or SVG DOM structures. method(+atom), output(+atom) ]). -:- predicate_options(gif_to_svg_dom/3, 3, [ +:- predicate_options(graph_to_svg_dom/3, 3, [ pass_to(graph_to_gv_file/3, 3) ]). :- predicate_options(graph_to_gv_file/3, 3, [ ```

65: 正在比较变动前 315b16e 和变动后 898b5d2

[back to content](#compare) ``` diff diff --git a/gv_file.pl b/gv_file.pl index efd8c89..52506e8 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -29,7 +29,6 @@ and GraphViz output files or SVG DOM structures. :- use_module(library(process)). :- use_module(generics(code_ext)). -:- use_module(generics(db_ext)). :- use_module(os(file_ext)). :- use_module(os(run_ext)). @@ -45,9 +44,6 @@ and GraphViz output files or SVG DOM structures. method(+atom), output(+atom) ]). -:- predicate_options(graph_to_svg_dom/3, 3, [ - pass_to(graph_to_gv_file/3, 3) - ]). :- predicate_options(graph_to_gv_file/3, 3, [ pass_to(codes_to_gv_file/3, 3) ]). ```

66: 正在比较变动前 898b5d2 和变动后 4279a49

[back to content](#compare) ``` diff diff --git a/gv_file.pl b/gv_file.pl index 52506e8..188cfa6 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -6,9 +6,9 @@ file_to_gv/3, % +InputFile:atom % ?OutputFile:atom % +Options:list(nvpair) - graph_to_gv_file/3, % +Graph:compound - % ?OutputFile:atom - % +Options:list(nvpair) + export_graph_to_gv_file/3, % +ExportGraph:compound + % ?OutputFile:atom + % +Options:list(nvpair) open_dot/1 % +File:file ] ). @@ -22,7 +22,7 @@ Also converts between GraphViz DOT formatted files and GraphViz output files or SVG DOM structures. @author Wouter Beek -@version 2013/09, 2013/11-2014/01, 2014/05, 2014/07-2014/08 +@version 2013/09, 2013/11-2014/01, 2014/05, 2014/07-2014/08, 2014/11 */ :- use_module(library(option)). @@ -34,6 +34,11 @@ and GraphViz output files or SVG DOM structures. :- use_module(plGraphViz(gv_dot)). +:- dynamic(user:prolog_file_type/2). +:- multifile(user:prolog_file_type/2). + +user:prolog_file_type(dot, dot). + :- predicate_options(codes_to_gv_file/3, 3, [ pass_to(file_to_gv/3, 3) ]). @@ -44,12 +49,14 @@ and GraphViz output files or SVG DOM structures. method(+atom), output(+atom) ]). -:- predicate_options(graph_to_gv_file/3, 3, [ +:- predicate_options(export_graph_to_gv_file/3, 3, [ pass_to(codes_to_gv_file/3, 3) ]). + + %! codes_to_gv_file( %! +Codes:list(code), %! ?OutputFile:atom, @@ -120,23 +127,23 @@ file_to_gv(InputFile, OutputFile, Options):- -%! graph_to_gv_file( -%! +Graph:compound, +%! export_graph_to_gv_file( +%! +ExportGraph:compound, %! ?OutputFile:atom, %! +Options:list(nvpair) %! ) is det. % Returns a file containing a GraphViz visualization of the given graph. % % The following options are supported: -% * `method(+Method:atom` +% - `method(+Method:atom` % The algorithm used by GraphViz for positioning the tree nodes. % Either =dot= (default) or =sfdp=. -% * `output(+FileType:atom)` +% - `output(+FileType:atom)` % The file type of the generated GraphViz file. % Default: `pdf`. -graph_to_gv_file(Gif, OutputFile, Options):- - once(phrase(gv_graph(Gif), Codes)), +export_graph_to_gv_file(ExportGraph, OutputFile, Options):- + once(phrase(gv_graph(ExportGraph), Codes)), codes_to_gv_file(Codes, OutputFile, Options). @@ -154,6 +161,7 @@ open_dot(File):- + % HELPERS gv_method(circo). ```

67: 正在比较变动前 4279a49 和变动后 c173073

[back to content](#compare) ``` diff diff --git a/gv_dot.pl b/gv_dot.pl index d01b656..a4197a9 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -13,10 +13,10 @@ Methods for writing to the GraphViz DOT format. In GraphViz vertices are called 'nodes'. -~~~abnf +```abnf attr_list = "[" [a_list] "]" [attr_list] a_list = ID "=" ID [","] [a_list] -~~~ +``` --- diff --git a/gv_html.pl b/gv_html.pl index 9a4d33a..63f2d82 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -9,7 +9,7 @@ Grammar taken from the GraphViz Web site: -~~~ +``` label : text | table text : textitem @@ -34,7 +34,7 @@ cells : cell | cells cell cell: label | -~~~ +``` --- @@ -148,9 +148,9 @@ rows([H]) --> %! table(?Contents:compound)// . -% ~~~ +% ``` % table : [ ] rows
[
] -% ~~~ +% ``` % % Supported attributes for `TABLE`: % - `ALIGN="CENTER|LEFT|RIGHT"` @@ -206,10 +206,10 @@ table(font(Attrs1,Table)) --> %! text(?Contents:list)// . -% ~~~ +% ``` % text : textitem % | text textitem -% ~~~ +% ``` text(Contents) --> {is_list(Contents)}, !, @@ -220,7 +220,7 @@ text(Content) --> %! textitem(?Content:compound)// . -% ~~~ +% ``` % textitem : string % |
% | text @@ -231,7 +231,7 @@ text(Content) --> % | text % | text % | text -% ~~~ +% ``` % % Supported attributes for BR: % - `ALIGN="CENTER|LEFT|RIGHT"` ```

68: 正在比较变动前 c173073 和变动后 107c515

[back to content](#compare) ``` diff diff --git a/gv_attrs.pl b/gv_attrs.pl index e3ba03c..6e61373 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -129,7 +129,7 @@ assert_gv_attr_row([Name,UsedBy1,Types1,Default1,Minimum,Notes]):- gv_attrs_download:- gv_attrs_url(Url), - download_html(Url, Dom, [html_dialect(html4),verbose(silent)]), + download_html_dom(Url, Dom, [html_dialect(html4),verbose(silent)]), xpath(Dom, //table(@align=center), TableDom), % @tbd This does not work, since in `record_name(Element, Name)`, diff --git a/gv_color.pl b/gv_color.pl index 0510f98..c1c6fde 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -94,7 +94,7 @@ wc_weight(Float) --> gv_color_download:- gv_color_url(Url), - download_html(Url, Dom, [html_dialect(html4),verbose(silent)]), + download_html_dom(Url, Dom, [html_dialect(html4),verbose(silent)]), xpath(Dom, //table(1), TableDom1), xpath(Dom, //table(2), TableDom2), maplist(assert_color_table, [x11,svg], [TableDom1,TableDom2]). ```

69: 正在比较变动前 107c515 和变动后 8f574bb

[back to content](#compare) ``` diff diff --git a/gv_attrs.pl b/gv_attrs.pl index 6e61373..0fa4dcc 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -2,7 +2,7 @@ gv_attrs, [ gv_attr_value//2 % +Context:oneof([cluster,edge,graph,node,subgraph]) - % +Attribute:nvpair + % +Attribute:nvpair ] ). @@ -11,7 +11,7 @@ Support for GraphViz attributes. @author Wouter Beek -@version 2014/06, 2014/11 +@version 2014/06, 2014/11-2014/12 */ :- use_module(library(apply)). @@ -30,7 +30,7 @@ Support for GraphViz attributes. :- use_module(plHtml(html)). :- use_module(plHtml(html_table)). -:- use_module(plGraphViz(gv_attr_type)). % DCGs implementing attribute types. +:- use_module(plGraphViz(gv_attr_type), [gv_attr_type/1]). :- db_add_novel(user:prolog_file_type(log, logging)). @@ -94,7 +94,7 @@ gv_attr_value(Context, Name=Value) --> % Check validity of Value w.r.t. minimum value -- if available. check_minimum(Value, Minimum) }, - dcg_call(Dcg, Value). + dcg_call(gv_attr_type:Dcg, Value). ```

70: 正在比较变动前 8f574bb 和变动后 d7088dd

[back to content](#compare) ``` diff diff --git a/gv_dot.pl b/gv_dot.pl index a4197a9..e7b6748 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -341,12 +341,12 @@ gv_id(Atom) --> gv_id(Atom) --> quoted(dcg_atom_codes(gv_quoted_string, Atom)), !. -gv_id_first(X) --> letter(X). +gv_id_first(X) --> ascii_letter(X). gv_id_first(X) --> underscore(X). gv_id_rest([]) --> []. gv_id_rest([H|T]) --> - ( alpha_numeric(H) + ( ascii_alpha_numeric(H) ; underscore(H) ), gv_id_rest(T). ```

71: 正在比较变动前 d7088dd 和变动后 94ed05d

[back to content](#compare) ``` diff diff --git a/README.md b/README.md index 9413d36..eb8512b 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ $ git submodule update --init ~~~prolog $ swipl run.pl ?- use_module(plGraphViz(gv_file)). -?- graph_to_gv_file( +?- export_graph_to_gv_file( graph([vertex(1,[]),vertex(2,[])],[edge(1,2,[])],[]), File, [method(sfdp),output(png)] @@ -136,7 +136,7 @@ The following values are supported. Example of using HTML-like labels: ~~~prolog -graph_to_gv_file( +export_graph_to_gv_file( graph( [vertex(1,[]),vertex(2,[label=html(table([tr([td(a),td(b)]),tr([td(c),td(d)])]))])], [edge(1,2,[label='From 1 to 2.'])], ```

72: 正在比较变动前 94ed05d 和变动后 f481060

[back to content](#compare) ``` diff diff --git a/gv_file.pl b/gv_file.pl index 188cfa6..101dc4d 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -94,6 +94,7 @@ file_to_gv(InputFile, OutputFile, Options):- ; rename_file(InputFile, OutputFile) ). file_to_gv(InputFile, OutputFile, Options):- +gtrace, % Typecheck for `method` option. option(method(Method), Options, dot), findall(Method0, gv_method(Method0), Methods), ```

73: 正在比较变动前 f481060 和变动后 ce492ef

[back to content](#compare) ``` diff diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 4678991..6d2e4f5 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -46,7 +46,7 @@ /** GraphViz attribute types @author Wouter Beek -@version 2014/06, 2014/11 +@version 2014/06, 2014/11-2014/12 */ :- use_module(plDcg(dcg_abnf)). @@ -54,7 +54,9 @@ :- use_module(plDcg(dcg_atom)). :- use_module(plDcg(dcg_cardinal)). :- use_module(plDcg(dcg_content)). +:- use_module(plDcg(dcg_generics)). :- use_module(plDcg(dcg_quote)). +:- use_module(plDcg(dcg_replace)). :- use_module(plGraphViz(gv_html)). @@ -210,7 +212,10 @@ doubleList(L) --> % @tbd Support for context-dependent replacements. escString(String) --> - quoted(atom(String)). + {dcg_phrase(dcg_replace(double_quote, escaped_double_quote), String, String0)}, + quoted(atom(String0)). +escaped_double_quote --> + "\\\"". diff --git a/gv_dot.pl b/gv_dot.pl index e7b6748..c51b4cf 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -22,7 +22,7 @@ a_list = ID "=" ID [","] [a_list] @author Wouter Beek @see http://www.graphviz.org/content/dot-language -@version 2013/07, 2013/09, 2014/03-2014/06, 2014/11 +@version 2013/07, 2013/09, 2014/03-2014/06, 2014/11-2014/12 */ :- use_module(library(apply)). @@ -32,6 +32,7 @@ a_list = ID "=" ID [","] [a_list] :- use_module(plDcg(dcg_abnf)). :- use_module(plDcg(dcg_arrow)). :- use_module(plDcg(dcg_ascii)). +:- use_module(plDcg(dcg_atom)). :- use_module(plDcg(dcg_bracket)). :- use_module(plDcg(dcg_content)). :- use_module(plDcg(dcg_generics)). @@ -111,12 +112,11 @@ gv_edge_operator(true) --> arrow(right, 2). gv_edge_statement(I, Directed, edge(FromId,ToId,EAttrs)) --> indent(I), - gv_node_id(FromId), " ", + gv_node_id(FromId), " ", gv_edge_operator(Directed), " ", - gv_node_id(ToId), " ", - + % We want `colorscheme/1` from the edges and % `directionality/1` from the graph. bracketed(square, '*'(gv_attr(edge), EAttrs, [])), @@ -293,7 +293,7 @@ gv_graph_type(true) --> "digraph". -%! gv_id(?Atom:atom)// is det. +%! gv_id(?Atom:compound)// is det. % Parse a GraphViz identifier. % There are 4 variants: % 1. Any string of alphabetic (`[a-zA-Z'200-'377]`) characters, @@ -306,17 +306,26 @@ gv_graph_type(true) --> "digraph". % is converted to `"`. All other characters are left unchanged. % In particular, `\\` remains `\\`. % Layout engines may apply additional escape sequences. +% Represented by a Prolog term of the form `double_quoted_string(ATOM)`. % 4. An HTML string (`<...>`). +% Represented by a Prolog term of the form `html_like_label(COMPOUND)`. % % @tbd Add support for HTML-like labels: % http://www.graphviz.org/doc/info/shapes.html#html % This requires an XML grammar! -% HTML strings (variant 4). -gv_id(Content) --> - {compound(Content)}, !, +% HTML strings (assumed to be the same as HTML-like labels). +gv_id(html_like_label(Content)) --> !, gv_html_like_label(Content). -% Alpha-numeric strings (variant 1). +% Double-quoted strings. +% The quotes are already part of the given atom. +gv_id(double_quoted_string(Atom)) --> !, + quoted(atom(Atom)). +% Numerals. +gv_id(N) --> + {number(N)}, !, + gv_numeral(N). +% Alpha-numeric strings. gv_id(Atom) --> {atom_codes(Atom, [H|T])}, gv_id_first(H), @@ -324,22 +333,6 @@ gv_id(Atom) --> % Variant 1 identifiers should not be (case-variants of) a % GraphViz keyword. {\+ gv_keyword([H|T])}. -% Numerals (variant 2) -gv_id(N) --> - {number(N)}, !, - gv_numeral(N). -% Double-quoted strings (variant 3). -% The quotes are already part of the given atom. -gv_id(Atom) --> - { - atom_codes(Atom, [H|T]), - append(S, [H], T) - }, - dcg_between(double_quote(H), gv_quoted_string(S)), !. -% Double-quoted strings (variant 3). -% The quotes are not in the given atom. They are written anyway. -gv_id(Atom) --> - quoted(dcg_atom_codes(gv_quoted_string, Atom)), !. gv_id_first(X) --> ascii_letter(X). gv_id_first(X) --> underscore(X). @@ -382,7 +375,7 @@ gv_kind(node) --> "node". -%! gv_node_id(+NodeId:atom)// . +%! gv_node_id(+NodeId:compound)// . % GraphViz node identifiers can be of the following two types: % 1. A GraphViz identifier, see gv_id//1. % 2. A GraphViz identifier plus a GraphViz port indicator, see gv_port//0. @@ -439,26 +432,6 @@ gv_port_location --> -gv_quoted_string([]) --> []. -% Just to be sure, we do not allow the double quote -% that closes the string to be escaped. -gv_quoted_string([X]) --> - {X \== 92}, !, - [X]. -% A double quote is only allowed if it is escaped by a backslash. -gv_quoted_string([92,34|T]) --> !, - gv_quoted_string(T). -% Add the backslash escape character. -gv_quoted_string([34|T]) --> !, - "\\\"", - gv_quoted_string(T). -% All other characters are allowed without escaping. -gv_quoted_string([H|T]) --> - [H], - gv_quoted_string(T). - - - gv_ranked_node_collection(I, rank(Rank_V_Term,Content_V_Terms)) --> indent(I), bracketed(curly, ( diff --git a/gv_file.pl b/gv_file.pl index 101dc4d..d191e10 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -22,7 +22,7 @@ Also converts between GraphViz DOT formatted files and GraphViz output files or SVG DOM structures. @author Wouter Beek -@version 2013/09, 2013/11-2014/01, 2014/05, 2014/07-2014/08, 2014/11 +@version 2013/09, 2013/11-2014/01, 2014/05, 2014/07-2014/08, 2014/11-2014/12 */ :- use_module(library(option)). @@ -38,6 +38,7 @@ and GraphViz output files or SVG DOM structures. :- multifile(user:prolog_file_type/2). user:prolog_file_type(dot, dot). +user:prolog_file_type(pdf, pdf). :- predicate_options(codes_to_gv_file/3, 3, [ pass_to(file_to_gv/3, 3) @@ -94,7 +95,6 @@ file_to_gv(InputFile, OutputFile, Options):- ; rename_file(InputFile, OutputFile) ). file_to_gv(InputFile, OutputFile, Options):- -gtrace, % Typecheck for `method` option. option(method(Method), Options, dot), findall(Method0, gv_method(Method0), Methods), @@ -108,9 +108,7 @@ gtrace, % The output file is either given or created. ( var(OutputFile) -> file_alternative(InputFile, _, _, OutputType, OutputFile) - ; is_absolute_file_name(OutputFile), - % The given output file must match a certain file extension. - file_name_extension(_, OutputType, OutputFile) + ; is_absolute_file_name(OutputFile) ), % Run the GraphViz conversion command in the shell. ```

74: 正在比较变动前 ce492ef 和变动后 ddef555

[back to content](#compare) ``` diff diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 6d2e4f5..b886f9f 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -229,7 +229,7 @@ escaped_double_quote --> %! lblString(+String:compound)// . -lblString(html(V)) --> +lblString(html_like_label(V)) --> gv_html_like_label(V). lblString(V) --> escString(V). diff --git a/gv_html.pl b/gv_html.pl index 63f2d82..1410c25 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -236,8 +236,6 @@ text(Content) --> % Supported attributes for BR: % - `ALIGN="CENTER|LEFT|RIGHT"` -textitem(br) --> - textitem(br([])). textitem(br(Attrs)) --> html_element(br, Attrs). % Compound term: parser. ```

75: 正在比较变动前 ddef555 和变动后 af27fdd

[back to content](#compare) ``` diff diff --git a/gv_color.pl b/gv_color.pl index c1c6fde..2263fa1 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -17,7 +17,7 @@ */ :- use_module(library(apply)). -:- use_module(library(lists), except([delete/3])). +:- use_module(library(lists), except([delete/3,subset/2])). :- use_module(library(persistency)). :- use_module(library(xpath)). diff --git a/gv_dot.pl b/gv_dot.pl index c51b4cf..e047a74 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -26,7 +26,7 @@ a_list = ID "=" ID [","] [a_list] */ :- use_module(library(apply)). -:- use_module(library(lists), except([delete/3])). +:- use_module(library(lists), except([delete/3,subset/2])). :- use_module(library(ordsets)). :- use_module(plDcg(dcg_abnf)). ```

76: 正在比较变动前 af27fdd 和变动后 f390238

[back to content](#compare) ``` diff diff --git a/gv_attr_type.pl b/gv_attr_type.pl index b886f9f..b68f753 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -46,7 +46,7 @@ /** GraphViz attribute types @author Wouter Beek -@version 2014/06, 2014/11-2014/12 +@version 2014/06, 2014/11-2015/01 */ :- use_module(plDcg(dcg_abnf)). @@ -57,6 +57,7 @@ :- use_module(plDcg(dcg_generics)). :- use_module(plDcg(dcg_quote)). :- use_module(plDcg(dcg_replace)). +:- use_module(plDcg(language/c)). :- use_module(plGraphViz(gv_html)). @@ -104,9 +105,9 @@ gv_attr_type(viewPort). %! addDouble(+Float:float)// . % An *addDouble* is represented by a Prolog float. -addDouble(Float) --> - '?'(plus_sign, []), - double(Float). +addDouble(N) --> + ("+" ; ""), + c_double(N). @@ -115,7 +116,7 @@ addDouble(Float) --> % `point(X:float,Y:float,InputOnly:boolean)`. addPoint(Point) --> - '?'(plus_sign, []), + ("+" ; ""), point(Point). @@ -194,10 +195,8 @@ dirType(none). %! double(+Double:float)// . -double(Double1) --> - % float//1 will check for float type. - {Double2 is Double1 * 1.0}, - float(Double2). +double(N) --> + c_double(N). diff --git a/gv_numeral.pl b/gv_numeral.pl index d36fa59..cf595d9 100644 --- a/gv_numeral.pl +++ b/gv_numeral.pl @@ -19,7 +19,7 @@ -%! gv_numeral(?Value:number)// . +%! gv_numeral(?Value:compound)// . % % # Syntax % @@ -45,36 +45,39 @@ % - (decimal-separator) gv_numeral(N) --> - {var(N)}, !, - sign(Sign), - ( ".", - '+'(decimal_digit, Fractional, [convert1(weights_decimal)]), - {IntegerPart = 0} - ; '+'(decimal_digit, IntegerPart, [convert1(weights_decimal)]), - ( ".", - '*'(decimal_digit, Fractional, [convert1(weights_decimal)]) - ; {Fractional = 0} + ( {ground(N)} + -> '[-]?'(N), + {N0 is abs(N)}, + {rational_parts(N0, I, F)}, + ( % [1] The fractional is zero, so only write the integer part + % and do not write the decimal separator. + {F =:= 0} + -> {weights_nonneg(IW, I)}, + '[0-9]+'(IW) + ; % [2] The integer part is zero, so only write the fractional part, + % preceded by the decimal separator. + {I =:= 0} + -> ".", + {weights_fraction(FW, F)}, + '[0-9]*'(FW) + ; % [3] Both the integer part and the fractional are non-zero, + % so write both of them, with the decimal separator in-between. + {weights_nonneg(IW, I)}, + '[0-9]+'(IW), + ".", + {weights_fraction(FW, F)}, + '[0-9]*'(FW) ) - ), - { number_integer_parts(UnsignedN, IntegerPart, Fractional), - N is copysign(UnsignedN, Sign) - }. -gv_numeral(N) --> - {number_sign_parts(N, Sign, UnsignedN)}, - sign_negative(Sign), - {number_integer_parts(UnsignedN, IntegerPart, Fractional)}, - ( % [1] The fractional is zero, so only write the integer part - % and do not write the decimal separator. - {Fractional =:= 0} - -> integer(IntegerPart) - ; % [2] The integer part is zero, so only write the fractional part, - % preceded by the decimal separator. - {IntegerPart =:= 0} - -> ".", - integer(Fractional) - ; % [3] Both the integer part and the fractional are non-zero, - % so write both of them, with the decimal separator in-between. - integer(IntegerPart), - ".", - integer(Fractional) + ; '[-]?'(Sg), + ( ".", + '[0-9]+'(FW), + {IW = []} + ; '[0-9]+'(IW), + ( ".", + '[0-9]*'(FW), + ; {FW = []} + ) + ), + {rational_parts_weights(N0, IW, FW)}, + {N is copysign(N0, Sg)} ). ```

77: 正在比较变动前 f390238 和变动后 c5f7d82

[back to content](#compare) ``` diff diff --git a/gv_numeral.pl b/gv_numeral.pl index cf595d9..c9b3e1d 100644 --- a/gv_numeral.pl +++ b/gv_numeral.pl @@ -8,12 +8,15 @@ /** GraphViz numeral @author Wouter Beek -@version 2014/05-2014/06 +@version 2014/05-2014/06, 2015/01 */ :- use_module(math(math_ext)). +:- use_module(math(radix)). +:- use_module(math(rational_ext)). :- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_abnf_common)). :- use_module(plDcg(dcg_ascii)). :- use_module(plDcg(dcg_cardinal)). ```

78: 正在比较变动前 c5f7d82 和变动后 acf6467

[back to content](#compare) ``` diff diff --git a/gv_attr_type.pl b/gv_attr_type.pl index b68f753..157681f 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -49,6 +49,8 @@ @version 2014/06, 2014/11-2015/01 */ +:- use_module(library(dcg/basics), [float//1,integer//1]). + :- use_module(plDcg(dcg_abnf)). :- use_module(plDcg(dcg_ascii)). :- use_module(plDcg(dcg_atom)). diff --git a/gv_color.pl b/gv_color.pl index 2263fa1..7aea965 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -13,10 +13,11 @@ @author Wouter Beek @tbd Color value `transparent` is only available in the output formats ps, svg, fig, vmrl, and the bitmap formats. -@version 2014/06, 2014/10-2014/11 +@version 2014/06, 2014/10-2014/11, 2015/01 */ :- use_module(library(apply)). +:- use_module(library(dcg/basics), [float//1]). :- use_module(library(lists), except([delete/3,subset/2])). :- use_module(library(persistency)). :- use_module(library(xpath)). diff --git a/gv_numeral.pl b/gv_numeral.pl index c9b3e1d..439a024 100644 --- a/gv_numeral.pl +++ b/gv_numeral.pl @@ -77,7 +77,7 @@ gv_numeral(N) --> {IW = []} ; '[0-9]+'(IW), ( ".", - '[0-9]*'(FW), + '[0-9]*'(FW) ; {FW = []} ) ), ```

79: 正在比较变动前 acf6467 和变动后 6656a2d

[back to content](#compare) ``` diff diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 157681f..3ae0920 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -59,7 +59,6 @@ :- use_module(plDcg(dcg_generics)). :- use_module(plDcg(dcg_quote)). :- use_module(plDcg(dcg_replace)). -:- use_module(plDcg(language/c)). :- use_module(plGraphViz(gv_html)). @@ -109,7 +108,7 @@ gv_attr_type(viewPort). addDouble(N) --> ("+" ; ""), - c_double(N). + float(N). @@ -198,7 +197,7 @@ dirType(none). %! double(+Double:float)// . double(N) --> - c_double(N). + float(N). diff --git a/gv_numeral.pl b/gv_numeral.pl index 439a024..5776a4a 100644 --- a/gv_numeral.pl +++ b/gv_numeral.pl @@ -22,6 +22,8 @@ + + %! gv_numeral(?Value:compound)// . % % # Syntax ```

80: 正在比较变动前 6656a2d 和变动后 256c9ce

[back to content](#compare) ``` diff diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 3c731a0..06aa96f 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 3c731a03db6ee32031815d24c505e784273f46ef +Subproject commit 06aa96fbeef941157e9bcccc7c088d72ba8c8d3a diff --git a/plDcg b/plDcg index d2e4a8a..2f2ae3a 160000 --- a/plDcg +++ b/plDcg @@ -1 +1 @@ -Subproject commit d2e4a8a094b7c405222574a4f9fe8c472296d7e6 +Subproject commit 2f2ae3a9228e8add2dfa4835ff045a3635a062ba diff --git a/plHtml b/plHtml index dfd7c27..b8bd7a6 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit dfd7c27dfd102e8eb6bfd9c516fccfcd23b5abf0 +Subproject commit b8bd7a6d92f1076a5be2c4686e998a0bfc840ac8 diff --git a/plUri b/plUri index 0be7e9c..6550f33 160000 --- a/plUri +++ b/plUri @@ -1 +1 @@ -Subproject commit 0be7e9cae7b42dea30f08aa751438d382387b8a2 +Subproject commit 6550f331120c7f63739f69692791760afb507280 ```

81: 正在比较变动前 256c9ce 和变动后 bf4ebea

[back to content](#compare) ``` diff diff --git a/.gitmodules b/.gitmodules index 6c22435..26ddd86 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,9 +4,6 @@ [submodule "plHtml"] path = plHtml url = https://github.com/wouterbeek/plHtml.git -[submodule "plDcg"] - path = plDcg - url = https://github.com/wouterbeek/plDcg.git [submodule "plUri"] path = plUri url = https://github.com/wouterbeek/plUri.git diff --git a/debug_project.pl b/debug_project.pl index 17195c1..d53a92f 100644 --- a/debug_project.pl +++ b/debug_project.pl @@ -1,7 +1,8 @@ :- module( debug_project, [ - debug_all_files/0 + debug_all_files/0, + start_pldoc_server/0 ] ). @@ -11,20 +12,35 @@ Generic code for debugging a project: * Load all subdirectories and Prolog files contained in those directories. @author Wouter Beek -@version 2014/11/19 +@version 2015/02/26 */ :- use_module(library(ansi_term)). :- use_module(library(apply)). +:- use_module(library(pldoc)). +:- use_module(library(portray_text)). + +:- set_prolog_flag( + answer_write_options, + [max_depth(100),portrayed(true),spacing(next_argument)] +). +:- set_prolog_flag( + debugger_write_options, + [max_depth(100),portrayed(true),spacing(next_argument)] +). +:- set_portray_text(ellipsis, 1000). + +:- dynamic(user:debug_mode). +:- multifile(user:debug_mode). + +:- initialization(init_debug_mode). -:- use_module(os(dir_ext)). -% Avoid errors when using gtrace/0 in threads. -:- initialization(guitracer). debug_all_files:- + ensure_loaded(plc(io/dir_ext)), absolute_file_name(project(.), Dir, [access(read),file_type(directory)]), directory_files( Dir, @@ -55,6 +71,30 @@ do_not_load0(index). do_not_load0(load). do_not_load0(load_project). do_not_load0(run). +do_not_load0(style). + + + +%! start_pldoc_server is det. +% The plDoc server should be started *before* documented modules are loaded. + +start_pldoc_server:- + doc_server(9999). + + + + + +% INITIALIZATION + +init_debug_mode:- + % Set the debug mode flag. + ( user:debug_mode + -> true + ; assert(user:debug_mode) + ), + % Avoid errors when using gtrace/0 in threads. + guitracer. diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 3ae0920..9794eef 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -51,14 +51,14 @@ :- use_module(library(dcg/basics), [float//1,integer//1]). -:- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_ascii)). -:- use_module(plDcg(dcg_atom)). -:- use_module(plDcg(dcg_cardinal)). -:- use_module(plDcg(dcg_content)). -:- use_module(plDcg(dcg_generics)). -:- use_module(plDcg(dcg_quote)). -:- use_module(plDcg(dcg_replace)). +:- use_module(plc(dcg/dcg_abnf)). +:- use_module(plc(dcg/dcg_ascii)). +:- use_module(plc(dcg/dcg_atom)). +:- use_module(plc(dcg/dcg_cardinal)). +:- use_module(plc(dcg/dcg_content)). +:- use_module(plc(dcg/dcg_generics)). +:- use_module(plc(dcg/dcg_quote)). +:- use_module(plc(dcg/dcg_replace)). :- use_module(plGraphViz(gv_html)). diff --git a/gv_attrs.pl b/gv_attrs.pl index 0fa4dcc..4e7ae2d 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -18,17 +18,16 @@ Support for GraphViz attributes. :- use_module(library(persistency)). :- use_module(library(xpath)). -:- use_module(generics(db_ext)). -:- use_module(os(file_ext)). -:- use_module(os(file_gnu)). - -:- use_module(plDcg(dcg_atom)). -:- use_module(plDcg(dcg_content)). -:- use_module(plDcg(dcg_meta)). -:- use_module(plDcg(dcg_generics)). +:- use_module(plc(dcg/dcg_atom)). +:- use_module(plc(dcg/dcg_content)). +:- use_module(plc(dcg/dcg_meta)). +:- use_module(plc(dcg/dcg_generics)). +:- use_module(plc(generics/db_ext)). +:- use_module(plc(io/file_ext)). +:- use_module(plc(io/file_gnu)). :- use_module(plHtml(html)). -:- use_module(plHtml(html_table)). +:- use_module(plHtml(elements/html_table)). :- use_module(plGraphViz(gv_attr_type), [gv_attr_type/1]). @@ -100,7 +99,7 @@ gv_attr_value(Context, Name=Value) --> -% HELPERS +% HELPERS % %! check_minimum(+Value:atom, +Minimum:number) is semidet. % Trivially succeeds if no minimum value is available for a given attribute. @@ -112,7 +111,9 @@ check_minimum(V, Min1):- -% INITIALIZATION + + +% INITIALIZATION % %! assert_gv_attr_row(+Row:list(atom)) is det. diff --git a/gv_color.pl b/gv_color.pl index 7aea965..34d99eb 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -22,19 +22,18 @@ :- use_module(library(persistency)). :- use_module(library(xpath)). -:- use_module(generics(db_ext)). -:- use_module(generics(persistent_db_ext)). -:- use_module(os(file_ext)). -:- use_module(os(file_gnu)). - -:- use_module(plDcg(abnf_core_rules)). -:- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_atom)). -:- use_module(plDcg(dcg_cardinal)). -:- use_module(plDcg(dcg_content)). +:- use_module(plc(dcg/abnf_core_rules)). +:- use_module(plc(dcg/dcg_abnf)). +:- use_module(plc(dcg/dcg_atom)). +:- use_module(plc(dcg/dcg_cardinal)). +:- use_module(plc(dcg/dcg_content)). +:- use_module(plc(generics/db_ext)). +:- use_module(plc(generics/persistent_db_ext)). +:- use_module(plc(io/file_ext)). +:- use_module(plc(io/file_gnu)). :- use_module(plHtml(html)). -:- use_module(plHtml(html_table)). +:- use_module(plHtml(elements/html_table)). :- db_add_novel(user:prolog_file_type(log, logging)). @@ -46,6 +45,8 @@ + + % color(+Color:compound)// . % A *color* is represented by a compound term of one of the following forms: % 1. `rgb(Red:nonneg,Green:nonneg,Blue:nonneg)` @@ -89,7 +90,9 @@ wc_weight(Float) --> -% INITIALIZATION + + +% INITIALIZATION % %! gv_color_download is det. diff --git a/gv_dot.pl b/gv_dot.pl index e047a74..19657f5 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -29,15 +29,15 @@ a_list = ID "=" ID [","] [a_list] :- use_module(library(lists), except([delete/3,subset/2])). :- use_module(library(ordsets)). -:- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_arrow)). -:- use_module(plDcg(dcg_ascii)). -:- use_module(plDcg(dcg_atom)). -:- use_module(plDcg(dcg_bracket)). -:- use_module(plDcg(dcg_content)). -:- use_module(plDcg(dcg_generics)). -:- use_module(plDcg(dcg_meta)). -:- use_module(plDcg(dcg_quote)). +:- use_module(plc(dcg/dcg_abnf)). +:- use_module(plc(dcg/dcg_arrow)). +:- use_module(plc(dcg/dcg_ascii)). +:- use_module(plc(dcg/dcg_atom)). +:- use_module(plc(dcg/dcg_bracket)). +:- use_module(plc(dcg/dcg_content)). +:- use_module(plc(dcg/dcg_generics)). +:- use_module(plc(dcg/dcg_meta)). +:- use_module(plc(dcg/dcg_quote)). :- use_module(plGraphViz(gv_attrs)). :- use_module(plGraphViz(gv_html)). diff --git a/gv_file.pl b/gv_file.pl index d191e10..6cb739f 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -28,9 +28,9 @@ and GraphViz output files or SVG DOM structures. :- use_module(library(option)). :- use_module(library(process)). -:- use_module(generics(code_ext)). -:- use_module(os(file_ext)). -:- use_module(os(run_ext)). +:- use_module(plc(generics/code_ext)). +:- use_module(plc(io/file_ext)). +:- use_module(plc(process/run_ext)). :- use_module(plGraphViz(gv_dot)). @@ -41,18 +41,18 @@ user:prolog_file_type(dot, dot). user:prolog_file_type(pdf, pdf). :- predicate_options(codes_to_gv_file/3, 3, [ - pass_to(file_to_gv/3, 3) - ]). + pass_to(file_to_gv/3, 3) +]). :- predicate_options(file_to_gv/2, 2, [ - pass_to(file_to_gv/3, 3) - ]). + pass_to(file_to_gv/3, 3) +]). :- predicate_options(file_to_gv/3, 3, [ - method(+atom), - output(+atom) - ]). + method(+atom), + output(+atom) +]). :- predicate_options(export_graph_to_gv_file/3, 3, [ - pass_to(codes_to_gv_file/3, 3) - ]). + pass_to(codes_to_gv_file/3, 3) +]). diff --git a/gv_html.pl b/gv_html.pl index 1410c25..65ae2bd 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -43,9 +43,9 @@ cell: label @version 2013/07, 2013/09, 2014/03-2014/06, 2014/11 */ -:- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_bracket)). -:- use_module(plDcg(dcg_content)). +:- use_module(plc(dcg/dcg_abnf)). +:- use_module(plc(dcg/dcg_bracket)). +:- use_module(plc(dcg/dcg_content)). :- use_module(plHtml(html_dcg)). diff --git a/gv_numeral.pl b/gv_numeral.pl index 5776a4a..ac294b4 100644 --- a/gv_numeral.pl +++ b/gv_numeral.pl @@ -11,14 +11,13 @@ @version 2014/05-2014/06, 2015/01 */ -:- use_module(math(math_ext)). -:- use_module(math(radix)). -:- use_module(math(rational_ext)). - -:- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_abnf_common)). -:- use_module(plDcg(dcg_ascii)). -:- use_module(plDcg(dcg_cardinal)). +:- use_module(plc(dcg/dcg_abnf)). +:- use_module(plc(dcg/dcg_abnf_common)). +:- use_module(plc(dcg/dcg_ascii)). +:- use_module(plc(dcg/dcg_cardinal)). +:- use_module(plc(math/math_ext)). +:- use_module(plc(math/radix)). +:- use_module(plc(math/rational_ext)). diff --git a/load.pl b/load.pl index 5cec32c..de8b5ca 100644 --- a/load.pl +++ b/load.pl @@ -7,7 +7,6 @@ :- use_module(load_project). :- load_project([ plc-'Prolog-Library-Collection', - plDcg, plHtml, plUri ]). diff --git a/plDcg b/plDcg deleted file mode 160000 index 2f2ae3a..0000000 --- a/plDcg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2f2ae3a9228e8add2dfa4835ff045a3635a062ba ```

82: 正在比较变动前 bf4ebea 和变动后 70aec99

[back to content](#compare) ``` diff diff --git a/.gitmodules b/.gitmodules index 26ddd86..6c22435 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,9 @@ [submodule "plHtml"] path = plHtml url = https://github.com/wouterbeek/plHtml.git +[submodule "plDcg"] + path = plDcg + url = https://github.com/wouterbeek/plDcg.git [submodule "plUri"] path = plUri url = https://github.com/wouterbeek/plUri.git diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 06aa96f..9d0e491 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 06aa96fbeef941157e9bcccc7c088d72ba8c8d3a +Subproject commit 9d0e49135bbd1916d901ccd18be605699f48c5cc diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 9794eef..3ae0920 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -51,14 +51,14 @@ :- use_module(library(dcg/basics), [float//1,integer//1]). -:- use_module(plc(dcg/dcg_abnf)). -:- use_module(plc(dcg/dcg_ascii)). -:- use_module(plc(dcg/dcg_atom)). -:- use_module(plc(dcg/dcg_cardinal)). -:- use_module(plc(dcg/dcg_content)). -:- use_module(plc(dcg/dcg_generics)). -:- use_module(plc(dcg/dcg_quote)). -:- use_module(plc(dcg/dcg_replace)). +:- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_ascii)). +:- use_module(plDcg(dcg_atom)). +:- use_module(plDcg(dcg_cardinal)). +:- use_module(plDcg(dcg_content)). +:- use_module(plDcg(dcg_generics)). +:- use_module(plDcg(dcg_quote)). +:- use_module(plDcg(dcg_replace)). :- use_module(plGraphViz(gv_html)). diff --git a/gv_attrs.pl b/gv_attrs.pl index 4e7ae2d..25519af 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -18,16 +18,17 @@ Support for GraphViz attributes. :- use_module(library(persistency)). :- use_module(library(xpath)). -:- use_module(plc(dcg/dcg_atom)). -:- use_module(plc(dcg/dcg_content)). -:- use_module(plc(dcg/dcg_meta)). -:- use_module(plc(dcg/dcg_generics)). -:- use_module(plc(generics/db_ext)). -:- use_module(plc(io/file_ext)). -:- use_module(plc(io/file_gnu)). +:- use_module(generics(db_ext)). +:- use_module(os(file_ext)). +:- use_module(os(file_gnu)). + +:- use_module(plDcg(dcg_atom)). +:- use_module(plDcg(dcg_content)). +:- use_module(plDcg(dcg_meta)). +:- use_module(plDcg(dcg_generics)). :- use_module(plHtml(html)). -:- use_module(plHtml(elements/html_table)). +:- use_module(plHtml(html_table)). :- use_module(plGraphViz(gv_attr_type), [gv_attr_type/1]). @@ -80,16 +81,16 @@ gv_attr_value(Context, Name=Value) --> % Check the validity of the context argument. gv_attr(Name, UsedBy, Types, _, Minimum, _), memberchk(Context, UsedBy), - + % Pick a value type non-deterministically. member(Type, Types), - + % The `style` type is the only one that requires the context argument. ( Type == style -> Dcg =.. [Type,Context] ; Dcg =.. [Type] ), - + % Check validity of Value w.r.t. minimum value -- if available. check_minimum(Value, Minimum) }, @@ -99,7 +100,7 @@ gv_attr_value(Context, Name=Value) --> -% HELPERS % +% HELPERS %! check_minimum(+Value:atom, +Minimum:number) is semidet. % Trivially succeeds if no minimum value is available for a given attribute. @@ -111,9 +112,7 @@ check_minimum(V, Min1):- - - -% INITIALIZATION % +% INITIALIZATION %! assert_gv_attr_row(+Row:list(atom)) is det. @@ -130,13 +129,8 @@ assert_gv_attr_row([Name,UsedBy1,Types1,Default1,Minimum,Notes]):- gv_attrs_download:- gv_attrs_url(Url), - download_html_dom(Url, Dom, [html_dialect(html4),verbose(silent)]), - + download_html_dom(Url, Dom, [dialect(html4),silent(true)]), xpath(Dom, //table(@align=center), TableDom), - % @tbd This does not work, since in `record_name(Element, Name)`, - % `Element` is a signleton list whereas a compound term is expected. - %%%%xpath(Dom, /html/body/table, TableDom), - html_to_table(TableDom, _, Rows), maplist(assert_gv_attr_row, Rows). diff --git a/gv_color.pl b/gv_color.pl index 34d99eb..7aea965 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -22,18 +22,19 @@ :- use_module(library(persistency)). :- use_module(library(xpath)). -:- use_module(plc(dcg/abnf_core_rules)). -:- use_module(plc(dcg/dcg_abnf)). -:- use_module(plc(dcg/dcg_atom)). -:- use_module(plc(dcg/dcg_cardinal)). -:- use_module(plc(dcg/dcg_content)). -:- use_module(plc(generics/db_ext)). -:- use_module(plc(generics/persistent_db_ext)). -:- use_module(plc(io/file_ext)). -:- use_module(plc(io/file_gnu)). +:- use_module(generics(db_ext)). +:- use_module(generics(persistent_db_ext)). +:- use_module(os(file_ext)). +:- use_module(os(file_gnu)). + +:- use_module(plDcg(abnf_core_rules)). +:- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_atom)). +:- use_module(plDcg(dcg_cardinal)). +:- use_module(plDcg(dcg_content)). :- use_module(plHtml(html)). -:- use_module(plHtml(elements/html_table)). +:- use_module(plHtml(html_table)). :- db_add_novel(user:prolog_file_type(log, logging)). @@ -45,8 +46,6 @@ - - % color(+Color:compound)// . % A *color* is represented by a compound term of one of the following forms: % 1. `rgb(Red:nonneg,Green:nonneg,Blue:nonneg)` @@ -90,9 +89,7 @@ wc_weight(Float) --> - - -% INITIALIZATION % +% INITIALIZATION %! gv_color_download is det. diff --git a/gv_dot.pl b/gv_dot.pl index 19657f5..e047a74 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -29,15 +29,15 @@ a_list = ID "=" ID [","] [a_list] :- use_module(library(lists), except([delete/3,subset/2])). :- use_module(library(ordsets)). -:- use_module(plc(dcg/dcg_abnf)). -:- use_module(plc(dcg/dcg_arrow)). -:- use_module(plc(dcg/dcg_ascii)). -:- use_module(plc(dcg/dcg_atom)). -:- use_module(plc(dcg/dcg_bracket)). -:- use_module(plc(dcg/dcg_content)). -:- use_module(plc(dcg/dcg_generics)). -:- use_module(plc(dcg/dcg_meta)). -:- use_module(plc(dcg/dcg_quote)). +:- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_arrow)). +:- use_module(plDcg(dcg_ascii)). +:- use_module(plDcg(dcg_atom)). +:- use_module(plDcg(dcg_bracket)). +:- use_module(plDcg(dcg_content)). +:- use_module(plDcg(dcg_generics)). +:- use_module(plDcg(dcg_meta)). +:- use_module(plDcg(dcg_quote)). :- use_module(plGraphViz(gv_attrs)). :- use_module(plGraphViz(gv_html)). diff --git a/gv_file.pl b/gv_file.pl index 6cb739f..d191e10 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -28,9 +28,9 @@ and GraphViz output files or SVG DOM structures. :- use_module(library(option)). :- use_module(library(process)). -:- use_module(plc(generics/code_ext)). -:- use_module(plc(io/file_ext)). -:- use_module(plc(process/run_ext)). +:- use_module(generics(code_ext)). +:- use_module(os(file_ext)). +:- use_module(os(run_ext)). :- use_module(plGraphViz(gv_dot)). @@ -41,18 +41,18 @@ user:prolog_file_type(dot, dot). user:prolog_file_type(pdf, pdf). :- predicate_options(codes_to_gv_file/3, 3, [ - pass_to(file_to_gv/3, 3) -]). + pass_to(file_to_gv/3, 3) + ]). :- predicate_options(file_to_gv/2, 2, [ - pass_to(file_to_gv/3, 3) -]). + pass_to(file_to_gv/3, 3) + ]). :- predicate_options(file_to_gv/3, 3, [ - method(+atom), - output(+atom) -]). + method(+atom), + output(+atom) + ]). :- predicate_options(export_graph_to_gv_file/3, 3, [ - pass_to(codes_to_gv_file/3, 3) -]). + pass_to(codes_to_gv_file/3, 3) + ]). diff --git a/gv_html.pl b/gv_html.pl index 65ae2bd..1410c25 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -43,9 +43,9 @@ cell: label @version 2013/07, 2013/09, 2014/03-2014/06, 2014/11 */ -:- use_module(plc(dcg/dcg_abnf)). -:- use_module(plc(dcg/dcg_bracket)). -:- use_module(plc(dcg/dcg_content)). +:- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_bracket)). +:- use_module(plDcg(dcg_content)). :- use_module(plHtml(html_dcg)). diff --git a/gv_numeral.pl b/gv_numeral.pl index ac294b4..5776a4a 100644 --- a/gv_numeral.pl +++ b/gv_numeral.pl @@ -11,13 +11,14 @@ @version 2014/05-2014/06, 2015/01 */ -:- use_module(plc(dcg/dcg_abnf)). -:- use_module(plc(dcg/dcg_abnf_common)). -:- use_module(plc(dcg/dcg_ascii)). -:- use_module(plc(dcg/dcg_cardinal)). -:- use_module(plc(math/math_ext)). -:- use_module(plc(math/radix)). -:- use_module(plc(math/rational_ext)). +:- use_module(math(math_ext)). +:- use_module(math(radix)). +:- use_module(math(rational_ext)). + +:- use_module(plDcg(dcg_abnf)). +:- use_module(plDcg(dcg_abnf_common)). +:- use_module(plDcg(dcg_ascii)). +:- use_module(plDcg(dcg_cardinal)). diff --git a/load.pl b/load.pl index de8b5ca..5cec32c 100644 --- a/load.pl +++ b/load.pl @@ -7,6 +7,7 @@ :- use_module(load_project). :- load_project([ plc-'Prolog-Library-Collection', + plDcg, plHtml, plUri ]). diff --git a/plDcg b/plDcg new file mode 160000 index 0000000..45a2d2b --- /dev/null +++ b/plDcg @@ -0,0 +1 @@ +Subproject commit 45a2d2b3ce1e3e18533586005b2a6a63eb2300d0 diff --git a/plHtml b/plHtml index b8bd7a6..c2491cb 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit b8bd7a6d92f1076a5be2c4686e998a0bfc840ac8 +Subproject commit c2491cb789baef4b2c7b9e30ca79d65a7213af02 diff --git a/plUri b/plUri index 6550f33..f1696b3 160000 --- a/plUri +++ b/plUri @@ -1 +1 @@ -Subproject commit 6550f331120c7f63739f69692791760afb507280 +Subproject commit f1696b3c41635b4c6af3e961e819a5e6c0bf5b75 ```

83: 正在比较变动前 70aec99 和变动后 e06e6ba

[back to content](#compare) ``` diff diff --git a/.gitmodules b/.gitmodules index 6c22435..26ddd86 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,9 +4,6 @@ [submodule "plHtml"] path = plHtml url = https://github.com/wouterbeek/plHtml.git -[submodule "plDcg"] - path = plDcg - url = https://github.com/wouterbeek/plDcg.git [submodule "plUri"] path = plUri url = https://github.com/wouterbeek/plUri.git diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 3ae0920..9794eef 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -51,14 +51,14 @@ :- use_module(library(dcg/basics), [float//1,integer//1]). -:- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_ascii)). -:- use_module(plDcg(dcg_atom)). -:- use_module(plDcg(dcg_cardinal)). -:- use_module(plDcg(dcg_content)). -:- use_module(plDcg(dcg_generics)). -:- use_module(plDcg(dcg_quote)). -:- use_module(plDcg(dcg_replace)). +:- use_module(plc(dcg/dcg_abnf)). +:- use_module(plc(dcg/dcg_ascii)). +:- use_module(plc(dcg/dcg_atom)). +:- use_module(plc(dcg/dcg_cardinal)). +:- use_module(plc(dcg/dcg_content)). +:- use_module(plc(dcg/dcg_generics)). +:- use_module(plc(dcg/dcg_quote)). +:- use_module(plc(dcg/dcg_replace)). :- use_module(plGraphViz(gv_html)). diff --git a/gv_attrs.pl b/gv_attrs.pl index 25519af..68f42db 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -18,17 +18,16 @@ Support for GraphViz attributes. :- use_module(library(persistency)). :- use_module(library(xpath)). -:- use_module(generics(db_ext)). -:- use_module(os(file_ext)). -:- use_module(os(file_gnu)). - -:- use_module(plDcg(dcg_atom)). -:- use_module(plDcg(dcg_content)). -:- use_module(plDcg(dcg_meta)). -:- use_module(plDcg(dcg_generics)). +:- use_module(plc(dcg/dcg_atom)). +:- use_module(plc(dcg/dcg_content)). +:- use_module(plc(dcg/dcg_meta)). +:- use_module(plc(dcg/dcg_generics)). +:- use_module(plc(generics/db_ext)). +:- use_module(plc(io/file_ext)). +:- use_module(plc(io/file_gnu)). :- use_module(plHtml(html)). -:- use_module(plHtml(html_table)). +:- use_module(plHtml(elements/html_table)). :- use_module(plGraphViz(gv_attr_type), [gv_attr_type/1]). @@ -100,7 +99,7 @@ gv_attr_value(Context, Name=Value) --> -% HELPERS +% HELPERS % %! check_minimum(+Value:atom, +Minimum:number) is semidet. % Trivially succeeds if no minimum value is available for a given attribute. @@ -112,7 +111,9 @@ check_minimum(V, Min1):- -% INITIALIZATION + + +% INITIALIZATION % %! assert_gv_attr_row(+Row:list(atom)) is det. diff --git a/gv_color.pl b/gv_color.pl index 7aea965..34d99eb 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -22,19 +22,18 @@ :- use_module(library(persistency)). :- use_module(library(xpath)). -:- use_module(generics(db_ext)). -:- use_module(generics(persistent_db_ext)). -:- use_module(os(file_ext)). -:- use_module(os(file_gnu)). - -:- use_module(plDcg(abnf_core_rules)). -:- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_atom)). -:- use_module(plDcg(dcg_cardinal)). -:- use_module(plDcg(dcg_content)). +:- use_module(plc(dcg/abnf_core_rules)). +:- use_module(plc(dcg/dcg_abnf)). +:- use_module(plc(dcg/dcg_atom)). +:- use_module(plc(dcg/dcg_cardinal)). +:- use_module(plc(dcg/dcg_content)). +:- use_module(plc(generics/db_ext)). +:- use_module(plc(generics/persistent_db_ext)). +:- use_module(plc(io/file_ext)). +:- use_module(plc(io/file_gnu)). :- use_module(plHtml(html)). -:- use_module(plHtml(html_table)). +:- use_module(plHtml(elements/html_table)). :- db_add_novel(user:prolog_file_type(log, logging)). @@ -46,6 +45,8 @@ + + % color(+Color:compound)// . % A *color* is represented by a compound term of one of the following forms: % 1. `rgb(Red:nonneg,Green:nonneg,Blue:nonneg)` @@ -89,7 +90,9 @@ wc_weight(Float) --> -% INITIALIZATION + + +% INITIALIZATION % %! gv_color_download is det. diff --git a/gv_dot.pl b/gv_dot.pl index e047a74..19657f5 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -29,15 +29,15 @@ a_list = ID "=" ID [","] [a_list] :- use_module(library(lists), except([delete/3,subset/2])). :- use_module(library(ordsets)). -:- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_arrow)). -:- use_module(plDcg(dcg_ascii)). -:- use_module(plDcg(dcg_atom)). -:- use_module(plDcg(dcg_bracket)). -:- use_module(plDcg(dcg_content)). -:- use_module(plDcg(dcg_generics)). -:- use_module(plDcg(dcg_meta)). -:- use_module(plDcg(dcg_quote)). +:- use_module(plc(dcg/dcg_abnf)). +:- use_module(plc(dcg/dcg_arrow)). +:- use_module(plc(dcg/dcg_ascii)). +:- use_module(plc(dcg/dcg_atom)). +:- use_module(plc(dcg/dcg_bracket)). +:- use_module(plc(dcg/dcg_content)). +:- use_module(plc(dcg/dcg_generics)). +:- use_module(plc(dcg/dcg_meta)). +:- use_module(plc(dcg/dcg_quote)). :- use_module(plGraphViz(gv_attrs)). :- use_module(plGraphViz(gv_html)). diff --git a/gv_file.pl b/gv_file.pl index d191e10..6cb739f 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -28,9 +28,9 @@ and GraphViz output files or SVG DOM structures. :- use_module(library(option)). :- use_module(library(process)). -:- use_module(generics(code_ext)). -:- use_module(os(file_ext)). -:- use_module(os(run_ext)). +:- use_module(plc(generics/code_ext)). +:- use_module(plc(io/file_ext)). +:- use_module(plc(process/run_ext)). :- use_module(plGraphViz(gv_dot)). @@ -41,18 +41,18 @@ user:prolog_file_type(dot, dot). user:prolog_file_type(pdf, pdf). :- predicate_options(codes_to_gv_file/3, 3, [ - pass_to(file_to_gv/3, 3) - ]). + pass_to(file_to_gv/3, 3) +]). :- predicate_options(file_to_gv/2, 2, [ - pass_to(file_to_gv/3, 3) - ]). + pass_to(file_to_gv/3, 3) +]). :- predicate_options(file_to_gv/3, 3, [ - method(+atom), - output(+atom) - ]). + method(+atom), + output(+atom) +]). :- predicate_options(export_graph_to_gv_file/3, 3, [ - pass_to(codes_to_gv_file/3, 3) - ]). + pass_to(codes_to_gv_file/3, 3) +]). diff --git a/gv_html.pl b/gv_html.pl index 1410c25..65ae2bd 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -43,9 +43,9 @@ cell: label @version 2013/07, 2013/09, 2014/03-2014/06, 2014/11 */ -:- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_bracket)). -:- use_module(plDcg(dcg_content)). +:- use_module(plc(dcg/dcg_abnf)). +:- use_module(plc(dcg/dcg_bracket)). +:- use_module(plc(dcg/dcg_content)). :- use_module(plHtml(html_dcg)). diff --git a/gv_numeral.pl b/gv_numeral.pl index 5776a4a..ac294b4 100644 --- a/gv_numeral.pl +++ b/gv_numeral.pl @@ -11,14 +11,13 @@ @version 2014/05-2014/06, 2015/01 */ -:- use_module(math(math_ext)). -:- use_module(math(radix)). -:- use_module(math(rational_ext)). - -:- use_module(plDcg(dcg_abnf)). -:- use_module(plDcg(dcg_abnf_common)). -:- use_module(plDcg(dcg_ascii)). -:- use_module(plDcg(dcg_cardinal)). +:- use_module(plc(dcg/dcg_abnf)). +:- use_module(plc(dcg/dcg_abnf_common)). +:- use_module(plc(dcg/dcg_ascii)). +:- use_module(plc(dcg/dcg_cardinal)). +:- use_module(plc(math/math_ext)). +:- use_module(plc(math/radix)). +:- use_module(plc(math/rational_ext)). diff --git a/load.pl b/load.pl index 5cec32c..de8b5ca 100644 --- a/load.pl +++ b/load.pl @@ -7,7 +7,6 @@ :- use_module(load_project). :- load_project([ plc-'Prolog-Library-Collection', - plDcg, plHtml, plUri ]). diff --git a/plDcg b/plDcg deleted file mode 160000 index 45a2d2b..0000000 --- a/plDcg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 45a2d2b3ce1e3e18533586005b2a6a63eb2300d0 ```

84: 正在比较变动前 e06e6ba 和变动后 0fd12ca

[back to content](#compare) ``` diff diff --git a/plHtml b/plHtml index c2491cb..37bd0bf 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit c2491cb789baef4b2c7b9e30ca79d65a7213af02 +Subproject commit 37bd0bf33676fc06f9153221715a2cf00c4065d0 diff --git a/plUri b/plUri index f1696b3..6550f33 160000 --- a/plUri +++ b/plUri @@ -1 +1 @@ -Subproject commit f1696b3c41635b4c6af3e961e819a5e6c0bf5b75 +Subproject commit 6550f331120c7f63739f69692791760afb507280 ```

85: 正在比较变动前 0fd12ca 和变动后 67c4157

[back to content](#compare) ``` diff diff --git a/README.md b/README.md index eb8512b..b4e3017 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,25 @@ plGraphViz ========== -Easily export graphs represented as Prolog terms to - [GraphViz](http://www.graphviz.org/). +This library allows you to easily export graphs represented as Prolog terms +using [GraphViz](http://www.graphviz.org/), an advanced graph drawing library. The Prolog terms have the following form: ~~~prolog graph(Vertices, Edges, GraphAttrs) ~~~ -`Vertices` and `Edges` are lists of compounds terms of - the following form: +`Vertices` and `Edges` are lists of compound terms of the following form: ~~~prolog vertex(Id, VertexAttrs) -edges(FromId, ToId, EdgeAttrs) +edge(FromId, ToId, EdgeAttrs) ~~~ -`Id` identifies a vertex and need not occur in any of the edges - (i.e., unconnected vertices are allowed). +`Id` identifies a vertex and may or may not occur in any of the edges +(i.e., unconnected vertices are allowed). `FromId` and `ToId` may occur in the list of vertices, - in order to draw an edge between vertices with set attributes. +in order to draw an edge between vertices with set attributes. Attributes have the form `Name=Value`. `GraphAttrs` are attributes of the graph. @@ -28,13 +27,12 @@ Attributes have the form `Name=Value`. `EdgeAttrs` are attributes of the edge. Attribute values are given as Prolog terms as well, - and are type-checked before exporting. +and are type-checked before exporting. Many of the GraphViz attributes are supported. New ones are added on an as-needed bases - (open an issue on Github if you want to see a specific feature added). -Supports HTML-like labels, allowing complex tables to be shown - inside vertices. -Support for vertex clusters is currently under way. +(open an issue on Github if you want to see a specific feature added!). +HTML-like labels are supported, allowing complex tables to be shown +inside vertices. --- @@ -62,7 +60,7 @@ $ swipl run.pl ![](https://raw.githubusercontent.com/wouterbeek/plGraphViz/master/example1.png "Example graph.") The graphic can be saved to a different file by instantiating - the `File` argument. +the `File` argument. --- @@ -152,4 +150,3 @@ export_graph_to_gv_file( --- Developed during 2013-2014 by [Wouter Beek](http://www.wouterbeek.com). - ```

86: 正在比较变动前 67c4157 和变动后 b972e2b

[back to content](#compare) ``` diff diff --git a/gv_attrs.pl b/gv_attrs.pl index 68f42db..8ba1535 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -11,7 +11,7 @@ Support for GraphViz attributes. @author Wouter Beek -@version 2014/06, 2014/11-2014/12 +@version 2014/06, 2014/11-2014/12, 2015/03 */ :- use_module(library(apply)). @@ -23,6 +23,7 @@ Support for GraphViz attributes. :- use_module(plc(dcg/dcg_meta)). :- use_module(plc(dcg/dcg_generics)). :- use_module(plc(generics/db_ext)). +:- use_module(plc(generics/print_ext)). :- use_module(plc(io/file_ext)). :- use_module(plc(io/file_gnu)). @@ -129,11 +130,16 @@ assert_gv_attr_row([Name,UsedBy1,Types1,Default1,Minimum,Notes]):- % Downloads the table describing GraphViz attributes from `graphviz.org`. gv_attrs_download:- - gv_attrs_url(Url), - download_html_dom(Url, Dom, [dialect(html4),silent(true)]), - xpath(Dom, //table(@align=center), TableDom), - html_to_table(TableDom, _, Rows), - maplist(assert_gv_attr_row, Rows). + report_on_process( + 'Updating GraphViz attributes table... ', + ( + gv_attrs_uri(Uri), + download_html_dom(Uri, Dom, [dialect(html5),silent(true)]), + xpath(Dom, //table(@align=lower_case(center)), TableDom), + html_to_table(TableDom, _, Rows), + maplist(assert_gv_attr_row, Rows) + ) + ). %! gv_attrs_file(-File:atom) is det. @@ -167,9 +173,9 @@ gv_attrs_update(_):- gv_attrs_download. -%! gv_attrs_url(-Url:url) is det. +%! gv_attrs_uri(-Url:url) is det. -gv_attrs_url('http://www.graphviz.org/doc/info/attrs.html'). +gv_attrs_uri('http://www.graphviz.org/doc/info/attrs.html'). %! safe_db_attach(+File:atom) is det. diff --git a/gv_color.pl b/gv_color.pl index 34d99eb..0ab3fa7 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -13,7 +13,7 @@ @author Wouter Beek @tbd Color value `transparent` is only available in the output formats ps, svg, fig, vmrl, and the bitmap formats. -@version 2014/06, 2014/10-2014/11, 2015/01 +@version 2014/06, 2014/10-2014/11, 2015/01, 2015/03 */ :- use_module(library(apply)). @@ -29,6 +29,7 @@ :- use_module(plc(dcg/dcg_content)). :- use_module(plc(generics/db_ext)). :- use_module(plc(generics/persistent_db_ext)). +:- use_module(plc(generics/print_ext)). :- use_module(plc(io/file_ext)). :- use_module(plc(io/file_gnu)). @@ -97,11 +98,16 @@ wc_weight(Float) --> %! gv_color_download is det. gv_color_download:- - gv_color_url(Url), - download_html_dom(Url, Dom, [html_dialect(html4),verbose(silent)]), - xpath(Dom, //table(1), TableDom1), - xpath(Dom, //table(2), TableDom2), - maplist(assert_color_table, [x11,svg], [TableDom1,TableDom2]). + report_on_process( + 'Updating the GraphViz color table...', + ( + gv_color_uri(Uri), + download_html_dom(Uri, Dom, [html_dialect(html4),silent(true)]), + xpath(Dom, //table(1), TableDom1), + xpath(Dom, //table(2), TableDom2), + maplist(assert_color_table, [x11,svg], [TableDom1,TableDom2]) + ) + ). assert_color_table(Colorscheme, TableDom):- html_to_table(TableDom, _, Rows), @@ -141,7 +147,7 @@ gv_color_update(_):- gv_color_download. -%! gv_color_url(-Url:url) is det. +%! gv_color_uri(-Url:url) is det. -gv_color_url('http://www.graphviz.org/doc/info/colors.html'). +gv_color_uri('http://www.graphviz.org/doc/info/colors.html'). ```

87: 正在比较变动前 b972e2b 和变动后 8bbc84c

[back to content](#compare) ``` diff diff --git a/gv_file.pl b/gv_file.pl index 6cb739f..991df5f 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -22,7 +22,8 @@ Also converts between GraphViz DOT formatted files and GraphViz output files or SVG DOM structures. @author Wouter Beek -@version 2013/09, 2013/11-2014/01, 2014/05, 2014/07-2014/08, 2014/11-2014/12 +@version 2013/09, 2013/11-2014/01, 2014/05, 2014/07-2014/08, 2014/11-2014/12, + 2015/03 */ :- use_module(library(option)). @@ -30,7 +31,8 @@ and GraphViz output files or SVG DOM structures. :- use_module(plc(generics/code_ext)). :- use_module(plc(io/file_ext)). -:- use_module(plc(process/run_ext)). +:- use_module(plc(process/process_ext)). +:- use_module(plc(process/program_db)). :- use_module(plGraphViz(gv_dot)). @@ -114,15 +116,12 @@ file_to_gv(InputFile, OutputFile, Options):- % Run the GraphViz conversion command in the shell. format(atom(OutputTypeFlag), '-T~a', [OutputType]), format(atom(OutputFileFlag), '-o~a', [OutputFile]), - process_create( - path(Method), - % @tbd Windows hack: - %%%%'C:\\Program Files (x86)\\Graphviz2.38\\bin\\dot.exe', + atomic_list_concat(['GraphViz',Method], ' ', Program), + handle_process( + Method, [OutputTypeFlag,file(InputFile),OutputFileFlag], - [process(PID)] - ), - process_wait(PID, exit(ShellStatus)), - exit_code_handler('GraphViz', ShellStatus). + [detached(true),program(Program)] + ). @@ -155,7 +154,7 @@ export_graph_to_gv_file(ExportGraph, OutputFile, Options):- open_dot(File):- once(find_program_by_file_type(dot, Program)), - run_program(Program, [File]). + handle_process(Program, [File], [program('GraphViz DOT')]). ```

88: 正在比较变动前 8bbc84c 和变动后 033fa14

[back to content](#compare) ``` diff diff --git a/.gitignore b/.gitignore index 7193a38..e6bec15 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *~ *# *.db +*.log data/* diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index 9d0e491..ca7adb3 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit 9d0e49135bbd1916d901ccd18be605699f48c5cc +Subproject commit ca7adb30da33a289e40b01e5e163f860d5c096c7 diff --git a/README.md b/README.md index b4e3017..23a45db 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,6 @@ $ git submodule update --init ~~~prolog $ swipl run.pl -?- use_module(plGraphViz(gv_file)). ?- export_graph_to_gv_file( graph([vertex(1,[]),vertex(2,[])],[edge(1,2,[])],[]), File, diff --git a/gv_file.pl b/gv_file.pl index 991df5f..2e0539d 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -42,9 +42,6 @@ and GraphViz output files or SVG DOM structures. user:prolog_file_type(dot, dot). user:prolog_file_type(pdf, pdf). -:- predicate_options(codes_to_gv_file/3, 3, [ - pass_to(file_to_gv/3, 3) -]). :- predicate_options(file_to_gv/2, 2, [ pass_to(file_to_gv/3, 3) ]). @@ -53,30 +50,13 @@ user:prolog_file_type(pdf, pdf). output(+atom) ]). :- predicate_options(export_graph_to_gv_file/3, 3, [ - pass_to(codes_to_gv_file/3, 3) + pass_to(file_to_gv/3, 3) ]). -%! codes_to_gv_file( -%! +Codes:list(code), -%! ?OutputFile:atom, -%! +Options:list(nvpair) -%! ) is det. - -codes_to_gv_file(Codes, OutputFile, Options):- - absolute_file_name(data(tmp), TmpFile, [access(write),extensions([dot])]), - setup_call_cleanup( - open(TmpFile, write, Write, [encoding(utf8)]), - put_codes(Write, Codes), - close(Write) - ), - file_to_gv(TmpFile, OutputFile, Options). - - - %! file_to_gv(+InputFile:atom, +Options:list(nvpair)) is det. file_to_gv(InputFile, Options):- @@ -120,7 +100,7 @@ file_to_gv(InputFile, OutputFile, Options):- handle_process( Method, [OutputTypeFlag,file(InputFile),OutputFileFlag], - [detached(true),program(Program)] + [program(Program)] ). @@ -142,19 +122,30 @@ file_to_gv(InputFile, OutputFile, Options):- export_graph_to_gv_file(ExportGraph, OutputFile, Options):- once(phrase(gv_graph(ExportGraph), Codes)), - codes_to_gv_file(Codes, OutputFile, Options). + + % Be thread-safe. + thread_self(Id), + atomic_list_concat([gv_file,Id], '_', ThreadName), + absolute_file_name( + data(ThreadName), + TmpFile, + [access(write),extensions([dot])] + ), + setup_call_cleanup( + open(TmpFile, write, Write, [encoding(utf8)]), + put_codes(Write, Codes), + close(Write) + ), + file_to_gv(TmpFile, OutputFile, Options). %! open_dot(+File:atom) is det. % Opens the given DOT file. -% -% @tbd Test support on Windows. -% @tbd Test support on OS-X. open_dot(File):- once(find_program_by_file_type(dot, Program)), - handle_process(Program, [File], [program('GraphViz DOT')]). + handle_process(Program, [file(File)], []). diff --git a/plHtml b/plHtml index 37bd0bf..2919705 160000 --- a/plHtml +++ b/plHtml @@ -1 +1 @@ -Subproject commit 37bd0bf33676fc06f9153221715a2cf00c4065d0 +Subproject commit 2919705d079b1ab28bf3c502a87d1648fd842ed3 diff --git a/plUri b/plUri index 6550f33..1a55127 160000 --- a/plUri +++ b/plUri @@ -1 +1 @@ -Subproject commit 6550f331120c7f63739f69692791760afb507280 +Subproject commit 1a55127517ee0b0cf2ad4fecbe3f84402f5f4c12 diff --git a/run.pl b/run.pl index 8bba736..8c751f4 100644 --- a/run.pl +++ b/run.pl @@ -7,3 +7,5 @@ :- ensure_loaded(load). :- endif. +:- use_module(plGraphViz(gv_file)). + ```

89: 正在比较变动前 033fa14 和变动后 fdb5a9e

[back to content](#compare) ``` diff diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 9794eef..ce8012b 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -212,7 +212,13 @@ doubleList(L) --> % @tbd Support for context-dependent replacements. escString(String) --> - {dcg_phrase(dcg_replace(double_quote, escaped_double_quote), String, String0)}, + { + atom_phrase( + dcg_replace(double_quote, escaped_double_quote), + String, + String0 + ) + }, quoted(atom(String0)). escaped_double_quote --> "\\\"". diff --git a/gv_attrs.pl b/gv_attrs.pl index 8ba1535..fc8529a 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -119,8 +119,8 @@ check_minimum(V, Min1):- %! assert_gv_attr_row(+Row:list(atom)) is det. assert_gv_attr_row([Name,UsedBy1,Types1,Default1,Minimum,Notes]):- - dcg_phrase(translate_usedby(UsedBy2), UsedBy1), - once(dcg_phrase(translate_type(Types2), Types1)), + atom_phrase(translate_usedby(UsedBy2), UsedBy1), + once(atom_phrase(translate_type(Types2), Types1)), sort(UsedBy2, UsedBy3), translate_default(Default1, Default2), assert_gv_attr(Name, UsedBy3, Types2, Default2, Minimum, Notes). ```

90: 正在比较变动前 fdb5a9e 和变动后 6ec582e

[back to content](#compare) ``` diff ```

91: 正在比较变动前 6ec582e 和变动后 68b53b8

[back to content](#compare) ``` diff diff --git a/gv_attrs.pl b/gv_attrs.pl index fc8529a..20036b3 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -28,7 +28,7 @@ Support for GraphViz attributes. :- use_module(plc(io/file_gnu)). :- use_module(plHtml(html)). -:- use_module(plHtml(elements/html_table)). +:- use_module(plHtml(element/html_table)). :- use_module(plGraphViz(gv_attr_type), [gv_attr_type/1]). diff --git a/gv_color.pl b/gv_color.pl index 0ab3fa7..7da7313 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -34,7 +34,7 @@ :- use_module(plc(io/file_gnu)). :- use_module(plHtml(html)). -:- use_module(plHtml(elements/html_table)). +:- use_module(plHtml(element/html_table)). :- db_add_novel(user:prolog_file_type(log, logging)). ```

92: 正在比较变动前 68b53b8 和变动后 46e8f3c

[back to content](#compare) ``` diff diff --git a/gv_attrs.pl b/gv_attrs.pl index 20036b3..add0721 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -28,7 +28,7 @@ Support for GraphViz attributes. :- use_module(plc(io/file_gnu)). :- use_module(plHtml(html)). -:- use_module(plHtml(element/html_table)). +:- use_module(plHtml(html_table)). :- use_module(plGraphViz(gv_attr_type), [gv_attr_type/1]). diff --git a/gv_color.pl b/gv_color.pl index 7da7313..41e153b 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -34,7 +34,7 @@ :- use_module(plc(io/file_gnu)). :- use_module(plHtml(html)). -:- use_module(plHtml(element/html_table)). +:- use_module(plHtml(html_table)). :- db_add_novel(user:prolog_file_type(log, logging)). ```

93: 正在比较变动前 46e8f3c 和变动后 3162d88

[back to content](#compare) ``` diff diff --git a/gv_file.pl b/gv_file.pl index 2e0539d..2c6ed93 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -113,7 +113,7 @@ file_to_gv(InputFile, OutputFile, Options):- % Returns a file containing a GraphViz visualization of the given graph. % % The following options are supported: -% - `method(+Method:atom` +% - `method(+Method:atom)` % The algorithm used by GraphViz for positioning the tree nodes. % Either =dot= (default) or =sfdp=. % - `output(+FileType:atom)` @@ -122,7 +122,7 @@ file_to_gv(InputFile, OutputFile, Options):- export_graph_to_gv_file(ExportGraph, OutputFile, Options):- once(phrase(gv_graph(ExportGraph), Codes)), - + % Be thread-safe. thread_self(Id), atomic_list_concat([gv_file,Id], '_', ThreadName), ```

94: 正在比较变动前 3162d88 和变动后 714b2e0

[back to content](#compare) ``` diff diff --git a/gv_attr_type.pl b/gv_attr_type.pl index ce8012b..1e3515c 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -49,7 +49,7 @@ @version 2014/06, 2014/11-2015/01 */ -:- use_module(library(dcg/basics), [float//1,integer//1]). +:- use_module(library(dcg/basics)). :- use_module(plc(dcg/dcg_abnf)). :- use_module(plc(dcg/dcg_ascii)). diff --git a/gv_attrs.pl b/gv_attrs.pl index add0721..489ce51 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -15,6 +15,7 @@ Support for GraphViz attributes. */ :- use_module(library(apply)). +:- use_module(library(dcg/basics)). :- use_module(library(persistency)). :- use_module(library(xpath)). diff --git a/gv_color.pl b/gv_color.pl index 41e153b..c4c82b4 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -17,7 +17,7 @@ */ :- use_module(library(apply)). -:- use_module(library(dcg/basics), [float//1]). +:- use_module(library(dcg/basics)). :- use_module(library(lists), except([delete/3,subset/2])). :- use_module(library(persistency)). :- use_module(library(xpath)). diff --git a/gv_dot.pl b/gv_dot.pl index 19657f5..637a5ab 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -26,6 +26,7 @@ a_list = ID "=" ID [","] [a_list] */ :- use_module(library(apply)). +:- use_module(library(dcg/basics)). :- use_module(library(lists), except([delete/3,subset/2])). :- use_module(library(ordsets)). ```

95: 正在比较变动前 714b2e0 和变动后 af7a387

[back to content](#compare) ``` diff diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 1e3515c..6d572ab 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -49,7 +49,7 @@ @version 2014/06, 2014/11-2015/01 */ -:- use_module(library(dcg/basics)). +:- use_module(library(dcg/basics), except([string//1])). :- use_module(plc(dcg/dcg_abnf)). :- use_module(plc(dcg/dcg_ascii)). ```

96: 正在比较变动前 af7a387 和变动后 7b434e3

[back to content](#compare) ``` diff diff --git a/gv_color.pl b/gv_color.pl index c4c82b4..1f3f9d6 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -22,8 +22,8 @@ :- use_module(library(persistency)). :- use_module(library(xpath)). -:- use_module(plc(dcg/abnf_core_rules)). :- use_module(plc(dcg/dcg_abnf)). +:- use_module(plc(dcg/dcg_abnf_rules)). :- use_module(plc(dcg/dcg_atom)). :- use_module(plc(dcg/dcg_cardinal)). :- use_module(plc(dcg/dcg_content)). diff --git a/gv_numeral.pl b/gv_numeral.pl index ac294b4..bff1255 100644 --- a/gv_numeral.pl +++ b/gv_numeral.pl @@ -16,6 +16,7 @@ :- use_module(plc(dcg/dcg_ascii)). :- use_module(plc(dcg/dcg_cardinal)). :- use_module(plc(math/math_ext)). +:- use_module(plc(math/positional)). :- use_module(plc(math/radix)). :- use_module(plc(math/rational_ext)). @@ -56,7 +57,7 @@ gv_numeral(N) --> ( % [1] The fractional is zero, so only write the integer part % and do not write the decimal separator. {F =:= 0} - -> {weights_nonneg(IW, I)}, + -> {positional(I, IW)}, '[0-9]+'(IW) ; % [2] The integer part is zero, so only write the fractional part, % preceded by the decimal separator. @@ -66,7 +67,7 @@ gv_numeral(N) --> '[0-9]*'(FW) ; % [3] Both the integer part and the fractional are non-zero, % so write both of them, with the decimal separator in-between. - {weights_nonneg(IW, I)}, + {positional(I, IW)}, '[0-9]+'(IW), ".", {weights_fraction(FW, F)}, ```

97: 正在比较变动前 7b434e3 和变动后 dcbcb4d

[back to content](#compare) ``` diff diff --git a/gv_dot.pl b/gv_dot.pl index 637a5ab..e98361b 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -146,151 +146,14 @@ gv_generic_attributes_statement(_, _, []) --> [], !. gv_generic_attributes_statement(Kind, I, KindAttrs) --> indent(I), gv_kind(Kind), " ", - bracketed(square, '*'(gv_attr(Kind), KindAttrs, [])), - line_feed. - - - -%! gv_graph(+Graph:compound)// -% The follow graph attributes are supported, -% beyond the GraphViz attributes for graphs: -% * `directed(+boolean)` -% Whether the graph is directed (`true`) or undirected (`false`). -% Default: `false`. -% * `name(+GraphName:atom)` -% * `strict(+StrictGraph:boolean)` -% This forbids the creation of self-arcs and multi-edges; -% they are ignored in the input file. -% Only in combinattion with directionality `directed`. -% -% ```abnf -% graph = ["strict"] ("graph" / "digraph") [ID] "{" stmt_list "}" -% ``` -% -% `GraphTerm` is a compound term of the following form: -% ```prolog -% graph(VertexTerms,RankedVertexTerms,EdgeTerms,GraphAttributes) -% ``` -% -% `RankedVertexTerms` is a list of compound terms of the following form: -% ```prolog -% rank(RankNode,ContentNodes) -% ``` -% -% @tbd Add support for subgraphs (arbitrary nesting). -% @tbd Add support for escape strings: -% http://www.graphviz.org/doc/info/attrs.html#k:escString -% @tbd Assert attributes that are generic with respect to a subgraph. -% @tbd Not all vertex and edge properties can be shared it seems (e.g., label). - -gv_graph(graph(VTerms,ETerms,GAttrs)) --> - gv_graph(graph(VTerms,[],ETerms,GAttrs)). - -gv_graph(graph(VTerms,RankedVTerms,ETerms,GAttrs1)) --> - { - shared_attributes(VTerms, SharedVAttrs, NewVTerms), - shared_attributes(ETerms, SharedEAttrs, NewETerms), - select_nvpair(strict=Strict, GAttrs1, GAttrs2, false), - select_nvpair(directed=Directed, GAttrs2, GAttrs3, true), - select_nvpair(name=GName, GAttrs3, GAttrs4, noname), - add_default_nvpair(GAttrs4, overlap, false, GAttrs5), - I = 0 - }, - - % The first statement in the GraphViz output. - % States that this file represents a graph according to the GraphViz format. - indent(I), - gv_strict(Strict), - gv_graph_type(Directed), " ", - gv_id(GName), " ", - - % The body of the DOT file appears between curly braces. - bracketed( - curly, - gv_graph0( - I, - NewVTerms, SharedVAttrs, RankedVTerms, - NewETerms, SharedEAttrs, - Directed, GAttrs5 - ) - ), - line_feed. - -gv_graph0( - I, - NewVTerms, SharedVAttrs, RankedVTerms, - NewETerms, SharedEAttrs, - Directed, GAttrs -) --> - line_feed, - - % The following lines are indented. - {NewI is I + 1}, - - % Attributes that apply to the graph as a whole. - gv_generic_attributes_statement(graph, NewI, GAttrs), - - % Attributes that are the same for all nodes. - gv_generic_attributes_statement(node, NewI, SharedVAttrs), - - % Attributes that are the same for all edges. - gv_generic_attributes_statement(edge, NewI, SharedEAttrs), - - % Only add a line_feed if some content was already written - % and some content is about to be written. - ( - { - % Succeeds if no content was written. - (GAttrs == [], SharedVAttrs == [], SharedEAttrs == []) - ; - % Succeeds if no content is about to be written. - (NewVTerms == [], RankedVTerms == []) - } - -> - "" - ; - line_feed - ), - - % The list of GraphViz nodes. - '*'(gv_node_statement(NewI), NewVTerms, []), - ({NewVTerms == []} -> "" ; line_feed), - - % The ranked GraphViz nodes (displayed at the same height). - '*'(gv_ranked_node_collection(NewI), RankedVTerms, []), - ({RankedVTerms == []} -> "" ; line_feed), - - { - findall( - edge(FromId,ToId,[]), - ( - nth0(Index1, RankedVTerms, rank(vertex(FromId,_),_)), - nth0(Index2, RankedVTerms, rank(vertex(ToId,_),_)), - % We assume that the rank vertices are nicely ordered. - succ(Index1, Index2) - ), - RankEdges - ) - }, - - % The rank edges. - '*'(gv_edge_statement(NewI, Directed), RankEdges, []), - - % The non-rank edges. - '*'(gv_edge_statement(NewI, Directed), NewETerms, []), - - % Note that we do not include a line_feed here. + "[", + gv_attrs(Kind, KindAttrs), + "]\n". - % We want to indent the closing curly brace. - indent(I). - - - -%! gv_graph_type(+Directed:boolean)// . -% The type of graph that is represented. - -gv_graph_type(false) --> "graph". -gv_graph_type(true) --> "digraph". +gv_attrs(_, []) --> !, "". +gv_attrs(Kind, [H|T]) --> + gv_attr(Kind, H), + gv_attrs(Kind, T). @@ -456,53 +319,3 @@ gv_ranked_node_collection(I, rank(Rank_V_Term,Content_V_Terms)) --> indent(I) )), line_feed. - - - -%! gv_strict(+Strict:boolean)// is det. -% The keyword denoting that the graph is strict, i.e., has no self-arcs and -% no multi-edges. -% This only applies to directed graphs. - -gv_strict(false) --> []. -gv_strict(true) --> "strict ". - - - - - -% HELPERS - -add_default_nvpair(Attrs1, N, Default, Attrs2):- - add_default_nvpair(Attrs1, N, Default, _, Attrs2). - -add_default_nvpair(Attrs, N, _, V, Attrs):- - memberchk(N=V, Attrs), !. -add_default_nvpair(Attrs1, N, Default, Default, Attrs2):- - ord_add_element(Attrs1, N=Default, Attrs2). - -select_nvpair(N=V, Attrs1, Attrs2, _):- - memberchk(N=V, Attrs1), !, - select(N=V, Attrs1, Attrs2). -select_nvpair(_=Default, Attrs, Attrs, Default). - - -extract_shared([], []):- !. -extract_shared(Argss, Shared):- - ord_intersection(Argss, Shared). - -remove_shared_attributes(Shared, Args1, Args2):- - ord_subtract(Args1, Shared, Args2). - -shared_attributes(Terms1, SharedAs, Terms2):- - maplist(term_to_attrs, Terms1, As1), - extract_shared(As1, SharedAs), - maplist(remove_shared_attributes(SharedAs), As1, As2), - maplist(term_change_attrs, Terms1, As2, Terms2). - -term_change_attrs(edge(From,To,_), A, edge(From,To,A)). -term_change_attrs(vertex(Id,_), A, vertex(Id,A)). - -term_to_attrs(edge(_,_,A), A). -term_to_attrs(vertex(_,A), A). - diff --git a/gv_file.pl b/gv_file.pl index 2c6ed93..5d2228e 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -1,40 +1,24 @@ :- module( gv_file, [ - file_to_gv/2, % +InputFile:atom - % +Options:list(nvpair) - file_to_gv/3, % +InputFile:atom - % ?OutputFile:atom - % +Options:list(nvpair) - export_graph_to_gv_file/3, % +ExportGraph:compound - % ?OutputFile:atom - % +Options:list(nvpair) - open_dot/1 % +File:file + gv_export/3 % +ExportGraph:compound + % +OutputFile:atom + % +Options:list(nvpair) ] ). /** GraphViz file -Predicates for converting GIF-formatted terms -into GraphViz output files or SVG DOM structures. - -Also converts between GraphViz DOT formatted files -and GraphViz output files or SVG DOM structures. - @author Wouter Beek -@version 2013/09, 2013/11-2014/01, 2014/05, 2014/07-2014/08, 2014/11-2014/12, - 2015/03 +@version 2015/07 */ +:- use_module(library(error)). +:- use_module(library(gv/gv_dot)). :- use_module(library(option)). :- use_module(library(process)). -:- use_module(plc(generics/code_ext)). -:- use_module(plc(io/file_ext)). :- use_module(plc(process/process_ext)). -:- use_module(plc(process/program_db)). - -:- use_module(plGraphViz(gv_dot)). :- dynamic(user:prolog_file_type/2). :- multifile(user:prolog_file_type/2). @@ -42,29 +26,43 @@ and GraphViz output files or SVG DOM structures. user:prolog_file_type(dot, dot). user:prolog_file_type(pdf, pdf). -:- predicate_options(file_to_gv/2, 2, [ - pass_to(file_to_gv/3, 3) -]). -:- predicate_options(file_to_gv/3, 3, [ - method(+atom), - output(+atom) -]). -:- predicate_options(export_graph_to_gv_file/3, 3, [ - pass_to(file_to_gv/3, 3) -]). - +:- predicate_options(gv_export/3, 3, [pass_to(file_to_gv/3, 3)]). +:- predicate_options(file_to_gv/3, 3, [method(+atom),output(+atom)]). +%! gv_export( +%! +ExportGraph:compound, +%! +OutputFile:atom, +%! +Options:list(nvpair) +%! ) is det. +% Returns a file containing a GraphViz visualization of the given graph. +% +% The following options are supported: +% - `method(+Method:atom)` +% The algorithm used by GraphViz for positioning the tree nodes. +% Either =dot= (default) or =sfdp=. +% - `output(+FileType:atom)` +% The file type of the generated GraphViz file. +% Default: `pdf`. -%! file_to_gv(+InputFile:atom, +Options:list(nvpair)) is det. +gv_export(ExportGraph, OutputFile, Options):- + once(phrase(gv_graph(ExportGraph), Codes)), -file_to_gv(InputFile, Options):- - file_to_gv(InputFile, _, Options). + % Be thread-safe. + thread_self(Id), + atomic_list_concat([gv_file,Id], '_', ThreadName), + absolute_file_name(data(ThreadName), TmpFile, [access(write),file_type(dot)]), + setup_call_cleanup( + open(TmpFile, write, Write, [encoding(utf8)]), + put_codes(Write, Codes), + close(Write) + ), + file_to_gv(TmpFile, OutputFile, Options). %! file_to_gv( %! +InputFile:atom, -%! ?OutputFile:atom, +%! +OutputFile:atom, %! +Options:list(nvpair) %! ) is det. % Converts a GraphViz DOT file to an image file, using a specific @@ -87,12 +85,6 @@ file_to_gv(InputFile, OutputFile, Options):- findall(OutputType0, gv_output_type(OutputType0), OutputTypes), must_be(oneof(OutputTypes), OutputType), - % The output file is either given or created. - ( var(OutputFile) - -> file_alternative(InputFile, _, _, OutputType, OutputFile) - ; is_absolute_file_name(OutputFile) - ), - % Run the GraphViz conversion command in the shell. format(atom(OutputTypeFlag), '-T~a', [OutputType]), format(atom(OutputFileFlag), '-o~a', [OutputFile]), @@ -105,53 +97,7 @@ file_to_gv(InputFile, OutputFile, Options):- -%! export_graph_to_gv_file( -%! +ExportGraph:compound, -%! ?OutputFile:atom, -%! +Options:list(nvpair) -%! ) is det. -% Returns a file containing a GraphViz visualization of the given graph. -% -% The following options are supported: -% - `method(+Method:atom)` -% The algorithm used by GraphViz for positioning the tree nodes. -% Either =dot= (default) or =sfdp=. -% - `output(+FileType:atom)` -% The file type of the generated GraphViz file. -% Default: `pdf`. - -export_graph_to_gv_file(ExportGraph, OutputFile, Options):- - once(phrase(gv_graph(ExportGraph), Codes)), - - % Be thread-safe. - thread_self(Id), - atomic_list_concat([gv_file,Id], '_', ThreadName), - absolute_file_name( - data(ThreadName), - TmpFile, - [access(write),extensions([dot])] - ), - setup_call_cleanup( - open(TmpFile, write, Write, [encoding(utf8)]), - put_codes(Write, Codes), - close(Write) - ), - file_to_gv(TmpFile, OutputFile, Options). - - - -%! open_dot(+File:atom) is det. -% Opens the given DOT file. - -open_dot(File):- - once(find_program_by_file_type(dot, Program)), - handle_process(Program, [file(File)], []). - - - - - -% HELPERS +% HELPERS % gv_method(circo). gv_method(dot). @@ -162,7 +108,6 @@ gv_method(sfdp). gv_method(twopi). - gv_output_type(bmp). gv_output_type(canon). gv_output_type(dot). diff --git a/gv_graph.pl b/gv_graph.pl new file mode 100644 index 0000000..dd4af97 --- /dev/null +++ b/gv_graph.pl @@ -0,0 +1,229 @@ +:- module( + gv_graph, + [ + gv_graph//1 % +Graph:compound + ] +). + +/** GraphViz graph + +@author Wouter Beek +@version 2015/07 +*/ + +:- use_module(library(apply)). +:- use_module(library(lists)). +:- use_module(library(option)). + + + +%! gv_graph(+Graph:compound)// +% The follow graph attributes are supported, +% beyond the GraphViz attributes for graphs: +% * `directed(+boolean)` +% Whether the graph is directed (`true`) or undirected (`false`). +% Default: `false`. +% * `name(+GraphName:atom)` +% * `strict(+StrictGraph:boolean)` +% This forbids the creation of self-arcs and multi-edges; +% they are ignored in the input file. +% Only in combinattion with directionality `directed`. +% +% ```abnf +% graph = ["strict"] ("graph" / "digraph") [ID] "{" stmt_list "}" +% ``` +% +% `GraphTerm` is a compound term of the following form: +% ```prolog +% graph(VertexTerms,RankedVertexTerms,EdgeTerms,GraphAttributes) +% ``` +% +% `RankedVertexTerms` is a list of compound terms of the following form: +% ```prolog +% rank(RankNode,ContentNodes) +% ``` +% +% @tbd Add support for subgraphs (arbitrary nesting). +% @tbd Add support for escape strings: +% http://www.graphviz.org/doc/info/attrs.html#k:escString +% @tbd Assert attributes that are generic with respect to a subgraph. +% @tbd Not all vertex and edge properties can be shared it seems (e.g., label). + +gv_graph(G) --> + gv_graph(G, 0). + +gv_graph(G1, I) --> + { + include_ranks(G1, G2), + G2 = graph(VTerms,RankedVTerms,ETerms,GAttrs1), + shared_attributes(VTerms, SharedVAttrs, NewVTerms), + shared_attributes(ETerms, SharedEAttrs, NewETerms), + add_default(GAttrs1, overlap(false), GAttrs2), + I = 0 + }, + + % The first statement in the GraphViz output. + % States that this file represents a graph according to the GraphViz format. + indent(I), + + % Strictness. + {select_option(strict(Strict), GAttrs2, GAttrs3, false)}, + gv_strict(Strict), + + % Directedness. + {select_option(directed(Directed), GAttrs3, GAttrs4, true)}, + gv_graph_type(Directed), " ", + + % Graph name. + ( {select_name(GName), GAttrs4, GAttrs5)} + -> gv_id(GName), " ", + ; {GAttrs5 = GAttrs4} + ), + + % The body of the DOT file appears between curly braces. + "{\n", + + % The following lines are indented. + {NewI is I + 1}, + + % Attributes that apply to the graph as a whole. + gv_generic_attributes_statement(graph, NewI, GAttrs5), + + % Attributes that are the same for all nodes. + gv_generic_attributes_statement(node, NewI, SharedVAttrs), + + % Attributes that are the same for all edges. + gv_generic_attributes_statement(edge, NewI, SharedEAttrs), + + % Only add a line_feed if some content was already written + % and some content is about to be written. + ( % Succeeds if no content was written. + {(GAttrs == [], SharedVAttrs == [], SharedEAttrs == [])} + -> "" + ; % Succeeds if no content is about to be written. + {(NewVTerms == [], RankedVTerms == [])} + -> "" + ; "\n" + ), + + % The list of GraphViz nodes. + gv_node_statements(NewI, NewVTerms), + ( {NewVTerms == []} + -> "" + ; "\n" + ), + + % The ranked GraphViz nodes (displayed at the same height). + gv_ranked_node_collections(NewI, RankedVTerms), + ( {RankedVTerms == []} + -> "" + ; "\n" + ), + + { + findall( + edge(FromId,ToId,[]), + ( + nth0(Index1, RankedVTerms, rank(vertex(FromId,_),_)), + nth0(Index2, RankedVTerms, rank(vertex(ToId,_),_)), + % We assume that the rank vertices are nicely ordered. + succ(Index1, Index2) + ), + RankEdges + ) + }, + + % The rank edges. + gv_edge_statements(NewI, Directed, RankEdges), + + % The non-rank edges. + gv_edge_statements(NewI, Directed, NewETerms), + + % Note that we do not include a line_feed here. + + % We want to indent the closing curly brace. + indent(I), + "}\n". + +gv_edge_statements(_, _, []) --> !, "". +gv_edge_statements(I, Dir, [H|T]) --> + gv_edge_statement(I, Dir, H), + gv_edge_statements(I, Dir, T). + +gv_node_statements(_, []) --> !, "". +gv_node_statements(I, [H|T]) --> + gv_node_statement(I, H), + gv_node_statements(I, T). + +gv_ranked_node_collections(_, []) --> !, "". +gv_ranked_node_collections(I, [H|T]) --> + gv_ranked_node_collection(I, H), + gv_ranked_node_collections(I, T), + + + +% HELPERS % + +%! add_default_option( +%! +Options:list(compound), +%! +Default:compound, +%! -NewOptions:list(compound) +%! ) is det. + +add_default(L1, Opt, L2):- + Opt =.. [N,V], + Opt0 =.. [N,_], + ( option(Opt0, L1) + -> true + ; L2 = [Opt|L1] + ). + + +%! gv_graph_type(+Directed:boolean)// is det. +% The type of graph that is represented. + +gv_graph_type(false) --> "graph". +gv_graph_type(true) --> "digraph". + + +%! gv_strict(+Strict:boolean)// is det. +% The keyword denoting that the graph is strict, i.e., has no self-arcs and +% no multi-edges. +% This only applies to directed graphs. + +gv_strict(false) --> []. +gv_strict(true) --> "strict ". + + +%! invlude_ranges(+Graph:compound, -GraphWithRanks:compound) is det. +% Ensures that there is a ranks components in +% the graph-denoting compound term. + +include_ranks(graph(Vs,Rs,Es,L), graph(Vs,Rs,Es,L)). +include_ranks(graph(Vs,Es,L), graph(Vs,[],Es,L)). + + +%! shared_attributes( +%! +Terms:list(compound), +%! -SharedAttributes:list(compound), +%! -NewTerms:list(compound) +%! ) is det. + +shared_attributes(Ts1, Shared, Ts2):- + maplist(term_to_attrs, Ts1, L1), + extract_shared(L1, Shared), + maplist(remove_shared_attributes(Shared), L1, L2), + maplist(term_change_attrs, Ts1, L2, Ts2). + +term_to_attrs(edge(_,_,A), A). +term_to_attrs(vertex(_,A), A). + +extract_shared([], []):- !. +extract_shared(Argss, Shared):- + ord_intersection(Argss, Shared). + +remove_shared_attributes(Shared, Args1, Args2):- + ord_subtract(Args1, Shared, Args2). + +term_change_attrs(edge(From,To,_), A, edge(From,To,A)). +term_change_attrs(vertex(Id,_), A, vertex(Id,A)). ```

98: 正在比较变动前 dcbcb4d 和变动后 50a3dbc

[back to content](#compare) ``` diff diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection index ca7adb3..88874a7 160000 --- a/Prolog-Library-Collection +++ b/Prolog-Library-Collection @@ -1 +1 @@ -Subproject commit ca7adb30da33a289e40b01e5e163f860d5c096c7 +Subproject commit 88874a7f451df36309d1d6ade03bc7186b4f6c8b diff --git a/gv_attr_type.pl b/gv_attr_type.pl index 6d572ab..b3e41ca 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -51,15 +51,6 @@ :- use_module(library(dcg/basics), except([string//1])). -:- use_module(plc(dcg/dcg_abnf)). -:- use_module(plc(dcg/dcg_ascii)). -:- use_module(plc(dcg/dcg_atom)). -:- use_module(plc(dcg/dcg_cardinal)). -:- use_module(plc(dcg/dcg_content)). -:- use_module(plc(dcg/dcg_generics)). -:- use_module(plc(dcg/dcg_quote)). -:- use_module(plc(dcg/dcg_replace)). - :- use_module(plGraphViz(gv_html)). @@ -203,25 +194,32 @@ double(N) --> %! doubleList(+Doubles:list(float))// . -doubleList(L) --> - '+'(double, L, [separator(colon)]). +doubleList([]) --> !, "". +doubleList([H]) --> !, double(H) +doubleList([H|T]) --> double(H), ":", doubleList(T). %! escString(+String:atom)// . % @tbd Support for context-dependent replacements. -escString(String) --> +escString(S1) --> { - atom_phrase( - dcg_replace(double_quote, escaped_double_quote), - String, - String0 - ) + atom_codes(S1, Cs1), + phrase(escape_double_quotes, Cs1, Cs2), + atom_codes(S2, Cs2) }, - quoted(atom(String0)). -escaped_double_quote --> - "\\\"". + "\"", + atom(S2), + "\"". + +escape_double_quotes, [92,34] --> + [34], !, + escape_double_quotes. +escape_double_quotes, [X] --> + [X], + escape_double_quotes. + @@ -449,7 +447,9 @@ smoothType(triangle). % A GraphViz string. string(Content) --> - quoted(atom(Content)). + "\"", + atom(Content), + "\"". diff --git a/gv_attrs.pl b/gv_attrs.pl index 489ce51..1e8ccdf 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -6,34 +6,25 @@ ] ). -/** GraphViz: Attributes - -Support for GraphViz attributes. +/** GraphViz attributes @author Wouter Beek -@version 2014/06, 2014/11-2014/12, 2015/03 +@version 2015/07 */ :- use_module(library(apply)). :- use_module(library(dcg/basics)). +:- use_module(library(lists)). :- use_module(library(persistency)). :- use_module(library(xpath)). -:- use_module(plc(dcg/dcg_atom)). -:- use_module(plc(dcg/dcg_content)). -:- use_module(plc(dcg/dcg_meta)). -:- use_module(plc(dcg/dcg_generics)). -:- use_module(plc(generics/db_ext)). -:- use_module(plc(generics/print_ext)). -:- use_module(plc(io/file_ext)). -:- use_module(plc(io/file_gnu)). - -:- use_module(plHtml(html)). -:- use_module(plHtml(html_table)). - :- use_module(plGraphViz(gv_attr_type), [gv_attr_type/1]). +:- use_module(plGraphViz(gv_util)). + +:- dynamic(user:prolog_file_type/2). +:- multifile(user:prolog_file_type/2). -:- db_add_novel(user:prolog_file_type(log, logging)). +user:prolog_file_type(log, logging). %! gv_attr( %! ?Name:atom, @@ -131,13 +122,13 @@ assert_gv_attr_row([Name,UsedBy1,Types1,Default1,Minimum,Notes]):- % Downloads the table describing GraphViz attributes from `graphviz.org`. gv_attrs_download:- - report_on_process( + verbose_process( 'Updating GraphViz attributes table... ', ( gv_attrs_uri(Uri), - download_html_dom(Uri, Dom, [dialect(html5),silent(true)]), + html_download(Uri, Dom), xpath(Dom, //table(@align=lower_case(center)), TableDom), - html_to_table(TableDom, _, Rows), + html_table(TableDom, _, Rows), maplist(assert_gv_attr_row, Rows) ) ). @@ -146,22 +137,19 @@ gv_attrs_download:- %! gv_attrs_file(-File:atom) is det. gv_attrs_file(File):- - absolute_file_name( - data(gv_attrs), - File, - [access(write),file_type(logging)] - ). + absolute_file_name(gv_attrs, File, [access(write),file_type(logging)]). %! gv_attrs_init is det. gv_attrs_init:- gv_attrs_file(File), - safe_db_attach(File), + persistent_db_attach(File), file_age(File, Age), gv_attrs_update(Age). + %! gv_attrs_update(+Age:float) is det. % The persistent store is still fresh. @@ -174,20 +162,12 @@ gv_attrs_update(_):- gv_attrs_download. + %! gv_attrs_uri(-Url:url) is det. gv_attrs_uri('http://www.graphviz.org/doc/info/attrs.html'). -%! safe_db_attach(+File:atom) is det. - -safe_db_attach(File):- - exists_file(File), !, - db_attach(File, []). -safe_db_attach(File):- - touch_file(File), - safe_db_attach(File). - %! translate_default(+Default1:atom, -Default2:atom) is det. @@ -198,24 +178,36 @@ translate_default('', _):- !. translate_default(Default, Default). + %! translate_type(-Types:list(atom))// is det. +translate_type([]) --> !, []. translate_type([H|T]) --> {gv_attr_type(H)}, atom(H), whites, translate_type(T). -translate_type([]) --> !, []. + %! translated_usedby( %! -UsedBy:list(oneof([cluster,edge,graph,node,subgraph])) %! )// is det. -translate_usedby([cluster|T]) --> `C`, !, translate_usedby(T). -translate_usedby([edge|T]) --> `E`, !, translate_usedby(T). -translate_usedby([graph|T]) --> `G`, !, translate_usedby(T). -translate_usedby([node|T]) --> `N`, !, translate_usedby(T). -translate_usedby([subgraph|T]) --> `S`, !, translate_usedby(T). -translate_usedby([]) --> []. - +translate_usedby([cluster|T]) --> + "C", !, + translate_usedby(T). +translate_usedby([edge|T]) --> + "E", !, + translate_usedby(T). +translate_usedby([graph|T]) --> + "G", !, + translate_usedby(T). +translate_usedby([node|T]) --> + "N", !, + translate_usedby(T). +translate_usedby([subgraph|T]) --> + "S", !, + translate_usedby(T). +translate_usedby([]) --> + "". diff --git a/gv_color.pl b/gv_color.pl index 1f3f9d6..b8cf308 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -56,34 +56,41 @@ color(rgb(Red,Green,Blue)) --> !, "#", - '#'(3, hex_color, [Red,Green,Blue], []). + hex_color(Red), + hex_color(Green), + hex_color(Blue). color(rgbs(Red,Green,Blue,Alpha)) --> !, - "#", - '#'(4, hex_color, [Red,Green,Blue,Alpha], []). + color(rgb(Red,Green,Blue)), + hex_color(Alpha). color(hsv(Hue,Saturation,Value)) --> !, - '#'(3, hsv_color, [Hue,Saturation,Value], []). + hsv_color(Hue), + hsv_color(Saturation), + hsv_color(Value). color(Name) --> {gv_color(_, Name)}, atom(Name). hex_color(I) --> - {W1 is I / 16}, - 'HEX'(W1), - {W2 is I mod 16}, - 'HEX'(W2). + xinteger(I). hsv_color(D, Head, Tail):- format(codes(Head,Tail), '~2f', [D]). + %! colorList(+Pairs:list(pair(compound,float)))// . -colorList(Pairs) --> - '+'(wc, Pairs, []). +colorList([H]) --> !, + wc(H). +colorList([H|T]) --> + wc(H), + colorList(T). wc(Color-Float) --> color(Color), - '?'(wc_weight(Float), []). + ( wc_weight(Float) + ; "" + ). wc_weight(Float) --> ";", diff --git a/gv_dot.pl b/gv_dot.pl index e98361b..c26d629 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -30,19 +30,8 @@ a_list = ID "=" ID [","] [a_list] :- use_module(library(lists), except([delete/3,subset/2])). :- use_module(library(ordsets)). -:- use_module(plc(dcg/dcg_abnf)). -:- use_module(plc(dcg/dcg_arrow)). -:- use_module(plc(dcg/dcg_ascii)). -:- use_module(plc(dcg/dcg_atom)). -:- use_module(plc(dcg/dcg_bracket)). -:- use_module(plc(dcg/dcg_content)). -:- use_module(plc(dcg/dcg_generics)). -:- use_module(plc(dcg/dcg_meta)). -:- use_module(plc(dcg/dcg_quote)). - :- use_module(plGraphViz(gv_attrs)). :- use_module(plGraphViz(gv_html)). -:- use_module(plGraphViz(gv_numeral)). @@ -90,7 +79,7 @@ gv_compass_pt(w) --> "w". % undirected (operator `--`). gv_edge_operator(false) --> !, "--". -gv_edge_operator(true) --> arrow(right, 2). +gv_edge_operator(true) --> "->". @@ -120,7 +109,9 @@ gv_edge_statement(I, Directed, edge(FromId,ToId,EAttrs)) --> % We want `colorscheme/1` from the edges and % `directionality/1` from the graph. - bracketed(square, '*'(gv_attr(edge), EAttrs, [])), + "[", + gv_attrs(edge, EAttrs), + "]", line_feed. @@ -184,11 +175,14 @@ gv_id(html_like_label(Content)) --> !, % Double-quoted strings. % The quotes are already part of the given atom. gv_id(double_quoted_string(Atom)) --> !, - quoted(atom(Atom)). + "\"", + atom(Atom), + "\"". % Numerals. gv_id(N) --> {number(N)}, !, - gv_numeral(N). + % @tbd Use gv_numeral//1. + number(N). % Alpha-numeric strings. gv_id(Atom) --> {atom_codes(Atom, [H|T])}, @@ -198,8 +192,10 @@ gv_id(Atom) --> % GraphViz keyword. {\+ gv_keyword([H|T])}. -gv_id_first(X) --> ascii_letter(X). -gv_id_first(X) --> underscore(X). +gv_id_first(X) --> + ascii_alpha(X). +gv_id_first(X) --> + underscore(X). gv_id_rest([]) --> []. gv_id_rest([H|T]) --> @@ -213,10 +209,10 @@ gv_id_rest([H|T]) --> %! gv_keyword(+Codes:list(code)) is semidet. % Succeeds if the given codes for a GraphViz reserved keyword. -gv_keyword(Codes):- +gv_keyword(Cs):- % Obviously, the keywords do not occur on the difference list input. % So we must use phrase/[2,3]. - phrase(gv_keyword, Codes). + phrase(gv_keyword, Cs). %! gv_keyword// . % GraphViz has reserved keywords that cannot be used as identifiers. @@ -260,18 +256,23 @@ gv_node_id(Id) --> gv_node_statement(I, vertex(Id,VAttrs)) --> indent(I), - gv_node_id(Id), " ", - bracketed(square, '*'(gv_attr(node), VAttrs, [])), - line_feed. + gv_node_id(Id), + " [", + gv_attrs(node, VAttrs), + "\n". gv_port --> gv_port_location, - '?'(gv_port_angle, []). + ( gv_port_angle + ; "" + ). gv_port --> gv_port_angle, - '?'(gv_port_location, []). + ( gv_port_location + ; "" + ). gv_port --> ":", gv_compass_pt(_). @@ -284,38 +285,31 @@ gv_port_location --> ":", gv_id(_). gv_port_location --> - ":", - bracketed( - round, - ( - gv_id(_), - ",", - gv_id(_) - ) - ). + ":(", + gv_id(_), + ",", + gv_id(_) + ")". gv_ranked_node_collection(I, rank(Rank_V_Term,Content_V_Terms)) --> indent(I), - bracketed(curly, ( - line_feed, - - % The rank attribute. - {NewI is I + 1}, - indent(NewI), - gv_attr(subgraph, rank=same), - ";", - line_feed, - - % Vertice statements. - '*'( - gv_node_statement(NewI), - [Rank_V_Term|Content_V_Terms], - [] - ), - - % We want to indent the closing curly brace. - indent(I) - )), - line_feed. + "{\n", + + % The rank attribute. + {NewI is I + 1}, + indent(NewI), + gv_attr(subgraph, rank=same), + ";\n", + + % Vertice statements. + '*'( + gv_node_statement(NewI), + [Rank_V_Term|Content_V_Terms], + [] + ), + + % We want to indent the closing curly brace. + indent(I), + "\n". diff --git a/gv_file.pl b/gv_file.pl index 5d2228e..45135f3 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -18,8 +18,6 @@ :- use_module(library(option)). :- use_module(library(process)). -:- use_module(plc(process/process_ext)). - :- dynamic(user:prolog_file_type/2). :- multifile(user:prolog_file_type/2). @@ -88,11 +86,10 @@ file_to_gv(InputFile, OutputFile, Options):- % Run the GraphViz conversion command in the shell. format(atom(OutputTypeFlag), '-T~a', [OutputType]), format(atom(OutputFileFlag), '-o~a', [OutputFile]), - atomic_list_concat(['GraphViz',Method], ' ', Program), - handle_process( - Method, + process_ext( + path(Method), [OutputTypeFlag,file(InputFile),OutputFileFlag], - [program(Program)] + [] ). diff --git a/gv_html.pl b/gv_html.pl index 65ae2bd..79d2564 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -56,7 +56,9 @@ cell: label %! gv_html_like_label(?Content:compound)// . gv_html_like_label(Content) --> - bracketed(angular, label(Content)). + "<", + label(Content), + ">". diff --git a/gv_util.pl b/gv_util.pl new file mode 100644 index 0000000..b2cbdcc --- /dev/null +++ b/gv_util.pl @@ -0,0 +1,260 @@ +:- module( + gv_util, + [ + ascii_alpha//1, % ?X:code + atom_phrase/2, % :Goal_1 + % +Atom:atom + atom_phrase/3, % :Goal_1 + % +Atom1:atom + % -Atom2:atom + file_age/2, % +File:atom + % -Age:float + html_download/2, % +Uri:atom + % -Dom:compound + indent//1, % +N:nonneg + persistent_db_attach/2, % +Module:atom + % +File:atom + underscore//1, % ?X:code + verbose_process/2 % +Process:atom + % :Goal_0 + ] +). + +/** GraphViz utilities + +Utilities that should not be specific to the GraphViz library +but that are considered too small to publish independently. + +@author Wouter Beek +@version 2015/07 +*/ + +:- use_module(library(ansi_term)). +:- use_module(library(http/http_open)). +:- use_module(library(http/http_ssl_plugin)). % HTTPS support. +:- use_module(library(lambda)). +:- use_module(library(option)). +:- use_module(library(process)). +:- use_module(library(sgml)). +:- use_module(library(xpath)). + +:- meta_predicate(atom_phrase(1,+)). +:- meta_predicate(atom_phrase(1,+,-)). +:- meta_predicate(dcg_call(//,?,?)). +:- meta_predicate(dcg_call(1,+,?,?)). +:- meta_predicate(http_get(+,1,+)). +:- meta_predicate(http_stream(+,1,+)). +:- meta_predicate(verbose_process(+,0)). + + + +%! ascii_alpha(?X:code)// . + +ascii_alpha(X) --> + between_code(65, 90, X) +ascii_alpha(X) --> + between_code(97, 122, X) + + + +%! ascii_alpha_numeric(?X:code)// . + +ascii_alpha_numeric(X) --> + ascii_alpha(X). +ascii_alpha_numeric(X) --> + ascii_numberic(X). + + + +%! ascii_numeric(?X:code)// . + +ascii_numeric(X) --> + between_code(48, 57, X). + + + +%! atom_phrase(:Goal_1, +Atom:atom) is det. + +atom_phrase(Goal_1, A):- + atom_codes(A, Cs), + phrase(Goal_1, Cs). + + + +%! atom_phrase(:Goal_1, +Atom1:atom, +Atom2:atom) is det. + +atom_phrase(Goal_1, A1, A2):- + atom_codes(A1, Cs1), + phrase(Goal_1, Cs1, Cs2), + atom_codes(A2, Cs2). + + + +%! between_code(+Low:code, +High:code, ?X:code)// . + +between_code(Low, High, X) --> + [X], + {between(Low, High, X)}. + + + +%! dcg_call(:Dcg_0)// is det. + +dcg_call(Dcg, X, Y):- + call(Dcg, X, Y). + +%! dcg_call(:Dcg_1, +Argument1)// is det. + +dcg_call(Dcg, A1, X, Y):- + call(Dcg, A1, X, Y). + + + +%! file_age(+File:atom, -Age:float) is det. + +file_age(File, Age):- + time_file(File, LastModified), + get_time(Now), + Age is Now - LastModified. + + + +%! html_download(+Uri:atom, -Dom:compound) is det. + +html_download(Uri, Dom):- + http_get( + Uri, + \Stream^load_html(Stream, Dom, [dialect(html5),max_errors(-1)]), + copy + [] + ). + + + +%! http_get(+Uri:atom, :Success_1, +Options:list(compound)) is det. + +http_get(Uri, Success_1, Opts0):- + merge_options([method(get),status_code(Status)], Opts0, Opts), + setup_call_cleanup( + http_open(Uri, Stream, Opts), + http_stream(Status, Success_1, Stream), + close(Stream) + ). + +%! http_stream(+Status:between(100,599), :Success_1, +Read:stream) is det. + +http_stream(Status, Success_1, Stream):- + between(200, 299, Status), !, + call(Success_1, Stream). +http_stream(Status, _, Stream):- + format(user_error, '[STATUS ~D] ', [Status]), + copy_stream_data(Stream, user_error), + format(user_error, '\n', []). + + + +%! html_table(+Dom:list(compound), -Header:list, -Data:list(list)) is det. + +html_table(Dom, Header, Data):- + ignore(html_table_row(header, Dom, Header)), + findall( + Data0, + html_table_row(data, Table, Data0), + Data + ). + +%! html_table_row( +%! +Mode:oneof([data,header]), +%! +Dom:list(compound), +%! -Data:list +%! ) is det. + +html_table_row(data, Dom, Row):- !, + xpath(Dom, //tr, Tr), + findall( + Cell, + xpath(Tr, //td(normalize_space), Cell), + Row + ), + Row \== []. +html_table_row(header, Dom, Row):- + xpath(Dom, //tr, Tr), + findall( + Cell, + xpath(Tr, //th(normalize_space), Cell), + Row + ), + Row \== []. + + + +%! indent(+N:nonneg)// is det. + +indent(0) --> !, "". +indent(N) --> + " ", + {succ(M, N)}, + indent(M). + + + +%! persistent_db_attach(+Module:atom, +File:atom) is det. +% Safe attachement of a persistent database dump. +% This first make sure the given file exists. + +persistent_db_attach(Mod, File):- + exists_file(File), !, + Mod:db_attach(File, []). +persistent_db_attach(Mod, File):- + touch_file(File), + persistent_db_attach(Mod, File). + +touch_file(File):- + create_process(path(touch), [file(File)], []). + + + +%! underscore(?C:code)// . + +underscore(95) --> + [95]. + + + +%! verbose_process(+Name:atom, :Goal_0) is det. + +verbose_process(Name, Goal_0):- + setup_call_catcher_cleanup( + start(Name), + Goal_0, + E, + ( E == true + -> success(Name) + ; failure(Name) + ) + ). + +failure(Name):- + warning('[FAILURE]'), + normal(' Process '), + normal(Name), + normal(':'), + nl, + normal(E). + +start(Name):- + normal('Starting process '), + normal(Name), + normal('.'). + +success(Name):- + success('[SUCCESS]'), + normal(' Ending process '), + normal(Name), + normal('.'). + +emphasis(X):- ansi_format([bold], '~a', [X]). +normal(X):- ansi_format([], '~a', [X]). +notification(X):- ansi_format([bold,fg(yellow)], '~a', [X]). +success(X):- ansi_format([bold,fg(green)], '~a', [X]). +warning(X):- ansi_format([bold,fg(red)], '~a', [X]). ```

99: 正在比较变动前 50a3dbc 和变动后 a97e8e1

[back to content](#compare) ``` diff diff --git a/Prolog-Library-Collection b/Prolog-Library-Collection deleted file mode 160000 index 88874a7..0000000 --- a/Prolog-Library-Collection +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 88874a7f451df36309d1d6ade03bc7186b4f6c8b diff --git a/debug.pl b/debug.pl deleted file mode 100644 index 12b4526..0000000 --- a/debug.pl +++ /dev/null @@ -1,7 +0,0 @@ -% Debug file for library plGraphViz. - -:- [load]. - -:- use_module(debug_project). -:- debug_all_files. - diff --git a/debug_project.pl b/debug_project.pl deleted file mode 100644 index d53a92f..0000000 --- a/debug_project.pl +++ /dev/null @@ -1,106 +0,0 @@ -:- module( - debug_project, - [ - debug_all_files/0, - start_pldoc_server/0 - ] -). - -/** Debug project - -Generic code for debugging a project: - * Load all subdirectories and Prolog files contained in those directories. - -@author Wouter Beek -@version 2015/02/26 -*/ - -:- use_module(library(ansi_term)). -:- use_module(library(apply)). -:- use_module(library(pldoc)). -:- use_module(library(portray_text)). - -:- set_prolog_flag( - answer_write_options, - [max_depth(100),portrayed(true),spacing(next_argument)] -). -:- set_prolog_flag( - debugger_write_options, - [max_depth(100),portrayed(true),spacing(next_argument)] -). -:- set_portray_text(ellipsis, 1000). - -:- dynamic(user:debug_mode). -:- multifile(user:debug_mode). - -:- initialization(init_debug_mode). - - - - - -debug_all_files:- - ensure_loaded(plc(io/dir_ext)), - absolute_file_name(project(.), Dir, [access(read),file_type(directory)]), - directory_files( - Dir, - Files1, - [ - file_types([prolog]), - include_directories(false), - include_self(false), - recursive(true) - ] - ), - exclude(do_not_load, Files1, Files2), - maplist(use_module0, Files2). -use_module0(File):- - print_message(informational, loading_module(File)), - use_module(File). - -do_not_load(File1):- - file_base_name(File1, File2), - file_name_extension(File3, pl, File2), - do_not_load0(File3). - -do_not_load0(dcg_ascii). -do_not_load0(dcg_unicode). -do_not_load0(debug). -do_not_load0(debug_project). -do_not_load0(index). -do_not_load0(load). -do_not_load0(load_project). -do_not_load0(run). -do_not_load0(style). - - - -%! start_pldoc_server is det. -% The plDoc server should be started *before* documented modules are loaded. - -start_pldoc_server:- - doc_server(9999). - - - - - -% INITIALIZATION - -init_debug_mode:- - % Set the debug mode flag. - ( user:debug_mode - -> true - ; assert(user:debug_mode) - ), - % Avoid errors when using gtrace/0 in threads. - guitracer. - - - -% MESSAGES - -:- multifile(prolog:message//1). - -prolog:message(loading_module(File)) --> - ['[M] ',File]. diff --git a/gv_attr_type.pl b/gv_attr_type.pl index b3e41ca..4e1b7f2 100644 --- a/gv_attr_type.pl +++ b/gv_attr_type.pl @@ -36,7 +36,7 @@ ] ). :- reexport( - plGraphViz(gv_color), + library(gv/gv_color), [ color//1, % +Color:compound colorList//1 % +ColorList:list(compound) @@ -46,12 +46,15 @@ /** GraphViz attribute types @author Wouter Beek -@version 2014/06, 2014/11-2015/01 +@version 2015/07 */ :- use_module(library(dcg/basics), except([string//1])). - -:- use_module(plGraphViz(gv_html)). +:- use_module(library(dcg/dcg_abnf)). +:- use_module(library(dcg/dcg_ascii)). +:- use_module(library(dcg/dcg_phrase)). +:- use_module(library(dcg/dcg_quoted)). +:- use_module(library(gv/gv_html)). @@ -194,9 +197,8 @@ double(N) --> %! doubleList(+Doubles:list(float))// . -doubleList([]) --> !, "". -doubleList([H]) --> !, double(H) -doubleList([H|T]) --> double(H), ":", doubleList(T). +doubleList(L) --> + '*'(double, L, [separator(colon)]). @@ -204,14 +206,8 @@ doubleList([H|T]) --> double(H), ":", doubleList(T). % @tbd Support for context-dependent replacements. escString(S1) --> - { - atom_codes(S1, Cs1), - phrase(escape_double_quotes, Cs1, Cs2), - atom_codes(S2, Cs2) - }, - "\"", - atom(S2), - "\"". + {atom_phrase(escape_double_quotes, S1, S2)}, + quoted(atom(S2)). escape_double_quotes, [92,34] --> [34], !, @@ -285,9 +281,7 @@ pagedir('TR'). % `point(X:float,Y:float,Changeable:boolean)`. point(point(X,Y,Changeable)) --> - float(X), - ",", - float(Y), + '#'(2, float, [X,Y], [separator(comma)]), input_changeable(Changeable). input_changeable(false) --> "". @@ -348,10 +342,12 @@ rankdir('TB'). %! rect(+Rectangle:compound)// . rect(rect(LowerLeftX,LowerLeftY,UpperRightX,UpperRightY)) --> - float(LowerLeftX), ",", - float(LowerLeftY), ",", - float(UpperRightX), ",", - float(UpperRightY). + '#'( + 4, + float, + [LowerLeftX,LowerLeftY,UpperRightX,UpperRightY], + [separator(comma)] + ). @@ -447,9 +443,7 @@ smoothType(triangle). % A GraphViz string. string(Content) --> - "\"", - atom(Content), - "\"". + quoted(atom(Content)). diff --git a/gv_attrs.pl b/gv_attrs.pl index 1e8ccdf..cce4f9d 100644 --- a/gv_attrs.pl +++ b/gv_attrs.pl @@ -13,13 +13,18 @@ */ :- use_module(library(apply)). +:- use_module(library(deb_ext)). :- use_module(library(dcg/basics)). +:- use_module(library(dcg/dcg_call)). +:- use_module(library(dcg/dcg_phrase)). +:- use_module(library(file_ext)). +:- use_module(library(http/html_download)). +:- use_module(library(http/html_table)). :- use_module(library(lists)). -:- use_module(library(persistency)). +:- use_module(library(persistency_ext)). :- use_module(library(xpath)). -:- use_module(plGraphViz(gv_attr_type), [gv_attr_type/1]). -:- use_module(plGraphViz(gv_util)). +:- use_module(library(gv/gv_attr_type), [gv_attr_type/1]). :- dynamic(user:prolog_file_type/2). :- multifile(user:prolog_file_type/2). @@ -144,7 +149,7 @@ gv_attrs_file(File):- gv_attrs_init:- gv_attrs_file(File), - persistent_db_attach(File), + attach_persistent_db(File), file_age(File, Age), gv_attrs_update(Age). diff --git a/gv_color.pl b/gv_color.pl index b8cf308..dd1690b 100644 --- a/gv_color.pl +++ b/gv_color.pl @@ -18,7 +18,7 @@ :- use_module(library(apply)). :- use_module(library(dcg/basics)). -:- use_module(library(lists), except([delete/3,subset/2])). +:- use_module(library(lists)). :- use_module(library(persistency)). :- use_module(library(xpath)). @@ -56,16 +56,12 @@ color(rgb(Red,Green,Blue)) --> !, "#", - hex_color(Red), - hex_color(Green), - hex_color(Blue). + '#'(3, hex_color, [Red,Green,Blue], []). color(rgbs(Red,Green,Blue,Alpha)) --> !, color(rgb(Red,Green,Blue)), hex_color(Alpha). color(hsv(Hue,Saturation,Value)) --> !, - hsv_color(Hue), - hsv_color(Saturation), - hsv_color(Value). + '#'(3, hsv_color, [Hue,Saturation,Value], []). color(Name) --> {gv_color(_, Name)}, atom(Name). @@ -80,11 +76,8 @@ hsv_color(D, Head, Tail):- %! colorList(+Pairs:list(pair(compound,float)))// . -colorList([H]) --> !, - wc(H). -colorList([H|T]) --> - wc(H), - colorList(T). +colorList(L) --> + '+'(wc, L, []). wc(Color-Float) --> color(Color), @@ -105,11 +98,11 @@ wc_weight(Float) --> %! gv_color_download is det. gv_color_download:- - report_on_process( + verbose_call( 'Updating the GraphViz color table...', ( gv_color_uri(Uri), - download_html_dom(Uri, Dom, [html_dialect(html4),silent(true)]), + html_download(Uri, Dom), xpath(Dom, //table(1), TableDom1), xpath(Dom, //table(2), TableDom2), maplist(assert_color_table, [x11,svg], [TableDom1,TableDom2]) @@ -117,7 +110,7 @@ gv_color_download:- ). assert_color_table(Colorscheme, TableDom):- - html_to_table(TableDom, _, Rows), + html_table(TableDom, _, Rows), append(Rows, Cells), forall( member(Cell, Cells), @@ -157,4 +150,3 @@ gv_color_update(_):- %! gv_color_uri(-Url:url) is det. gv_color_uri('http://www.graphviz.org/doc/info/colors.html'). - diff --git a/gv_dot.pl b/gv_dot.pl index c26d629..9c53cc5 100644 --- a/gv_dot.pl +++ b/gv_dot.pl @@ -1,7 +1,6 @@ :- module( gv_dot, [ - gv_graph//1 % +Graph:compound ] ). @@ -22,17 +21,19 @@ a_list = ID "=" ID [","] [a_list] @author Wouter Beek @see http://www.graphviz.org/content/dot-language -@version 2013/07, 2013/09, 2014/03-2014/06, 2014/11-2014/12 +@version 2015/07 */ :- use_module(library(apply)). :- use_module(library(dcg/basics)). -:- use_module(library(lists), except([delete/3,subset/2])). +:- use_module(library(dcg/dcg_ascii)). +:- use_module(library(dcg/dcg_bracketed)). +:- use_module(library(dcg/dcg_content)). +:- use_module(library(gv/gv_attrs)). +:- use_module(library(gv/gv_html)). +:- use_module(library(lists)). :- use_module(library(ordsets)). -:- use_module(plGraphViz(gv_attrs)). -:- use_module(plGraphViz(gv_html)). - @@ -44,14 +45,24 @@ a_list = ID "=" ID [","] [a_list] % A single GraphViz attribute. % We assume that the attribute has already been validated. -gv_attr(Context, Name=Value) --> - gv_id(Name), +gv_attr(Context, N=V) --> + gv_id(N), "=", - gv_attr_value(Context, Name=Value), + gv_attr_value(Context, N=V), ";". +%! gv_attrs( +%! +Kind:oneof([edge,graph,node]), +%! +Attributes:list(compound) +%! )// is det. + +gv_attrs(Kind, L) --> + bracketed(square, '*'(gv_attr, L, [])). + + + %! gv_compass_pt(+Direction:oneof(['_',c,e,n,ne,nw,s,se,sw,w]))// . % ``` % compass_pt : (n | ne | e | se | s | sw | w | nw | c | _) @@ -76,7 +87,7 @@ gv_compass_pt(w) --> "w". % undirected. % % @arg Directed Whether an edge is directed (operator `->`) or -% undirected (operator `--`). +% undirected (operator `--`). gv_edge_operator(false) --> !, "--". gv_edge_operator(true) --> "->". @@ -109,10 +120,8 @@ gv_edge_statement(I, Directed, edge(FromId,ToId,EAttrs)) --> % We want `colorscheme/1` from the edges and % `directionality/1` from the graph. - "[", gv_attrs(edge, EAttrs), - "]", - line_feed. + "\n". @@ -137,14 +146,8 @@ gv_generic_attributes_statement(_, _, []) --> [], !. gv_generic_attributes_statement(Kind, I, KindAttrs) --> indent(I), gv_kind(Kind), " ", - "[", gv_attrs(Kind, KindAttrs), - "]\n". - -gv_attrs(_, []) --> !, "". -gv_attrs(Kind, [H|T]) --> - gv_attr(Kind, H), - gv_attrs(Kind, T). + "\n". @@ -175,9 +178,7 @@ gv_id(html_like_label(Content)) --> !, % Double-quoted strings. % The quotes are already part of the given atom. gv_id(double_quoted_string(Atom)) --> !, - "\"", - atom(Atom), - "\"". + quoted(atom(Atom)). % Numerals. gv_id(N) --> {number(N)}, !, @@ -193,7 +194,7 @@ gv_id(Atom) --> {\+ gv_keyword([H|T])}. gv_id_first(X) --> - ascii_alpha(X). + ascii_letter(X). gv_id_first(X) --> underscore(X). @@ -257,7 +258,6 @@ gv_node_id(Id) --> gv_node_statement(I, vertex(Id,VAttrs)) --> indent(I), gv_node_id(Id), - " [", gv_attrs(node, VAttrs), "\n". @@ -293,9 +293,12 @@ gv_port_location --> -gv_ranked_node_collection(I, rank(Rank_V_Term,Content_V_Terms)) --> +gv_ranked_node_collection(I, Rank) --> indent(I), - "{\n", + bracketed(curly, gv_ranked_node_collection0(I, Rank)). + +gv_ranked_node_collection0(I, rank(Rank_V_Term,Content_V_Terms)) --> + "\n", % The rank attribute. {NewI is I + 1}, diff --git a/gv_file.pl b/gv_file.pl index 45135f3..da17737 100644 --- a/gv_file.pl +++ b/gv_file.pl @@ -29,6 +29,8 @@ user:prolog_file_type(pdf, pdf). + + %! gv_export( %! +ExportGraph:compound, %! +OutputFile:atom, diff --git a/gv_graph.pl b/gv_graph.pl index dd4af97..9ae7353 100644 --- a/gv_graph.pl +++ b/gv_graph.pl @@ -12,11 +12,15 @@ */ :- use_module(library(apply)). +:- use_module(library(dcg/dcg_abnf)). +:- use_module(library(dcg/dcg_content)). :- use_module(library(lists)). :- use_module(library(option)). + + %! gv_graph(+Graph:compound)// % The follow graph attributes are supported, % beyond the GraphViz attributes for graphs: @@ -145,20 +149,16 @@ gv_graph(G1, I) --> indent(I), "}\n". -gv_edge_statements(_, _, []) --> !, "". -gv_edge_statements(I, Dir, [H|T]) --> - gv_edge_statement(I, Dir, H), - gv_edge_statements(I, Dir, T). +gv_edge_statements(I, Dir, L) --> + '*'(gv_edge_statement(I, Dir), L, []). + +gv_node_statements(I, L) --> + '*'(gv_node_statement(I), L, []). + +gv_ranked_node_collections(I, L) --> + '*'(gv_ranked_node_collection(I), L, []). -gv_node_statements(_, []) --> !, "". -gv_node_statements(I, [H|T]) --> - gv_node_statement(I, H), - gv_node_statements(I, T). -gv_ranked_node_collections(_, []) --> !, "". -gv_ranked_node_collections(I, [H|T]) --> - gv_ranked_node_collection(I, H), - gv_ranked_node_collections(I, T), @@ -191,7 +191,7 @@ gv_graph_type(true) --> "digraph". % no multi-edges. % This only applies to directed graphs. -gv_strict(false) --> []. +gv_strict(false) --> "". gv_strict(true) --> "strict ". diff --git a/gv_html.pl b/gv_html.pl index 79d2564..ced6d6b 100644 --- a/gv_html.pl +++ b/gv_html.pl @@ -40,14 +40,13 @@ cell: label @author Wouter Beek @see http://www.graphviz.org/content/node-shapes#html -@version 2013/07, 2013/09, 2014/03-2014/06, 2014/11 +@version 2015/07 */ -:- use_module(plc(dcg/dcg_abnf)). -:- use_module(plc(dcg/dcg_bracket)). -:- use_module(plc(dcg/dcg_content)). - -:- use_module(plHtml(html_dcg)). +:- use_module(library(dcg/dcg_abnf)). +:- use_module(library(dcg/dcg_bracket)). +:- use_module(library(dcg/dcg_content)). +:- use_module(library(http/html_dcg)). @@ -56,9 +55,7 @@ cell: label %! gv_html_like_label(?Content:compound)// . gv_html_like_label(Content) --> - "<", - label(Content), - ">". + bracketed(angular, label(Content)). @@ -262,7 +259,7 @@ textitem(String) --> -% HELPERS +% HELPERS % %! supported_html_element(+Name:atom) is semidet. %! supported_html_element(-Name:atom) is multi. diff --git a/gv_numeral.pl b/gv_numeral.pl index bff1255..1e5c723 100644 --- a/gv_numeral.pl +++ b/gv_numeral.pl @@ -11,14 +11,14 @@ @version 2014/05-2014/06, 2015/01 */ -:- use_module(plc(dcg/dcg_abnf)). -:- use_module(plc(dcg/dcg_abnf_common)). -:- use_module(plc(dcg/dcg_ascii)). -:- use_module(plc(dcg/dcg_cardinal)). -:- use_module(plc(math/math_ext)). -:- use_module(plc(math/positional)). -:- use_module(plc(math/radix)). -:- use_module(plc(math/rational_ext)). +:- use_module(library(dcg/dcg_abnf)). +:- use_module(library(dcg/dcg_abnf_common)). +:- use_module(library(dcg/dcg_ascii)). +:- use_module(library(dcg/dcg_cardinal)). +:- use_module(library(math/math_ext)). +:- use_module(library(math/positional)). +:- use_module(library(math/radconv)). +:- use_module(library(math/rational_ext)). @@ -63,14 +63,14 @@ gv_numeral(N) --> % preceded by the decimal separator. {I =:= 0} -> ".", - {weights_fraction(FW, F)}, + {positional_fraction(FW, F)}, '[0-9]*'(FW) ; % [3] Both the integer part and the fractional are non-zero, % so write both of them, with the decimal separator in-between. {positional(I, IW)}, '[0-9]+'(IW), ".", - {weights_fraction(FW, F)}, + {positional_fraction(FW, F)}, '[0-9]*'(FW) ) ; '[-]?'(Sg), diff --git a/gv_util.pl b/gv_util.pl deleted file mode 100644 index b2cbdcc..0000000 --- a/gv_util.pl +++ /dev/null @@ -1,260 +0,0 @@ -:- module( - gv_util, - [ - ascii_alpha//1, % ?X:code - atom_phrase/2, % :Goal_1 - % +Atom:atom - atom_phrase/3, % :Goal_1 - % +Atom1:atom - % -Atom2:atom - file_age/2, % +File:atom - % -Age:float - html_download/2, % +Uri:atom - % -Dom:compound - indent//1, % +N:nonneg - persistent_db_attach/2, % +Module:atom - % +File:atom - underscore//1, % ?X:code - verbose_process/2 % +Process:atom - % :Goal_0 - ] -). - -/** GraphViz utilities - -Utilities that should not be specific to the GraphViz library -but that are considered too small to publish independently. - -@author Wouter Beek -@version 2015/07 -*/ - -:- use_module(library(ansi_term)). -:- use_module(library(http/http_open)). -:- use_module(library(http/http_ssl_plugin)). % HTTPS support. -:- use_module(library(lambda)). -:- use_module(library(option)). -:- use_module(library(process)). -:- use_module(library(sgml)). -:- use_module(library(xpath)). - -:- meta_predicate(atom_phrase(1,+)). -:- meta_predicate(atom_phrase(1,+,-)). -:- meta_predicate(dcg_call(//,?,?)). -:- meta_predicate(dcg_call(1,+,?,?)). -:- meta_predicate(http_get(+,1,+)). -:- meta_predicate(http_stream(+,1,+)). -:- meta_predicate(verbose_process(+,0)). - - - -%! ascii_alpha(?X:code)// . - -ascii_alpha(X) --> - between_code(65, 90, X) -ascii_alpha(X) --> - between_code(97, 122, X) - - - -%! ascii_alpha_numeric(?X:code)// . - -ascii_alpha_numeric(X) --> - ascii_alpha(X). -ascii_alpha_numeric(X) --> - ascii_numberic(X). - - - -%! ascii_numeric(?X:code)// . - -ascii_numeric(X) --> - between_code(48, 57, X). - - - -%! atom_phrase(:Goal_1, +Atom:atom) is det. - -atom_phrase(Goal_1, A):- - atom_codes(A, Cs), - phrase(Goal_1, Cs). - - - -%! atom_phrase(:Goal_1, +Atom1:atom, +Atom2:atom) is det. - -atom_phrase(Goal_1, A1, A2):- - atom_codes(A1, Cs1), - phrase(Goal_1, Cs1, Cs2), - atom_codes(A2, Cs2). - - - -%! between_code(+Low:code, +High:code, ?X:code)// . - -between_code(Low, High, X) --> - [X], - {between(Low, High, X)}. - - - -%! dcg_call(:Dcg_0)// is det. - -dcg_call(Dcg, X, Y):- - call(Dcg, X, Y). - -%! dcg_call(:Dcg_1, +Argument1)// is det. - -dcg_call(Dcg, A1, X, Y):- - call(Dcg, A1, X, Y). - - - -%! file_age(+File:atom, -Age:float) is det. - -file_age(File, Age):- - time_file(File, LastModified), - get_time(Now), - Age is Now - LastModified. - - - -%! html_download(+Uri:atom, -Dom:compound) is det. - -html_download(Uri, Dom):- - http_get( - Uri, - \Stream^load_html(Stream, Dom, [dialect(html5),max_errors(-1)]), - copy - [] - ). - - - -%! http_get(+Uri:atom, :Success_1, +Options:list(compound)) is det. - -http_get(Uri, Success_1, Opts0):- - merge_options([method(get),status_code(Status)], Opts0, Opts), - setup_call_cleanup( - http_open(Uri, Stream, Opts), - http_stream(Status, Success_1, Stream), - close(Stream) - ). - -%! http_stream(+Status:between(100,599), :Success_1, +Read:stream) is det. - -http_stream(Status, Success_1, Stream):- - between(200, 299, Status), !, - call(Success_1, Stream). -http_stream(Status, _, Stream):- - format(user_error, '[STATUS ~D] ', [Status]), - copy_stream_data(Stream, user_error), - format(user_error, '\n', []). - - - -%! html_table(+Dom:list(compound), -Header:list, -Data:list(list)) is det. - -html_table(Dom, Header, Data):- - ignore(html_table_row(header, Dom, Header)), - findall( - Data0, - html_table_row(data, Table, Data0), - Data - ). - -%! html_table_row( -%! +Mode:oneof([data,header]), -%! +Dom:list(compound), -%! -Data:list -%! ) is det. - -html_table_row(data, Dom, Row):- !, - xpath(Dom, //tr, Tr), - findall( - Cell, - xpath(Tr, //td(normalize_space), Cell), - Row - ), - Row \== []. -html_table_row(header, Dom, Row):- - xpath(Dom, //tr, Tr), - findall( - Cell, - xpath(Tr, //th(normalize_space), Cell), - Row - ), - Row \== []. - - - -%! indent(+N:nonneg)// is det. - -indent(0) --> !, "". -indent(N) --> - " ", - {succ(M, N)}, - indent(M). - - - -%! persistent_db_attach(+Module:atom, +File:atom) is det. -% Safe attachement of a persistent database dump. -% This first make sure the given file exists. - -persistent_db_attach(Mod, File):- - exists_file(File), !, - Mod:db_attach(File, []). -persistent_db_attach(Mod, File):- - touch_file(File), - persistent_db_attach(Mod, File). - -touch_file(File):- - create_process(path(touch), [file(File)], []). - - - -%! underscore(?C:code)// . - -underscore(95) --> - [95]. - - - -%! verbose_process(+Name:atom, :Goal_0) is det. - -verbose_process(Name, Goal_0):- - setup_call_catcher_cleanup( - start(Name), - Goal_0, - E, - ( E == true - -> success(Name) - ; failure(Name) - ) - ). - -failure(Name):- - warning('[FAILURE]'), - normal(' Process '), - normal(Name), - normal(':'), - nl, - normal(E). - -start(Name):- - normal('Starting process '), - normal(Name), - normal('.'). - -success(Name):- - success('[SUCCESS]'), - normal(' Ending process '), - normal(Name), - normal('.'). - -emphasis(X):- ansi_format([bold], '~a', [X]). -normal(X):- ansi_format([], '~a', [X]). -notification(X):- ansi_format([bold,fg(yellow)], '~a', [X]). -success(X):- ansi_format([bold,fg(green)], '~a', [X]). -warning(X):- ansi_format([bold,fg(red)], '~a', [X]). diff --git a/load.pl b/load.pl deleted file mode 100644 index de8b5ca..0000000 --- a/load.pl +++ /dev/null @@ -1,13 +0,0 @@ -% Load file for the plGraphViz library. - -:- dynamic(user:project/2). -:- multifile(user:project/2). - user:project(plGraphViz, 'GraphViz support for SWI-Prolog.'). - -:- use_module(load_project). -:- load_project([ - plc-'Prolog-Library-Collection', - plHtml, - plUri -]). - diff --git a/load_project.pl b/load_project.pl deleted file mode 100644 index 3f0ebef..0000000 --- a/load_project.pl +++ /dev/null @@ -1,125 +0,0 @@ -:- module( - load_project, - [ - load_project/1, % +ChildProjects:list(or([atom,pair(atom)])) - load_subproject/2, % +ParentFileSearchPath:atom - % +Child:or([atom,pair(atom)]) - set_data_subdirectory/1 % +ParentDirectory:atom - ] -). - -/** Load project - -Generic code for loading a project: - * Create a subdirectory for data. - * Load the root of subprojects onto the file search path. - * Load the index of subprojects onto the file search path. - -@author Wouter Beek -@version 2014/11/10 -*/ - -:- use_module(library(ansi_term)). % Colorized terminal messages. -:- use_module(library(apply)). -:- use_module(library(pldoc)). - -:- dynamic(user:project/2). -:- multifile(user:project/2). -:- dynamic(user:project/3). -:- multifile(user:project/3). - - - -load_project(ChildProjects):- - doc_server(9999), - - parent_alias(ParentFsp), - - % Entry point. - source_file(load_project(_), ThisFile), - file_directory_name(ThisFile, ThisDir), - assert(user:file_search_path(ParentFsp, ThisDir)), - assert(user:file_search_path(project, ThisDir)), - - % Set the data subdirectory. - set_data_subdirectory(ThisDir), - - % Load the root of submodules onto the file search path. - maplist(load_subproject(ParentFsp), ChildProjects), - - % Load the index into the file search path. - load_project_index(ParentFsp). - - - -%! load_subproject( -%! +ParentFileSearchPath:atom, -%! +Child:or([atom,pair(atom)]) -%! ) is det. - -load_subproject(ParentFsp, ChildFsp-ChildDir):- !, - load_subproject_file_search_path(ParentFsp, ChildFsp, ChildDir), - load_project_index(ChildFsp). -load_subproject(ParentFsp, Child):- - load_subproject(ParentFsp, Child-Child). - - -%! load_subproject_file_search_path( -%! +ParentFileSearchPath:atom, -%! +ChildFileSearchPath:atom, -%! +ChildDirectory:atom -%! ) is det. - -% The file search path for the subproject has already been set. -load_subproject_file_search_path(_, ChildFsp, _):- - user:file_search_path(ChildFsp, _). -load_subproject_file_search_path(ParentFsp, ChildFsp, ChildDir):- - Spec =.. [ParentFsp,ChildDir], - absolute_file_name(Spec, _, [access(read),file_type(directory)]), !, - assert(user:file_search_path(ChildFsp, Spec)). -load_subproject_file_search_path(_, ChildFsp, ChildDir):- - print_message(warning, missing_subproject_directory(ChildFsp,ChildDir)). - - -%! load_project_index(+FileSearchPath:atom) is det. - -load_project_index(Fsp):- - Spec =.. [Fsp,index], - absolute_file_name( - Spec, - File, - [access(read),file_errors(fail),file_type(prolog)] - ), !, - ensure_loaded(File). -load_project_index(_). - - -%! parent_alias(-ParentFsp:atom) is det. - -parent_alias(ParentFsp):- - user:project(_, _, ParentFsp), !. -parent_alias(ParentFsp):- - user:project(ParentFsp, _). - - -%! set_data_subdirectory(+ParentDirectory:atom) is det. - -set_data_subdirectory(ParentDir):- - directory_file_path(ParentDir, data, DataDir), - make_directory_path(DataDir), - assert(user:file_search_path(data, DataDir)). - - - -% Messages - -:- multifile(prolog:message//1). - -prolog:message(missing_subproject_directory(ChildFsp,ChildDir)) --> - [ - 'The ~a submodule is not present.'-[ChildFsp], nl, - 'Check whether subdirectory ~a is present in your project directory:'-[ChildDir], nl, - ' git submodule init', nl, - ' git submodule update' - ]. - diff --git a/plHtml b/plHtml deleted file mode 160000 index 2919705..0000000 --- a/plHtml +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2919705d079b1ab28bf3c502a87d1648fd842ed3 diff --git a/plUri b/plUri deleted file mode 160000 index 1a55127..0000000 --- a/plUri +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1a55127517ee0b0cf2ad4fecbe3f84402f5f4c12 diff --git a/run.pl b/run.pl deleted file mode 100644 index 8c751f4..0000000 --- a/run.pl +++ /dev/null @@ -1,11 +0,0 @@ -% Standalone execution of the plGraphViz library. - -:- if(current_prolog_flag(argv, ['--debug'|_])). - :- ensure_loaded(debug). -:- else. - :- set_prolog_flag(verbose, silent). - :- ensure_loaded(load). -:- endif. - -:- use_module(plGraphViz(gv_file)). - ```

100: 正在比较变动前 a97e8e1 和变动后 9513a9b

[back to content](#compare) ``` diff diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..c7b7798 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Wouter Beek + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/pack.pl b/pack.pl new file mode 100644 index 0000000..f0f5b22 --- /dev/null +++ b/pack.pl @@ -0,0 +1,9 @@ +author('Wouter Beek', 'me@wouterbeek.com'). +download('https://github.com/wouterbeek/plGraphViz/release/*.zip'). +home('https://github.com/wouterbeek/plGraphViz'). +maintainer('Wouter Beek', 'me@wouterbeek.com'). +name(plGraphViz). +packager('Wouter Beek', 'me@wouterbeek.com'). +requires('Prolog_Library_Collection'). +title(plGraphViz). +version('0.0.1'). diff --git a/gv_attr_type.pl b/prolog/gv/gv_attr_type.pl similarity index 86% rename from gv_attr_type.pl rename to prolog/gv/gv_attr_type.pl index 4e1b7f2..ff163fe 100644 --- a/gv_attr_type.pl +++ b/prolog/gv/gv_attr_type.pl @@ -1,7 +1,7 @@ :- module( gv_attr_type, [ - gv_attr_type/1, % ?Type:atom + gv_attr_type//1, % ?Type:atom addDouble//1, % +Double:float addPoint//1, % +Point:compound arrowType//1, % +ArrowType:atom @@ -62,38 +62,38 @@ %! gv_attr_type(?Type:atom) is nondet. -gv_attr_type(addDouble). -gv_attr_type(addPoint). -gv_attr_type(arrowType). -gv_attr_type(bool). -gv_attr_type(color). -gv_attr_type(colorList). -gv_attr_type(clusterMode). -gv_attr_type(dirType). -gv_attr_type(double). -gv_attr_type(doubleList). -gv_attr_type(escString). -gv_attr_type(layerList). -gv_attr_type(layerRange). -gv_attr_type(lblString). -gv_attr_type(int). -gv_attr_type(outputMode). -gv_attr_type(packMode). -gv_attr_type(pagedir). -gv_attr_type(point). -gv_attr_type(pointList). -gv_attr_type(portPos). -gv_attr_type(quadType). -gv_attr_type(rankType). -gv_attr_type(rankdir). -gv_attr_type(rect). -gv_attr_type(shape). -gv_attr_type(smoothType). -gv_attr_type(splineType). -gv_attr_type(startType). -gv_attr_type(string). -gv_attr_type(style). -gv_attr_type(viewPort). +gv_attr_type(addDouble) --> "addDouble". +gv_attr_type(addPoint) --> "addPoint". +gv_attr_type(arrowType) --> "arrowType". +gv_attr_type(bool) --> "bool". +gv_attr_type(color) --> "color". +gv_attr_type(colorList) --> "colorList". +gv_attr_type(clusterMode) --> "clusterMode". +gv_attr_type(dirType) --> "dirType". +gv_attr_type(double) --> "double". +gv_attr_type(doubleList) --> "doubleList". +gv_attr_type(escString) --> "escString". +gv_attr_type(layerList) --> "layerList". +gv_attr_type(layerRange) --> "layerRange". +gv_attr_type(lblString) --> "lblString". +gv_attr_type(int) --> "int". +gv_attr_type(outputMode) --> "outputMode". +gv_attr_type(packMode) --> "packMode". +gv_attr_type(pagedir) --> "pagedir". +gv_attr_type(point) --> "point". +gv_attr_type(pointList) --> "pointList". +gv_attr_type(portPos) --> "portPos". +gv_attr_type(quadType) --> "quadType". +gv_attr_type(rankType) --> "rankType". +gv_attr_type(rankdir) --> "rankdir". +gv_attr_type(rect) --> "rect". +gv_attr_type(shape) --> "shape". +gv_attr_type(smoothType) --> "smoothType". +gv_attr_type(splineType) --> "splineType". +gv_attr_type(startType) --> "startType". +gv_attr_type(string) --> "string". +gv_attr_type(style) --> "style". +gv_attr_type(viewPort) --> "viewPort". diff --git a/gv_attrs.pl b/prolog/gv/gv_attrs.pl similarity index 86% rename from gv_attrs.pl rename to prolog/gv/gv_attrs.pl index cce4f9d..d773a8b 100644 --- a/gv_attrs.pl +++ b/prolog/gv/gv_attrs.pl @@ -24,12 +24,7 @@ :- use_module(library(persistency_ext)). :- use_module(library(xpath)). -:- use_module(library(gv/gv_attr_type), [gv_attr_type/1]). - -:- dynamic(user:prolog_file_type/2). -:- multifile(user:prolog_file_type/2). - -user:prolog_file_type(log, logging). +:- use_module(library(gv/gv_attr_type), [gv_attr_type//1]). %! gv_attr( %! ?Name:atom, @@ -127,32 +122,30 @@ assert_gv_attr_row([Name,UsedBy1,Types1,Default1,Minimum,Notes]):- % Downloads the table describing GraphViz attributes from `graphviz.org`. gv_attrs_download:- - verbose_process( - 'Updating GraphViz attributes table... ', - ( - gv_attrs_uri(Uri), - html_download(Uri, Dom), - xpath(Dom, //table(@align=lower_case(center)), TableDom), - html_table(TableDom, _, Rows), - maplist(assert_gv_attr_row, Rows) - ) + verbose_call( + 'updating GraphViz attributes table', + gv_attrs_download0 ). +gv_attrs_download0:- + gv_attrs_uri(Uri), + html_download(Uri, Dom), + xpath_chk(Dom, //table(@align=lower_case(center)), TableDom), + html_table(TableDom, _, Rows), + maplist(assert_gv_attr_row, Rows). + %! gv_attrs_file(-File:atom) is det. gv_attrs_file(File):- - absolute_file_name(gv_attrs, File, [access(write),file_type(logging)]). + absolute_file_name('gv_attrs.log', File, [access(write)]). %! gv_attrs_init is det. gv_attrs_init:- gv_attrs_file(File), - attach_persistent_db(File), - file_age(File, Age), - gv_attrs_update(Age). - + init_persistent_db(File, gv_attrs_update). %! gv_attrs_update(+Age:float) is det. @@ -186,12 +179,13 @@ translate_default(Default, Default). %! translate_type(-Types:list(atom))// is det. -translate_type([]) --> !, []. translate_type([H|T]) --> - {gv_attr_type(H)}, - atom(H), + gv_attr_type(H), whites, translate_type(T). +translate_type([H]) --> + gv_attr_type(H). +translate_type([]) --> "". diff --git a/gv_color.pl b/prolog/gv/gv_color.pl similarity index 78% rename from gv_color.pl rename to prolog/gv/gv_color.pl index dd1690b..0553aa2 100644 --- a/gv_color.pl +++ b/prolog/gv/gv_color.pl @@ -17,27 +17,17 @@ */ :- use_module(library(apply)). +:- use_module(library(deb_ext)). :- use_module(library(dcg/basics)). +:- use_module(library(dcg/dcg_abnf)). +:- use_module(library(dcg/dcg_content)). +:- use_module(library(file_ext)). +:- use_module(library(http/html_download)). +:- use_module(library(http/html_table)). :- use_module(library(lists)). -:- use_module(library(persistency)). +:- use_module(library(persistency_ext)). :- use_module(library(xpath)). -:- use_module(plc(dcg/dcg_abnf)). -:- use_module(plc(dcg/dcg_abnf_rules)). -:- use_module(plc(dcg/dcg_atom)). -:- use_module(plc(dcg/dcg_cardinal)). -:- use_module(plc(dcg/dcg_content)). -:- use_module(plc(generics/db_ext)). -:- use_module(plc(generics/persistent_db_ext)). -:- use_module(plc(generics/print_ext)). -:- use_module(plc(io/file_ext)). -:- use_module(plc(io/file_gnu)). - -:- use_module(plHtml(html)). -:- use_module(plHtml(html_table)). - -:- db_add_novel(user:prolog_file_type(log, logging)). - %! gv_color(?Colorscheme:oneof([svg,x11]), ?Color:atom) is nondet. :- persistent(gv_color(colorscheme:oneof([svg,x11]),color:atom)). @@ -99,7 +89,7 @@ wc_weight(Float) --> gv_color_download:- verbose_call( - 'Updating the GraphViz color table...', + 'updating the GraphViz color table', ( gv_color_uri(Uri), html_download(Uri, Dom), @@ -121,18 +111,14 @@ assert_color_table(Colorscheme, TableDom):- %! gv_color_file(-File:atom) is det. gv_color_file(File):- - absolute_file_name( - data(gv_color), - File, - [access(write),file_type(logging)] - ). + absolute_file_name('gv_color.log', File, [access(write)]). %! gv_color_init is det. gv_color_init:- gv_color_file(File), - persistent_db_init(File, gv_color_update). + init_persistent_db(File, gv_color_update). %! gv_color_update(+Age:float) is det. diff --git a/gv_file.pl b/prolog/gv/gv_file.pl similarity index 96% rename from gv_file.pl rename to prolog/gv/gv_file.pl index da17737..a175071 100644 --- a/gv_file.pl +++ b/prolog/gv/gv_file.pl @@ -13,8 +13,9 @@ @version 2015/07 */ +:- use_module(library(code_ext)). :- use_module(library(error)). -:- use_module(library(gv/gv_dot)). +:- use_module(library(gv/gv_graph)). :- use_module(library(option)). :- use_module(library(process)). @@ -55,7 +56,7 @@ gv_export(ExportGraph, OutputFile, Options):- absolute_file_name(data(ThreadName), TmpFile, [access(write),file_type(dot)]), setup_call_cleanup( open(TmpFile, write, Write, [encoding(utf8)]), - put_codes(Write, Codes), + with_output_to(Write, put_codes(Codes)), close(Write) ), file_to_gv(TmpFile, OutputFile, Options). @@ -88,7 +89,7 @@ file_to_gv(InputFile, OutputFile, Options):- % Run the GraphViz conversion command in the shell. format(atom(OutputTypeFlag), '-T~a', [OutputType]), format(atom(OutputFileFlag), '-o~a', [OutputFile]), - process_ext( + process_create( path(Method), [OutputTypeFlag,file(InputFile),OutputFileFlag], [] diff --git a/gv_graph.pl b/prolog/gv/gv_graph.pl similarity index 93% rename from gv_graph.pl rename to prolog/gv/gv_graph.pl index 9ae7353..6bd4b86 100644 --- a/gv_graph.pl +++ b/prolog/gv/gv_graph.pl @@ -7,6 +7,13 @@ /** GraphViz graph +Generates GraphViz graphs in the DOT format based on +a Prolog representation of a graph. + +In GraphViz vertices are called 'nodes'. + +--- + @author Wouter Beek @version 2015/07 */ @@ -14,6 +21,7 @@ :- use_module(library(apply)). :- use_module(library(dcg/dcg_abnf)). :- use_module(library(dcg/dcg_content)). +:- use_module(library(gv/gv_graph_comp)). :- use_module(library(lists)). :- use_module(library(option)). @@ -79,8 +87,9 @@ gv_graph(G1, I) --> gv_graph_type(Directed), " ", % Graph name. - ( {select_name(GName), GAttrs4, GAttrs5)} - -> gv_id(GName), " ", + ( {select_option(name(GName), GAttrs4, GAttrs5)} + -> gv_id(GName), + " " ; {GAttrs5 = GAttrs4} ), @@ -102,7 +111,7 @@ gv_graph(G1, I) --> % Only add a line_feed if some content was already written % and some content is about to be written. ( % Succeeds if no content was written. - {(GAttrs == [], SharedVAttrs == [], SharedEAttrs == [])} + {(GAttrs5 == [], SharedVAttrs == [], SharedEAttrs == [])} -> "" ; % Succeeds if no content is about to be written. {(NewVTerms == [], RankedVTerms == [])} @@ -171,8 +180,8 @@ gv_ranked_node_collections(I, L) --> %! ) is det. add_default(L1, Opt, L2):- - Opt =.. [N,V], - Opt0 =.. [N,_], + Opt =.. [N,_Value], + Opt0 =.. [N,_FreshVar], ( option(Opt0, L1) -> true ; L2 = [Opt|L1] diff --git a/gv_dot.pl b/prolog/gv/gv_graph_comp.pl similarity index 79% rename from gv_dot.pl rename to prolog/gv/gv_graph_comp.pl index 9c53cc5..8a7d28a 100644 --- a/gv_dot.pl +++ b/prolog/gv/gv_graph_comp.pl @@ -1,16 +1,21 @@ :- module( - gv_dot, + gv_graph_comp, [ + gv_edge_statement//3, % +Indent:nonneg + % +Directed:boolean + % +Edge:compound + gv_generic_attributes_statement//3, % +Kind:oneof([edge,graph,node]) + % +Indent:nonneg + % +CategoryAttributes:list(compound) + gv_id//1, % +Name:compound + gv_node_statement//2, % +Indent:nonneg + % +Vertex:compound + gv_ranked_node_collection//2 % +Indent:nonneg + % +Rank:??? ] ). -/** GraphViz DOT generator - -DCG rules for GraphViz DOT file generation. - -Methods for writing to the GraphViz DOT format. - -In GraphViz vertices are called 'nodes'. +/** GraphViz graph components ```abnf attr_list = "[" [a_list] "]" [attr_list] @@ -26,9 +31,11 @@ a_list = ID "=" ID [","] [a_list] :- use_module(library(apply)). :- use_module(library(dcg/basics)). +:- use_module(library(dcg/dcg_abnf)). :- use_module(library(dcg/dcg_ascii)). :- use_module(library(dcg/dcg_bracketed)). :- use_module(library(dcg/dcg_content)). +:- use_module(library(dcg/dcg_quoted)). :- use_module(library(gv/gv_attrs)). :- use_module(library(gv/gv_html)). :- use_module(library(lists)). @@ -38,66 +45,10 @@ a_list = ID "=" ID [","] [a_list] -%! gv_attr( -%! +Context:oneof([edge,graph,node]), -%! +Attribute:nvpair -%! )// is det. -% A single GraphViz attribute. -% We assume that the attribute has already been validated. - -gv_attr(Context, N=V) --> - gv_id(N), - "=", - gv_attr_value(Context, N=V), - ";". - - - -%! gv_attrs( -%! +Kind:oneof([edge,graph,node]), -%! +Attributes:list(compound) -%! )// is det. - -gv_attrs(Kind, L) --> - bracketed(square, '*'(gv_attr, L, [])). - - - -%! gv_compass_pt(+Direction:oneof(['_',c,e,n,ne,nw,s,se,sw,w]))// . -% ``` -% compass_pt : (n | ne | e | se | s | sw | w | nw | c | _) -% ``` - -gv_compass_pt('_') --> "_". -gv_compass_pt(c) --> "c". -gv_compass_pt(e) --> "e". -gv_compass_pt(n) --> "n". -gv_compass_pt(ne) --> "ne". -gv_compass_pt(nw) --> "nw". -gv_compass_pt(s) --> "s". -gv_compass_pt(se) --> "se". -gv_compass_pt(sw) --> "sw". -gv_compass_pt(w) --> "w". - - - -%! gv_edge_operator(+Directed:boolean)// . -% The binary edge operator between two vertices. -% The operator that is used depends on whether the graph is directed or -% undirected. -% -% @arg Directed Whether an edge is directed (operator `->`) or -% undirected (operator `--`). - -gv_edge_operator(false) --> !, "--". -gv_edge_operator(true) --> "->". - - - %! gv_edge_statement( %! +Indent:nonneg, %! +Directed:boolean, -%! +EdgeTerm:compound +%! +Edge:compound %! )// is det. % A GraphViz statement describing an edge. % @@ -105,29 +56,40 @@ gv_edge_operator(true) --> "->". % @arg Directed Whether the graph is directed or not. % @arg GraphAttributes The attributes of the graph. Some of these attributes % may be used in the edge statement (e.g., the colorscheme). -% @arg EdgeTerm A compound term in the GIFormat, representing an edge. +% @arg Edge A compound term in the GIFormat, representing an edge. % % @tbd Instead of gv_node_id//1 we could have a gv_subgraph//1 % at the from and/or to location. % @tbd Add support for multiple, consecutive occurrences of gv_edge_rhs//2. -gv_edge_statement(I, Directed, edge(FromId,ToId,EAttrs)) --> +gv_edge_statement(I, Dir, edge(From,To,Attrs)) --> indent(I), - gv_node_id(FromId), " ", - gv_edge_operator(Directed), " ", - gv_node_id(ToId), " ", + gv_node_id(From), " ", + gv_edge_operator(Dir), " ", + gv_node_id(To), " ", % We want `colorscheme/1` from the edges and % `directionality/1` from the graph. - gv_attrs(edge, EAttrs), + gv_attrs(edge, Attrs), "\n". +%! gv_edge_operator(+Directed:boolean)// . +% The binary edge operator between two vertices. +% The operator that is used depends on whether the graph is directed or +% undirected. +% +% @arg Directed Whether an edge is directed (operator `->`) or +% undirected (operator `--`). + +gv_edge_operator(false) --> !, "--". +gv_edge_operator(true) --> "->". + %! gv_generic_attributes_statement( %! +Kind:oneof([edge,graph,node]), -%! +Indent:integer, +%! +Indent:nonneg, %! +CategoryAttributes:list(nvpair) %! )// % A GraphViz statement describing generic attributes for a category of items. @@ -142,16 +104,88 @@ gv_edge_statement(I, Directed, edge(FromId,ToId,EAttrs)) --> % attr_stmt = (graph / node / edge) attr_list % ``` -gv_generic_attributes_statement(_, _, []) --> [], !. -gv_generic_attributes_statement(Kind, I, KindAttrs) --> +gv_generic_attributes_statement(_, _, []) --> !, "". +gv_generic_attributes_statement(Kind, I, Attrs) --> indent(I), gv_kind(Kind), " ", - gv_attrs(Kind, KindAttrs), + gv_attrs(Kind, Attrs), + "\n". + +%! gv_kind(+Kind:oneof([edge,graph,node]))// . + +gv_kind(edge) --> "edge". +gv_kind(graph) --> "graph". +gv_kind(node) --> "node". + + + +%! gv_node_statement(+Indent:nonneg, +Vertex:compound)// is det. +% A GraphViz statement describing a vertex (GraphViz calls vertices 'nodes'). + +gv_node_statement(I, vertex(Id,Attrs)) --> + indent(I), + gv_node_id(Id), + gv_attrs(node, Attrs), + "\n". + + + +%! gv_ranked_node_collection(+Indent:nonneg, Rank:???)// is det. + +gv_ranked_node_collection(I, Rank) --> + indent(I), + bracketed(curly, gv_ranked_node_collection0(I, Rank)). + +gv_ranked_node_collection0(I, rank(Rank_V_Term,Content_V_Terms)) --> + "\n", + + % The rank attribute. + {NewI is I + 1}, + indent(NewI), + gv_attr(subgraph, rank=same), + ";\n", + + % Vertice statements. + '*'( + gv_node_statement(NewI), + [Rank_V_Term|Content_V_Terms], + [] + ), + + % We want to indent the closing curly brace. + indent(I), "\n". -%! gv_id(?Atom:compound)// is det. + + +% HELPERS % + +%! gv_attrs( +%! +Kind:oneof([edge,graph,node]), +%! +Attributes:list(compound) +%! )// is det. + +gv_attrs(Kind, L) --> + bracketed(square, '*'(gv_attr(Kind), L, [])). + +%! gv_attr( +%! +Context:oneof([edge,graph,node]), +%! +Attribute:nvpair +%! )// is det. +% A single GraphViz attribute. +% We assume that the attribute has already been validated. + +gv_attr(Context, N=V) --> + gv_id(N), + "=", + gv_attr_value(Context, N=V), + ";". + + + +%! gv_id(+Id:compound)// is det. % Parse a GraphViz identifier. % There are 4 variants: % 1. Any string of alphabetic (`[a-zA-Z'200-'377]`) characters, @@ -193,20 +227,24 @@ gv_id(Atom) --> % GraphViz keyword. {\+ gv_keyword([H|T])}. +%! gv_id_first(+First:code)// is det. +% Generates the first character of a GraphViz identifier. + gv_id_first(X) --> ascii_letter(X). gv_id_first(X) --> underscore(X). -gv_id_rest([]) --> []. +%! gv_id_rest(+NonFirst:code)// is det. +% Generates a non-first character of a GraphViz identifier. + +gv_id_rest([]) --> !, "". gv_id_rest([H|T]) --> ( ascii_alpha_numeric(H) ; underscore(H) ), gv_id_rest(T). - - %! gv_keyword(+Codes:list(code)) is semidet. % Succeeds if the given codes for a GraphViz reserved keyword. @@ -228,14 +266,6 @@ gv_keyword --> "subgraph". -%! gv_kind(+Kind:oneof([edge,graph,node]))// . - -gv_kind(edge) --> "edge". -gv_kind(graph) --> "graph". -gv_kind(node) --> "node". - - - %! gv_node_id(+NodeId:compound)// . % GraphViz node identifiers can be of the following two types: % 1. A GraphViz identifier, see gv_id//1. @@ -252,16 +282,7 @@ gv_node_id(Id) --> -%! gv_node_statement(+Indent:nonneg, +VertexTerm:compound)// . -% A GraphViz statement describing a vertex (GraphViz calls vertices 'nodes'). - -gv_node_statement(I, vertex(Id,VAttrs)) --> - indent(I), - gv_node_id(Id), - gv_attrs(node, VAttrs), - "\n". - - +%! gv_port// is det. gv_port --> gv_port_location, @@ -285,34 +306,25 @@ gv_port_location --> ":", gv_id(_). gv_port_location --> - ":(", - gv_id(_), - ",", - gv_id(_) - ")". - - + ":", + bracketed(( + gv_id(_), + ",", + gv_id(_) + )). -gv_ranked_node_collection(I, Rank) --> - indent(I), - bracketed(curly, gv_ranked_node_collection0(I, Rank)). +%! gv_compass_pt(+Direction:oneof(['_',c,e,n,ne,nw,s,se,sw,w]))// . +% ``` +% compass_pt : (n | ne | e | se | s | sw | w | nw | c | _) +% ``` -gv_ranked_node_collection0(I, rank(Rank_V_Term,Content_V_Terms)) --> - "\n", - - % The rank attribute. - {NewI is I + 1}, - indent(NewI), - gv_attr(subgraph, rank=same), - ";\n", - - % Vertice statements. - '*'( - gv_node_statement(NewI), - [Rank_V_Term|Content_V_Terms], - [] - ), - - % We want to indent the closing curly brace. - indent(I), - "\n". +gv_compass_pt('_') --> "_". +gv_compass_pt(c) --> "c". +gv_compass_pt(e) --> "e". +gv_compass_pt(n) --> "n". +gv_compass_pt(ne) --> "ne". +gv_compass_pt(nw) --> "nw". +gv_compass_pt(s) --> "s". +gv_compass_pt(se) --> "se". +gv_compass_pt(sw) --> "sw". +gv_compass_pt(w) --> "w". diff --git a/gv_html.pl b/prolog/gv/gv_html.pl similarity index 99% rename from gv_html.pl rename to prolog/gv/gv_html.pl index ced6d6b..c16d26b 100644 --- a/gv_html.pl +++ b/prolog/gv/gv_html.pl @@ -44,7 +44,7 @@ cell: label */ :- use_module(library(dcg/dcg_abnf)). -:- use_module(library(dcg/dcg_bracket)). +:- use_module(library(dcg/dcg_bracketed)). :- use_module(library(dcg/dcg_content)). :- use_module(library(http/html_dcg)). diff --git a/gv_numeral.pl b/prolog/gv/gv_numeral.pl similarity index 98% rename from gv_numeral.pl rename to prolog/gv/gv_numeral.pl index 1e5c723..4ba0d64 100644 --- a/gv_numeral.pl +++ b/prolog/gv/gv_numeral.pl @@ -14,7 +14,6 @@ :- use_module(library(dcg/dcg_abnf)). :- use_module(library(dcg/dcg_abnf_common)). :- use_module(library(dcg/dcg_ascii)). -:- use_module(library(dcg/dcg_cardinal)). :- use_module(library(math/math_ext)). :- use_module(library(math/positional)). :- use_module(library(math/radconv)). diff --git a/test/debug.pl b/test/debug.pl new file mode 100644 index 0000000..b0f85ea --- /dev/null +++ b/test/debug.pl @@ -0,0 +1,15 @@ +:- use_module(library(ansi_term)). +:- use_module(library(prolog_pack)). + +pack_ensure_removed(Pack):- + pack_property(Pack, _), !, + pack_remove(Pack). +pack_ensure_removed(_). + +test:- + pack_ensure_removed(plGraphViz), + source_file(test, ThisFile), + file_directory_name(ThisFile, ThisDirectory), + assert(user:file_search_path(gvTest, ThisDirectory)), + assert(user:file_search_path(library, gvTest('../prolog'))). +:- test. diff --git a/test/test.pl b/test/test.pl new file mode 100644 index 0000000..6e59928 --- /dev/null +++ b/test/test.pl @@ -0,0 +1,10 @@ +:- ensure_loaded(debug). + +:- use_module(library(gv/gv_attrs)). +:- use_module(library(gv/gv_attr_type)). +:- use_module(library(gv/gv_color)). +:- use_module(library(gv/gv_file)). +:- use_module(library(gv/gv_graph)). +:- use_module(library(gv/gv_graph_comp)). +:- use_module(library(gv/gv_html)). +:- use_module(library(gv/gv_numeral)). ```

101: 正在比较变动前 9513a9b 和变动后 7163f60

[back to content](#compare) ``` diff diff --git a/prolog/gv/gv_color.pl b/prolog/gv/gv_color.pl index 0553aa2..6c2cc4c 100644 --- a/prolog/gv/gv_color.pl +++ b/prolog/gv/gv_color.pl @@ -90,15 +90,17 @@ wc_weight(Float) --> gv_color_download:- verbose_call( 'updating the GraphViz color table', - ( - gv_color_uri(Uri), - html_download(Uri, Dom), - xpath(Dom, //table(1), TableDom1), - xpath(Dom, //table(2), TableDom2), - maplist(assert_color_table, [x11,svg], [TableDom1,TableDom2]) - ) + gv_color_download0 ). +gv_color_download0:- + gv_color_uri(Uri), + html_download(Uri, Dom), + xpath_chk(Dom, //table(1), TableDom1), + xpath_chk(Dom, //table(2), TableDom2), + maplist(assert_color_table, [x11,svg], [TableDom1,TableDom2]). + + assert_color_table(Colorscheme, TableDom):- html_table(TableDom, _, Rows), append(Rows, Cells), ```

102: 正在比较变动前 7163f60 和变动后 b2f4aef

[back to content](#compare) ``` diff diff --git a/pack.pl b/pack.pl index f0f5b22..cf24d04 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.1'). +version('0.0.2'). ```

103: 正在比较变动前 b2f4aef 和变动后 ba30c25

[back to content](#compare) ``` diff diff --git a/pack.pl b/pack.pl index cf24d04..775776f 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.2'). +version('0.0.3'). diff --git a/prolog/gv/gv_graph_comp.pl b/prolog/gv/gv_graph_comp.pl index 8a7d28a..7fd9709 100644 --- a/prolog/gv/gv_graph_comp.pl +++ b/prolog/gv/gv_graph_comp.pl @@ -177,7 +177,8 @@ gv_attrs(Kind, L) --> % A single GraphViz attribute. % We assume that the attribute has already been validated. -gv_attr(Context, N=V) --> +gv_attr(Context, Attr) --> + {Attr =.. [N,V]}, gv_id(N), "=", gv_attr_value(Context, N=V), ```

104: 正在比较变动前 ba30c25 和变动后 0eea41b

[back to content](#compare) ``` diff diff --git a/pack.pl b/pack.pl index 775776f..ea8929c 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.3'). +version('0.0.4'). diff --git a/prolog/gv/gv_file.pl b/prolog/gv/gv_file.pl index a175071..7a92cf5 100644 --- a/prolog/gv/gv_file.pl +++ b/prolog/gv/gv_file.pl @@ -53,7 +53,7 @@ gv_export(ExportGraph, OutputFile, Options):- % Be thread-safe. thread_self(Id), atomic_list_concat([gv_file,Id], '_', ThreadName), - absolute_file_name(data(ThreadName), TmpFile, [access(write),file_type(dot)]), + absolute_file_name(ThreadName, TmpFile, [access(write),file_type(dot)]), setup_call_cleanup( open(TmpFile, write, Write, [encoding(utf8)]), with_output_to(Write, put_codes(Codes)), @@ -69,20 +69,26 @@ gv_export(ExportGraph, OutputFile, Options):- % Converts a GraphViz DOT file to an image file, using a specific % visualization method. -file_to_gv(InputFile, OutputFile, Options):- - option(output(dot), Options), !, +file_to_gv(InputFile, OutputFile, Opts):- + var(OutputFile), !, + option(output(Ext), Opts, pdf), + file_name_extension(out, Ext, LocalName), + absolute_file_name(LocalName, OutputFile, Opts), + file_to_gv(InputFile, OutputFile, Opts). +file_to_gv(InputFile, OutputFile, Opts):- + option(output(dot), Opts), !, ( var(OutputFile) -> OutputFile = InputFile ; rename_file(InputFile, OutputFile) ). -file_to_gv(InputFile, OutputFile, Options):- +file_to_gv(InputFile, OutputFile, Opts):- % Typecheck for `method` option. - option(method(Method), Options, dot), + option(method(Method), Opts, dot), findall(Method0, gv_method(Method0), Methods), must_be(oneof(Methods), Method), % Typecheck for `output` option. - option(output(OutputType), Options, pdf), + option(output(OutputType), Opts, pdf), findall(OutputType0, gv_output_type(OutputType0), OutputTypes), must_be(oneof(OutputTypes), OutputType), ```

105: 正在比较变动前 0eea41b 和变动后 c1691bd

[back to content](#compare) ``` diff diff --git a/pack.pl b/pack.pl index ea8929c..8806f20 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.4'). +version('0.0.5'). diff --git a/prolog/gv/gv_attrs.pl b/prolog/gv/gv_attrs.pl index d773a8b..0e6b003 100644 --- a/prolog/gv/gv_attrs.pl +++ b/prolog/gv/gv_attrs.pl @@ -18,8 +18,8 @@ :- use_module(library(dcg/dcg_call)). :- use_module(library(dcg/dcg_phrase)). :- use_module(library(file_ext)). -:- use_module(library(http/html_download)). -:- use_module(library(http/html_table)). +:- use_module(library(html/html_download)). +:- use_module(library(html/html_table)). :- use_module(library(lists)). :- use_module(library(persistency_ext)). :- use_module(library(xpath)). diff --git a/prolog/gv/gv_color.pl b/prolog/gv/gv_color.pl index 6c2cc4c..bc08dcc 100644 --- a/prolog/gv/gv_color.pl +++ b/prolog/gv/gv_color.pl @@ -22,8 +22,8 @@ :- use_module(library(dcg/dcg_abnf)). :- use_module(library(dcg/dcg_content)). :- use_module(library(file_ext)). -:- use_module(library(http/html_download)). -:- use_module(library(http/html_table)). +:- use_module(library(html/html_download)). +:- use_module(library(html/html_table)). :- use_module(library(lists)). :- use_module(library(persistency_ext)). :- use_module(library(xpath)). diff --git a/prolog/gv/gv_dom.pl b/prolog/gv/gv_dom.pl new file mode 100644 index 0000000..e85849d --- /dev/null +++ b/prolog/gv/gv_dom.pl @@ -0,0 +1,35 @@ +:- module( + gv_dom, + [ + gv_dom/3 % +ExportGraph:compound + % -Dom:list(compound) + % +Options:list(compound) + ] +). + +/** GraphViz DOM + +@author Wouter Beek +@version 2015/07 +*/ + +:- use_module(library(gv/gv_file)). +:- use_module(library(option)). +:- use_module(library(svg/svg_dom)). + + + + + +%! gv_dom( +%! +ExportGraph:compound, +%! -Dom:list(compound), +%! +Options:list(compound) +%! ) is det. + +gv_dom(ExportG, Dom, Opts1):- + % Make sure the file type of the output file is SvgDom. + merge_options([output(svg)], Opts1, Opts2), + gv_export(ExportG, ToFile, Opts2), + svg_dom(ToFile, Dom), + delete_file(ToFile). diff --git a/prolog/gv/gv_html.pl b/prolog/gv/gv_html.pl index c16d26b..5f2db03 100644 --- a/prolog/gv/gv_html.pl +++ b/prolog/gv/gv_html.pl @@ -46,7 +46,7 @@ cell: label :- use_module(library(dcg/dcg_abnf)). :- use_module(library(dcg/dcg_bracketed)). :- use_module(library(dcg/dcg_content)). -:- use_module(library(http/html_dcg)). +:- use_module(library(html/html_dcg)). ```

106: 正在比较变动前 c1691bd 和变动后 3de9fc2

[back to content](#compare) ``` diff diff --git a/pack.pl b/pack.pl index 8806f20..d590fb2 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.5'). +version('0.0.6'). diff --git a/prolog/graph/build_export_graph.pl b/prolog/graph/build_export_graph.pl new file mode 100644 index 0000000..0bc966a --- /dev/null +++ b/prolog/graph/build_export_graph.pl @@ -0,0 +1,360 @@ +:- module( + build_export_graph, + [ + build_export_graph/3 % +Graph:compound + % -ExportGraph:compound + % +Options:list(compound) + ] +). + +/** Build graph representation for exporting + +Support for building GIF representations. + +# Graph Intermediate Format (GIF) + +## Graph + +```prolog +graph(Vs:ordset(compound),Ranks,Es:compound,Attributes:list(nvpair)) +``` + +### Edge + +```prolog +edge(FromVertexId,ToVertexId,Attributes:list(nvpair)) +``` + +### Rank + +```prolog +rank(RankVertex:compound,ContentVertices:ordset(compound)) +``` + +### Vertex + +```prolog +vertex(Id,Attributes:list(nvpair)) +``` + +# Property functions + +Edge label: + 1. [[graph_edge]] edge_label/2 + +Vertex coordinates: + 1. [[circle_coords]] circular_coord/4 + 2. [[random_coords]] random_coord/4 + +--- + +@author Wouter Beek +@version 2015/07 +*/ + +:- use_module(library(apply)). +:- use_module(library(list_ext)). +:- use_module(library(option_ext)). +:- use_module(library(ordsets)). + +:- predicate_options(build_export_graph/4, 4, [ + pass_to(edge_term/3, 3), + pass_to(graph_attributes/2, 2), + pass_to(vertex_term/3, 3) + ]). +:- predicate_options(edge_term/3, 3, [ + edge_arrowhead(+callable), + edge_color(+callable), + edge_id(+callable), + edge_label(+callable), + edge_penwidth(+callable), + edge_style(+callable) + ]). +:- predicate_options(graph_attributes/2, 2, [ + graph_charset(+oneof(['iso-8859-1','Latin1','UTF-8'])), + graph_colorscheme(+oneof([none,svg,x11])), + graph_directed(+boolean), + graph_fontsize(+float), + graph_label(+atom), + graph_overlap(+boolean) + ]). +:- predicate_options(vertex_term/3, 3, [ + vertex_color(+callable), + vertex_id(+callable), + vertex_image(+callable), + vertex_label(+callable), + vertex_peripheries(+callable), + vertex_position(+callable), + vertex_shape(+callable), + vertex_uri(+callable) + ]). + +:- meta_predicate(build_export_graph(+,-,:)). + +is_meta(edge_arrowhead). +is_meta(edge_color). +is_meta(edge_id). +is_meta(edge_label). +is_meta(edge_penwidth). +is_meta(edge_style). +is_meta(vertex_color). +is_meta(vertex_id). +is_meta(vertex_image). +is_meta(vertex_label). +is_meta(vertex_peripheries). +is_meta(vertex_position). +is_meta(vertex_shape). +is_meta(vertex_uri). + + + + + +%! build_export_graph( +%! +Graph:compound, +%! -ExportGraph:compound, +%! +Options:list(compound) +%! ) is det. + +build_export_graph(graph(Vs,Es), graph(VTerms,ETerms,GAttrs), Opts1):- + meta_options(is_meta, Opts1, Opts2), + + % V terms. + maplist(vertex_term0(Vs, Opts2), Vs, VTerms), + + % Edge terms. + maplist(edge_term0(Vs, Opts2), Es, ETerms), + + % Graph attributes. + graph_attributes(GAttrs, Opts2). + +vertex_term0(Vs, Opts, V, VTerm):- + vertex_term(Vs, V, VTerm, Opts). + +edge_term0(Vs, Opts, E, ETerm):- + edge_term(Vs, E, ETerm, Opts). + + + +%! edge_term( +%! +Vertices:ordset(compound), +%! +Edge:compound, +%! -EdgeTerm:compound, +%! +Options:list(compound) +%! ) is det. +% The following options are supported: +% * `edge_arrowhead(+callable)` +% No default. +% * `edge_color(+callable)` +% No default. +% * `edge_id(+callable)` +% Function that assignes the unique identifiers for an edge's +% incident vertices. +% * `edge_label(+callable)` +% No default. +% * `edge_penwidth(+callable)` +% No default. +% * `edge_style(+callable)` +% No default. + +edge_term(Vs, E, edge(FromId,ToId,EAttrs), Opts):- + % Arrowhead + if_option(edge_arrowhead(ArrowheadFunction), Opts, + call(ArrowheadFunction, E, EArrowhead) + ), + + % Color. + if_option(edge_color(ColorFunction), Opts, + call(ColorFunction, E, EColor) + ), + + % Id. + ( option(edge_id(IdFunction), Opts) + -> call(IdFunction, E, FromId, ToId) + ; E = edge(FromV,_,ToV), + nth0chk(FromId, Vs, FromV), + nth0chk(ToId, Vs, ToV) + ), + + % Label. + if_option(edge_label(LabelFunction), Opts, + call(LabelFunction, E, ELabel) + ), + + % Penwidth. + if_option(edge_penwidth(PenwidthFunction), Opts, + call(PenwidthFunction, E, EPenwidth) + ), + + % Style. + if_option(edge_style(StyleFunction), Opts, + call(StyleFunction, E, EStyle) + ), + + merge_options( + [ + arrowhead=EArrowhead, + color=EColor, + label=ELabel, + penwidth=EPenwidth, + style=EStyle + ], + EAttrs + ). + + + +%! graph_attributes( +%! -GraphAttributes:list(nvpair), +%! +Options:list(compound) +%! ) is det. +% The following options are supported: +% * `graph_charset(+oneof(['iso-8859-1','Latin1','UTF-8']))` +% The name of the character set that is used to encode text in the graph. +% Default: `UTF-8`. +% * `graph_colorscheme(+oneof([none,svg,x11]))` +% The colorscheme from which the color in this graph are taken. +% Default: `x11`. +% * `graph_directed(+boolean)` +% Whether the graph is directed (`true`) or undirected (`false`). +% Default: `false`. +% * `graph_fontsize(+float)` +% The font size of text in the graph. +% Default: `11.0`. +% * `graph_label(+atom)` +% The graph label. +% No default. +% * `graph_overlap(+boolean)` +% Whether the vertices are allowed to overlap. +% Default: `false`. + +graph_attributes(GAttrs, Opts):- + % Characer set. + option(graph_charset(Charset), Opts, 'UTF-8'), + % Colorscheme. + option(graph_colorscheme(Colorscheme), Opts, x11), + % Directed. + option(graph_directed(Directed), Opts, false), + % Fontsize. + option(graph_fontsize(Fontsize), Opts, 11.0), + % Label. + option(graph_label(GLabel), Opts, ''), + % Overlap. + option(graph_overlap(Overlap), Opts, false), + + merge_options( + [ + charset=Charset, + colorscheme=Colorscheme, + directed=Directed, + fontsize=Fontsize, + label=GLabel, + overlap=Overlap + ], + GAttrs + ). + + + +%! vertex_term( +%! +Vertices:ordset(compound), +%! +Vertex:compound, +%! -VertexTerm:compound, +%! +Options:list(compound) +%! ) is det. +% The following options are supported: +% * `vertex_color(:ColorFunction)` +% A function that assigns colors to vertices. +% No default. +% * `vertex_id(:ColorFunction)` +% A functions that assigns unique identifiers to vertices. +% * `vertex_image(:ImageFunction)` +% A function that assigns images to vertices. +% No default. +% * `vertex_label(:LabelFunction)` +% A function that assigns labels to vertices. +% No default. +% * `vertex_peripheries(:PeripheriesFunction)` +% A function that assinges peripheries to vertices. +% No default. +% * `vertex_position(:PositionFunction)` +% No default. +% * `vertex_shape(:ShapeFunction)` +% A function that assinges shapes to vertices. +% No default. +% * `vertex_uri(:UriFunction)` + +vertex_term(Vs, V, vertex(VId,VAttrs), Opts):- + % Color. + if_option(vertex_color(ColorFunction), Opts, + call(ColorFunction, V, VColor) + ), + + % Id. + ( option(vertex_id(IdFunction), Opts) + -> call(IdFunction, V, VId) + ; nth0chk(VId, Vs, V) + ), + + % Image. + ignore( + if_option(vertex_image(ImageFunction), Opts, + call(ImageFunction, V, VImage) + ) + ), + + % Label. + if_option(vertex_label(LabelFunction), Opts, + call(LabelFunction, V, VLabel) + ), + + % Peripheries. + if_option(vertex_peripheries(PeripheriesFunction), Opts, + call(PeripheriesFunction, V, VPeripheries) + ), + + % Position. + if_option(vertex_position(PositionFunction), Opts, + call(PositionFunction, Vs, Opts, V, VPosition) + ), + + % Shape. + if_option(vertex_shape(ShapeFunction), Opts, + call(ShapeFunction, V, VShape) + ), + + % URI + if_option(vertex_uri(UriFunction), Opts, + call(UriFunction, V, VUri) + ), + + merge_options( + [ + color=VColor, + image=VImage, + label=VLabel, + peripheries=VPeripheries, + pos=VPosition, + shape=VShape, + 'URL'=VUri + ], + VAttrs + ). + + + + + +% HELPERS % + +%! merge_options(+FromOptions:list(nvpair), -ToOptions:list(nvpair)) is det. + +merge_options([], []). +% Skip uninstantiated values. +merge_options([H|T1], T2):- + merge_options(T1, T2), + H =.. [_,V], + var(V), !. +% Include instantiated values. +merge_options([H|T1], [H|T2]):- + merge_options(T1, T2). diff --git a/prolog/gv/gv_attrs.pl b/prolog/gv/gv_attrs.pl index 0e6b003..6634b3e 100644 --- a/prolog/gv/gv_attrs.pl +++ b/prolog/gv/gv_attrs.pl @@ -18,14 +18,13 @@ :- use_module(library(dcg/dcg_call)). :- use_module(library(dcg/dcg_phrase)). :- use_module(library(file_ext)). +:- use_module(library(gv/gv_attr_type), [gv_attr_type//1]). :- use_module(library(html/html_download)). :- use_module(library(html/html_table)). :- use_module(library(lists)). :- use_module(library(persistency_ext)). :- use_module(library(xpath)). -:- use_module(library(gv/gv_attr_type), [gv_attr_type//1]). - %! gv_attr( %! ?Name:atom, %! ?UsedBy:list(oneof([cluster,edge,graph,node,subgraph])), diff --git a/test/test.pl b/test/test.pl index 6e59928..898c04e 100644 --- a/test/test.pl +++ b/test/test.pl @@ -1,10 +1,13 @@ :- ensure_loaded(debug). -:- use_module(library(gv/gv_attrs)). -:- use_module(library(gv/gv_attr_type)). -:- use_module(library(gv/gv_color)). -:- use_module(library(gv/gv_file)). -:- use_module(library(gv/gv_graph)). -:- use_module(library(gv/gv_graph_comp)). -:- use_module(library(gv/gv_html)). -:- use_module(library(gv/gv_numeral)). +%/graph + :- use_module(library(graph/build_export_graph)). +%/gv + :- use_module(library(gv/gv_attrs)). + :- use_module(library(gv/gv_attr_type)). + :- use_module(library(gv/gv_color)). + :- use_module(library(gv/gv_file)). + :- use_module(library(gv/gv_graph)). + :- use_module(library(gv/gv_graph_comp)). + :- use_module(library(gv/gv_html)). + :- use_module(library(gv/gv_numeral)). ```

107: 正在比较变动前 3de9fc2 和变动后 cb34d89

[back to content](#compare) ``` diff diff --git a/pack.pl b/pack.pl index d590fb2..8093a1f 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.6'). +version('0.0.7'). diff --git a/prolog/gv/gv_attrs.pl b/prolog/gv/gv_attrs.pl index 6634b3e..5e55234 100644 --- a/prolog/gv/gv_attrs.pl +++ b/prolog/gv/gv_attrs.pl @@ -22,7 +22,7 @@ :- use_module(library(html/html_download)). :- use_module(library(html/html_table)). :- use_module(library(lists)). -:- use_module(library(persistency_ext)). +:- use_module(library(persistency)). :- use_module(library(xpath)). %! gv_attr( @@ -144,7 +144,13 @@ gv_attrs_file(File):- gv_attrs_init:- gv_attrs_file(File), - init_persistent_db(File, gv_attrs_update). + ( exists_file(File) + -> true + ; touch(File) + ), + db_attach(File, []), + file_age(File, Age), + gv_attrs_update(Age). %! gv_attrs_update(+Age:float) is det. diff --git a/prolog/gv/gv_color.pl b/prolog/gv/gv_color.pl index bc08dcc..9235e27 100644 --- a/prolog/gv/gv_color.pl +++ b/prolog/gv/gv_color.pl @@ -25,7 +25,7 @@ :- use_module(library(html/html_download)). :- use_module(library(html/html_table)). :- use_module(library(lists)). -:- use_module(library(persistency_ext)). +:- use_module(library(persistency)). :- use_module(library(xpath)). %! gv_color(?Colorscheme:oneof([svg,x11]), ?Color:atom) is nondet. @@ -120,7 +120,13 @@ gv_color_file(File):- gv_color_init:- gv_color_file(File), - init_persistent_db(File, gv_color_update). + ( exists_file(File) + -> true + ; touch(File) + ), + db_attach(File, []), + file_age(File, Age), + gv_color_update(Age). %! gv_color_update(+Age:float) is det. ```

108: 正在比较变动前 cb34d89 和变动后 7f0e20f

[back to content](#compare) ``` diff diff --git a/pack.pl b/pack.pl index 8093a1f..487feb1 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.7'). +version('0.0.8'). diff --git a/prolog/gv/gv_graph.pl b/prolog/gv/gv_graph.pl index 6bd4b86..7f008c7 100644 --- a/prolog/gv/gv_graph.pl +++ b/prolog/gv/gv_graph.pl @@ -84,7 +84,8 @@ gv_graph(G1, I) --> % Directedness. {select_option(directed(Directed), GAttrs3, GAttrs4, true)}, - gv_graph_type(Directed), " ", + gv_graph_type(Directed), + " ", % Graph name. ( {select_option(name(GName), GAttrs4, GAttrs5)} @@ -183,7 +184,7 @@ add_default(L1, Opt, L2):- Opt =.. [N,_Value], Opt0 =.. [N,_FreshVar], ( option(Opt0, L1) - -> true + -> L2 = L1 ; L2 = [Opt|L1] ). ```

109: 正在比较变动前 7f0e20f 和变动后 c16a7a7

[back to content](#compare) ``` diff diff --git a/pack.pl b/pack.pl index 487feb1..57e9348 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.8'). +version('0.0.9'). diff --git a/prolog/graph/build_export_graph.pl b/prolog/graph/build_export_graph.pl index 0bc966a..67a9e1b 100644 --- a/prolog/graph/build_export_graph.pl +++ b/prolog/graph/build_export_graph.pl @@ -193,11 +193,11 @@ edge_term(Vs, E, edge(FromId,ToId,EAttrs), Opts):- merge_options( [ - arrowhead=EArrowhead, - color=EColor, - label=ELabel, - penwidth=EPenwidth, - style=EStyle + arrowhead(EArrowhead), + color(EColor), + label(ELabel), + penwidth(EPenwidth), + style(EStyle) ], EAttrs ). @@ -244,12 +244,12 @@ graph_attributes(GAttrs, Opts):- merge_options( [ - charset=Charset, - colorscheme=Colorscheme, - directed=Directed, - fontsize=Fontsize, - label=GLabel, - overlap=Overlap + charset(Charset), + colorscheme(Colorscheme), + directed(Directed), + fontsize(Fontsize), + label(GLabel), + overlap(Overlap) ], GAttrs ). @@ -330,13 +330,13 @@ vertex_term(Vs, V, vertex(VId,VAttrs), Opts):- merge_options( [ - color=VColor, - image=VImage, - label=VLabel, - peripheries=VPeripheries, - pos=VPosition, - shape=VShape, - 'URL'=VUri + color(VColor), + image(VImage), + label(VLabel), + peripheries(VPeripheries), + pos(VPosition), + shape(VShape), + 'URL'(VUri) ], VAttrs ). ```

110: 正在比较变动前 c16a7a7 和变动后 8bbb08c

[back to content](#compare) ``` diff diff --git a/pack.pl b/pack.pl index 57e9348..d1fef6b 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.9'). +version('0.0.10'). diff --git a/prolog/gv/gv_graph.pl b/prolog/gv/gv_graph.pl index 7f008c7..bff4257 100644 --- a/prolog/gv/gv_graph.pl +++ b/prolog/gv/gv_graph.pl @@ -160,13 +160,13 @@ gv_graph(G1, I) --> "}\n". gv_edge_statements(I, Dir, L) --> - '*'(gv_edge_statement(I, Dir), L, []). + '*'(gv_edge_statement(I, Dir), L, []), !. gv_node_statements(I, L) --> - '*'(gv_node_statement(I), L, []). + '*'(gv_node_statement(I), L, []), !. gv_ranked_node_collections(I, L) --> - '*'(gv_ranked_node_collection(I), L, []). + '*'(gv_ranked_node_collection(I), L, []), !. diff --git a/prolog/gv/gv_graph_comp.pl b/prolog/gv/gv_graph_comp.pl index 7fd9709..930fb32 100644 --- a/prolog/gv/gv_graph_comp.pl +++ b/prolog/gv/gv_graph_comp.pl @@ -109,7 +109,7 @@ gv_generic_attributes_statement(Kind, I, Attrs) --> indent(I), gv_kind(Kind), " ", gv_attrs(Kind, Attrs), - "\n". + "\n", !. %! gv_kind(+Kind:oneof([edge,graph,node]))// . ```

111: 正在比较变动前 8bbb08c 和变动后 34c8b1a

[back to content](#compare) ``` diff diff --git a/pack.pl b/pack.pl index d1fef6b..854ddee 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.10'). +version('0.0.11'). diff --git a/prolog/gv/gv_attrs.pl b/prolog/gv/gv_attrs.pl index 5e55234..5d97cb1 100644 --- a/prolog/gv/gv_attrs.pl +++ b/prolog/gv/gv_attrs.pl @@ -20,10 +20,10 @@ :- use_module(library(file_ext)). :- use_module(library(gv/gv_attr_type), [gv_attr_type//1]). :- use_module(library(html/html_download)). -:- use_module(library(html/html_table)). :- use_module(library(lists)). :- use_module(library(persistency)). :- use_module(library(xpath)). +:- use_module(library(xpath/xpath_table)). %! gv_attr( %! ?Name:atom, @@ -130,7 +130,7 @@ gv_attrs_download0:- gv_attrs_uri(Uri), html_download(Uri, Dom), xpath_chk(Dom, //table(@align=lower_case(center)), TableDom), - html_table(TableDom, _, Rows), + xpath_table(TableDom, _, Rows), maplist(assert_gv_attr_row, Rows). diff --git a/prolog/gv/gv_color.pl b/prolog/gv/gv_color.pl index 9235e27..d6eb478 100644 --- a/prolog/gv/gv_color.pl +++ b/prolog/gv/gv_color.pl @@ -13,7 +13,7 @@ @author Wouter Beek @tbd Color value `transparent` is only available in the output formats ps, svg, fig, vmrl, and the bitmap formats. -@version 2014/06, 2014/10-2014/11, 2015/01, 2015/03 +@version 2015/08 */ :- use_module(library(apply)). @@ -23,10 +23,10 @@ :- use_module(library(dcg/dcg_content)). :- use_module(library(file_ext)). :- use_module(library(html/html_download)). -:- use_module(library(html/html_table)). :- use_module(library(lists)). :- use_module(library(persistency)). :- use_module(library(xpath)). +:- use_module(library(xpath/xpath_table)). %! gv_color(?Colorscheme:oneof([svg,x11]), ?Color:atom) is nondet. @@ -102,7 +102,7 @@ gv_color_download0:- assert_color_table(Colorscheme, TableDom):- - html_table(TableDom, _, Rows), + xpath_table(TableDom, _, Rows), append(Rows, Cells), forall( member(Cell, Cells), diff --git a/prolog/gv/gv_file.pl b/prolog/gv/gv_file.pl index 7a92cf5..577a33a 100644 --- a/prolog/gv/gv_file.pl +++ b/prolog/gv/gv_file.pl @@ -25,8 +25,13 @@ user:prolog_file_type(dot, dot). user:prolog_file_type(pdf, pdf). -:- predicate_options(gv_export/3, 3, [pass_to(file_to_gv/3, 3)]). -:- predicate_options(file_to_gv/3, 3, [method(+atom),output(+atom)]). +:- predicate_options(gv_export/3, 3, [ + pass_to(file_to_gv/3, 3) + ]). +:- predicate_options(file_to_gv/3, 3, [ + method(+atom), + output(+atom) + ]). ```

112: 正在比较变动前 34c8b1a 和变动后 d883d06

[back to content](#compare) ``` diff diff --git a/pack.pl b/pack.pl index 854ddee..74f024d 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.11'). +version('0.0.12'). diff --git a/prolog/graph/build_export_graph.pl b/prolog/graph/build_export_graph.pl index 67a9e1b..e96f484 100644 --- a/prolog/graph/build_export_graph.pl +++ b/prolog/graph/build_export_graph.pl @@ -171,7 +171,10 @@ edge_term(Vs, E, edge(FromId,ToId,EAttrs), Opts):- % Id. ( option(edge_id(IdFunction), Opts) -> call(IdFunction, E, FromId, ToId) - ; E = edge(FromV,_,ToV), + ; ( E = edge(FromV,_,ToV) + -> true + ; E = edge(FromV,ToV) + ), nth0chk(FromId, Vs, FromV), nth0chk(ToId, Vs, ToV) ), ```

113: 正在比较变动前 d883d06 和变动后 66ac0a0

[back to content](#compare) ``` diff diff --git a/pack.pl b/pack.pl index 74f024d..2a85425 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.12'). +version('0.0.13'). diff --git a/prolog/graph/build_export_graph.pl b/prolog/graph/build_export_graph.pl index e96f484..b031d16 100644 --- a/prolog/graph/build_export_graph.pl +++ b/prolog/graph/build_export_graph.pl @@ -241,7 +241,8 @@ graph_attributes(GAttrs, Opts):- % Fontsize. option(graph_fontsize(Fontsize), Opts, 11.0), % Label. - option(graph_label(GLabel), Opts, ''), + % Defaults to the empty string. + option(graph_label(GLabel), Opts, '""'), % Overlap. option(graph_overlap(Overlap), Opts, false), ```

114: 正在比较变动前 66ac0a0 和变动后 ab5a102

[back to content](#compare) ``` diff diff --git a/pack.pl b/pack.pl index 2a85425..dfee09c 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.13'). +version('0.0.14'). diff --git a/prolog/gv/gv_attr_type.pl b/prolog/gv/gv_attr_type.pl index ff163fe..c6508a3 100644 --- a/prolog/gv/gv_attr_type.pl +++ b/prolog/gv/gv_attr_type.pl @@ -213,9 +213,9 @@ escape_double_quotes, [92,34] --> [34], !, escape_double_quotes. escape_double_quotes, [X] --> - [X], + [X], !, escape_double_quotes. - +escape_double_quotes --> []. ```

115: 正在比较变动前 ab5a102 和变动后 65f43b8

[back to content](#compare) ``` diff diff --git a/.gitignore b/.gitignore index e6bec15..7193a38 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ *~ *# *.db -*.log data/* diff --git a/gv_attrs.log b/gv_attrs.log new file mode 100644 index 0000000..a9c6010 --- /dev/null +++ b/gv_attrs.log @@ -0,0 +1,169 @@ +assert(gv_attr('Damping',[graph],[double],'0.99','0.0','neato only')). +assert(gv_attr('K',[cluster,graph],[double],'0.3','0','sfdp, fdp only')). +assert(gv_attr('URL',[cluster,edge,graph,node],[escString],_,'','svg, postscript, map only')). +assert(gv_attr('_background',[graph],[string],_,'','')). +assert(gv_attr(area,[cluster,node],[double],'1.0','>0','patchwork only')). +assert(gv_attr(arrowhead,[edge],[arrowType],normal,'','')). +assert(gv_attr(arrowsize,[edge],[double],'1.0','0.0','')). +assert(gv_attr(arrowtail,[edge],[arrowType],normal,'','')). +assert(gv_attr(bb,[graph],[rect],'','','write only')). +assert(gv_attr(bgcolor,[cluster,graph],[color,colorList],_,'','')). +assert(gv_attr(center,[graph],[bool],false,'','')). +assert(gv_attr(charset,[graph],[string],'"UTF-8"','','')). +assert(gv_attr(clusterrank,[graph],[clusterMode],local,'','dot only')). +assert(gv_attr(color,[cluster,edge,node],[color,colorList],black,'','')). +assert(gv_attr(colorscheme,[cluster,edge,graph,node],[string],'','','')). +assert(gv_attr(comment,[edge,graph,node],[string],'','','')). +assert(gv_attr(compound,[graph],[bool],false,'','dot only')). +assert(gv_attr(concentrate,[graph],[bool],false,'','')). +assert(gv_attr(constraint,[edge],[bool],true,'','dot only')). +assert(gv_attr(decorate,[edge],[bool],false,'','')). +assert(gv_attr(defaultdist,[graph],[double],'1+(avg. len)*sqrt(|V|)',epsilon,'neato only')). +assert(gv_attr(dim,[graph],[int],'2','2','sfdp, fdp, neato only')). +assert(gv_attr(dimen,[graph],[int],'2','2','sfdp, fdp, neato only')). +assert(gv_attr(dir,[edge],[dirType],'forward(directed)none(undirected)','','')). +assert(gv_attr(diredgeconstraints,[graph],[string,bool],false,'','neato only')). +assert(gv_attr(distortion,[node],[double],'0.0','-100.0','')). +assert(gv_attr(dpi,[graph],[double],'96.00.0','','svg, bitmap output only')). +assert(gv_attr(edgeURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(edgehref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(edgetarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(edgetooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(epsilon,[graph],[double],'.0001 * # nodes(mode == KK).0001(mode == major)','','neato only')). +assert(gv_attr(esep,[graph],[addDouble,addPoint],'+3','','not dot')). +assert(gv_attr(fillcolor,[cluster,edge,node],[color,colorList],'lightgrey(nodes)black(clusters)','','')). +assert(gv_attr(fixedsize,[node],[bool,string],false,'','')). +assert(gv_attr(fontcolor,[cluster,edge,graph,node],[color],black,'','')). +assert(gv_attr(fontname,[cluster,edge,graph,node],[string],'"Times-Roman"','','')). +assert(gv_attr(fontnames,[graph],[string],'','','svg only')). +assert(gv_attr(fontpath,[graph],[string],'system-dependent','','')). +assert(gv_attr(fontsize,[cluster,edge,graph,node],[double],'14.0','1.0','')). +assert(gv_attr(forcelabels,[graph],[bool],true,'','')). +assert(gv_attr(gradientangle,[cluster,graph,node],[int],'','','')). +assert(gv_attr(group,[node],[string],'','','dot only')). +assert(gv_attr(headURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(head_lp,[edge],[point],'','','write only')). +assert(gv_attr(headclip,[edge],[bool],true,'','')). +assert(gv_attr(headhref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(headlabel,[edge],[lblString],'','','')). +assert(gv_attr(headport,[edge],[portPos],center,'','')). +assert(gv_attr(headtarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(headtooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(height,[node],[double],'0.5','0.02','')). +assert(gv_attr(href,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only')). +assert(gv_attr(id,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only')). +assert(gv_attr(image,[node],[string],'','','')). +assert(gv_attr(imagepath,[graph],[string],'','','')). +assert(gv_attr(imagescale,[node],[bool,string],false,'','')). +assert(gv_attr(inputscale,[graph],[double],_,'','fdp, neato only')). +assert(gv_attr(label,[cluster,edge,graph,node],[lblString],'"\\N" (nodes)"" (otherwise)','','')). +assert(gv_attr(labelURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(label_scheme,[graph],[int],'0','0','sfdp only')). +assert(gv_attr(labelangle,[edge],[double],'-25.0','-180.0','')). +assert(gv_attr(labeldistance,[edge],[double],'1.0','0.0','')). +assert(gv_attr(labelfloat,[edge],[bool],false,'','')). +assert(gv_attr(labelfontcolor,[edge],[color],black,'','')). +assert(gv_attr(labelfontname,[edge],[string],'"Times-Roman"','','')). +assert(gv_attr(labelfontsize,[edge],[double],'14.0','1.0','')). +assert(gv_attr(labelhref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(labeljust,[cluster,graph],[string],'"c"','','')). +assert(gv_attr(labelloc,[cluster,graph,node],[string],'"t"(clusters)"b"(root graphs)"c"(nodes)','','')). +assert(gv_attr(labeltarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(labeltooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(landscape,[graph],[bool],false,'','')). +assert(gv_attr(layer,[cluster,edge,node],[layerRange],'','','')). +assert(gv_attr(layerlistsep,[graph],[string],'","','','')). +assert(gv_attr(layers,[graph],[layerList],'','','')). +assert(gv_attr(layerselect,[graph],[layerRange],'','','')). +assert(gv_attr(layersep,[graph],[string],'" :\\t"','','')). +assert(gv_attr(layout,[graph],[string],'','','')). +assert(gv_attr(len,[edge],[double],'1.0(neato)0.3(fdp)','','fdp, neato only')). +assert(gv_attr(levels,[graph],[int],'MAXINT','0.0','sfdp only')). +assert(gv_attr(levelsgap,[graph],[double],'0.0','','neato only')). +assert(gv_attr(lhead,[edge],[string],'','','dot only')). +assert(gv_attr(lheight,[cluster,graph],[double],'','','write only')). +assert(gv_attr(lp,[cluster,edge,graph],[point],'','','write only')). +assert(gv_attr(ltail,[edge],[string],'','','dot only')). +assert(gv_attr(lwidth,[cluster,graph],[double],'','','write only')). +assert(gv_attr(margin,[cluster,graph,node],[double,point],'','','')). +assert(gv_attr(maxiter,[graph],[int],'100 * # nodes(mode == KK)200(mode == major)600(fdp)','','fdp, neato only')). +assert(gv_attr(mclimit,[graph],[double],'1.0','','dot only')). +assert(gv_attr(mindist,[graph],[double],'1.0','0.0','circo only')). +assert(gv_attr(minlen,[edge],[int],'1','0','dot only')). +assert(gv_attr(mode,[graph],[string],major,'','neato only')). +assert(gv_attr(model,[graph],[string],shortpath,'','neato only')). +assert(gv_attr(mosek,[graph],[bool],false,'','neato only')). +assert(gv_attr(nodesep,[graph],[double],'0.25','0.02','')). +assert(gv_attr(nojustify,[cluster,edge,graph,node],[bool],false,'','')). +assert(gv_attr(normalize,[graph],[double,bool],false,'','not dot')). +assert(gv_attr(notranslate,[graph],[bool],false,'','neato only')). +assert(gv_attr('nslimit nslimit1',[graph],[double],'','','dot only')). +assert(gv_attr(ordering,[graph,node],[string],'','','dot only')). +assert(gv_attr(orientation,[node],[double],'0.0','360.0','')). +assert(gv_attr(orientation,[graph],[string],'','','')). +assert(gv_attr(outputorder,[graph],[outputMode],breadthfirst,'','')). +assert(gv_attr(overlap,[graph],[string,bool],true,'','not dot')). +assert(gv_attr(overlap_scaling,[graph],[double],'-4','-1.0e10','prism only')). +assert(gv_attr(overlap_shrink,[graph],[bool],true,'','prism only')). +assert(gv_attr(pack,[graph],[bool,int],false,'','')). +assert(gv_attr(packmode,[graph],[packMode],node,'','')). +assert(gv_attr(pad,[graph],[double,point],'0.0555 (4 points)','','')). +assert(gv_attr(page,[graph],[double,point],'','','')). +assert(gv_attr(pagedir,[graph],[pagedir],'BL','','')). +assert(gv_attr(pencolor,[cluster],[color],black,'','')). +assert(gv_attr(penwidth,[cluster,edge,node],[double],'1.0','0.0','')). +assert(gv_attr(peripheries,[cluster,node],[int],'shape default(nodes)1(clusters)','0','')). +assert(gv_attr(pin,[node],[bool],false,'','fdp, neato only')). +assert(gv_attr(pos,[edge,node],[point,splineType],'','','')). +assert(gv_attr(quadtree,[graph],[quadType,bool],normal,'','sfdp only')). +assert(gv_attr(quantum,[graph],[double],'0.0','0.0','')). +assert(gv_attr(rank,[subgraph],[rankType],'','','dot only')). +assert(gv_attr(rankdir,[graph],[rankdir],'TB','','dot only')). +assert(gv_attr(ranksep,[graph],[double,doubleList],'0.5(dot)1.0(twopi)','0.02','twopi, dot only')). +assert(gv_attr(ratio,[graph],[double,string],'','','')). +assert(gv_attr(rects,[node],[rect],'','','write only')). +assert(gv_attr(regular,[node],[bool],false,'','')). +assert(gv_attr(remincross,[graph],[bool],true,'','dot only')). +assert(gv_attr(repulsiveforce,[graph],[double],'1.0','0.0','sfdp only')). +assert(gv_attr(resolution,[graph],[double],'96.00.0','','svg, bitmap output only')). +assert(gv_attr(root,[graph,node],[string,bool],'(graphs)false(nodes)','','circo, twopi only')). +assert(gv_attr(rotate,[graph],[int],'0','','')). +assert(gv_attr(rotation,[graph],[double],'0','','sfdp only')). +assert(gv_attr(samehead,[edge],[string],'','','dot only')). +assert(gv_attr(sametail,[edge],[string],'','','dot only')). +assert(gv_attr(samplepoints,[node],[int],'8(output)20(overlap and image maps)','','')). +assert(gv_attr(scale,[graph],[double,point],'','','not dot')). +assert(gv_attr(searchsize,[graph],[int],'30','','dot only')). +assert(gv_attr(sep,[graph],[addDouble,addPoint],'+4','','not dot')). +assert(gv_attr(shape,[node],[shape],ellipse,'','')). +assert(gv_attr(shapefile,[node],[string],'','','')). +assert(gv_attr(showboxes,[edge,graph,node],[int],'0','0','dot only')). +assert(gv_attr(sides,[node],[int],'4','0','')). +assert(gv_attr(size,[graph],[double,point],'','','')). +assert(gv_attr(skew,[node],[double],'0.0','-100.0','')). +assert(gv_attr(smoothing,[graph],[smoothType],'"none"','','sfdp only')). +assert(gv_attr(sortv,[cluster,graph,node],[int],'0','0','')). +assert(gv_attr(splines,[graph],[bool,string],'','','')). +assert(gv_attr(start,[graph],[startType],'','','fdp, neato only')). +assert(gv_attr(style,[cluster,edge,graph,node],[style],'','','')). +assert(gv_attr(stylesheet,[graph],[string],'','','svg only')). +assert(gv_attr(tailURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(tail_lp,[edge],[point],'','','write only')). +assert(gv_attr(tailclip,[edge],[bool],true,'','')). +assert(gv_attr(tailhref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(taillabel,[edge],[lblString],'','','')). +assert(gv_attr(tailport,[edge],[portPos],center,'','')). +assert(gv_attr(tailtarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(tailtooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(target,[cluster,edge,graph,node],[escString,string],_,'','svg, map only')). +assert(gv_attr(tooltip,[cluster,edge,node],[escString],'','','svg, cmap only')). +assert(gv_attr(truecolor,[graph],[bool],'','','bitmap output only')). +assert(gv_attr(vertices,[node],[pointList],'','','write only')). +assert(gv_attr(viewport,[graph],[viewPort],'','','')). +assert(gv_attr(voro_margin,[graph],[double],'0.05','0.0','not dot')). +assert(gv_attr(weight,[edge],[int,double],'1','0(dot,twopi)1(neato,fdp)','')). +assert(gv_attr(width,[node],[double],'0.75','0.01','')). +assert(gv_attr(xdotversion,[graph],[string],'','','xdot only')). +assert(gv_attr(xlabel,[edge,node],[lblString],'','','')). +assert(gv_attr(xlp,[edge,node],[point],'','','write only')). +assert(gv_attr(z,[node],[double],'0.0','-MAXFLOAT-1000','')). diff --git a/gv_color.log b/gv_color.log new file mode 100644 index 0000000..23d6cdf --- /dev/null +++ b/gv_color.log @@ -0,0 +1,802 @@ +assert(gv_color(x11,aliceblue)). +assert(gv_color(x11,antiquewhite)). +assert(gv_color(x11,antiquewhite1)). +assert(gv_color(x11,antiquewhite2)). +assert(gv_color(x11,antiquewhite3)). +assert(gv_color(x11,antiquewhite4)). +assert(gv_color(x11,aquamarine)). +assert(gv_color(x11,aquamarine1)). +assert(gv_color(x11,aquamarine2)). +assert(gv_color(x11,aquamarine3)). +assert(gv_color(x11,aquamarine4)). +assert(gv_color(x11,azure)). +assert(gv_color(x11,azure1)). +assert(gv_color(x11,azure2)). +assert(gv_color(x11,azure3)). +assert(gv_color(x11,azure4)). +assert(gv_color(x11,beige)). +assert(gv_color(x11,bisque)). +assert(gv_color(x11,bisque1)). +assert(gv_color(x11,bisque2)). +assert(gv_color(x11,bisque3)). +assert(gv_color(x11,bisque4)). +assert(gv_color(x11,black)). +assert(gv_color(x11,blanchedalmond)). +assert(gv_color(x11,blue)). +assert(gv_color(x11,blue1)). +assert(gv_color(x11,blue2)). +assert(gv_color(x11,blue3)). +assert(gv_color(x11,blue4)). +assert(gv_color(x11,blueviolet)). +assert(gv_color(x11,brown)). +assert(gv_color(x11,brown1)). +assert(gv_color(x11,brown2)). +assert(gv_color(x11,brown3)). +assert(gv_color(x11,brown4)). +assert(gv_color(x11,burlywood)). +assert(gv_color(x11,burlywood1)). +assert(gv_color(x11,burlywood2)). +assert(gv_color(x11,burlywood3)). +assert(gv_color(x11,burlywood4)). +assert(gv_color(x11,cadetblue)). +assert(gv_color(x11,cadetblue1)). +assert(gv_color(x11,cadetblue2)). +assert(gv_color(x11,cadetblue3)). +assert(gv_color(x11,cadetblue4)). +assert(gv_color(x11,chartreuse)). +assert(gv_color(x11,chartreuse1)). +assert(gv_color(x11,chartreuse2)). +assert(gv_color(x11,chartreuse3)). +assert(gv_color(x11,chartreuse4)). +assert(gv_color(x11,chocolate)). +assert(gv_color(x11,chocolate1)). +assert(gv_color(x11,chocolate2)). +assert(gv_color(x11,chocolate3)). +assert(gv_color(x11,chocolate4)). +assert(gv_color(x11,coral)). +assert(gv_color(x11,coral1)). +assert(gv_color(x11,coral2)). +assert(gv_color(x11,coral3)). +assert(gv_color(x11,coral4)). +assert(gv_color(x11,cornflowerblue)). +assert(gv_color(x11,cornsilk)). +assert(gv_color(x11,cornsilk1)). +assert(gv_color(x11,cornsilk2)). +assert(gv_color(x11,cornsilk3)). +assert(gv_color(x11,cornsilk4)). +assert(gv_color(x11,crimson)). +assert(gv_color(x11,cyan)). +assert(gv_color(x11,cyan1)). +assert(gv_color(x11,cyan2)). +assert(gv_color(x11,cyan3)). +assert(gv_color(x11,cyan4)). +assert(gv_color(x11,darkgoldenrod)). +assert(gv_color(x11,darkgoldenrod1)). +assert(gv_color(x11,darkgoldenrod2)). +assert(gv_color(x11,darkgoldenrod3)). +assert(gv_color(x11,darkgoldenrod4)). +assert(gv_color(x11,darkgreen)). +assert(gv_color(x11,darkkhaki)). +assert(gv_color(x11,darkolivegreen)). +assert(gv_color(x11,darkolivegreen1)). +assert(gv_color(x11,darkolivegreen2)). +assert(gv_color(x11,darkolivegreen3)). +assert(gv_color(x11,darkolivegreen4)). +assert(gv_color(x11,darkorange)). +assert(gv_color(x11,darkorange1)). +assert(gv_color(x11,darkorange2)). +assert(gv_color(x11,darkorange3)). +assert(gv_color(x11,darkorange4)). +assert(gv_color(x11,darkorchid)). +assert(gv_color(x11,darkorchid1)). +assert(gv_color(x11,darkorchid2)). +assert(gv_color(x11,darkorchid3)). +assert(gv_color(x11,darkorchid4)). +assert(gv_color(x11,darksalmon)). +assert(gv_color(x11,darkseagreen)). +assert(gv_color(x11,darkseagreen1)). +assert(gv_color(x11,darkseagreen2)). +assert(gv_color(x11,darkseagreen3)). +assert(gv_color(x11,darkseagreen4)). +assert(gv_color(x11,darkslateblue)). +assert(gv_color(x11,darkslategray)). +assert(gv_color(x11,darkslategray1)). +assert(gv_color(x11,darkslategray2)). +assert(gv_color(x11,darkslategray3)). +assert(gv_color(x11,darkslategray4)). +assert(gv_color(x11,darkslategrey)). +assert(gv_color(x11,darkturquoise)). +assert(gv_color(x11,darkviolet)). +assert(gv_color(x11,deeppink)). +assert(gv_color(x11,deeppink1)). +assert(gv_color(x11,deeppink2)). +assert(gv_color(x11,deeppink3)). +assert(gv_color(x11,deeppink4)). +assert(gv_color(x11,deepskyblue)). +assert(gv_color(x11,deepskyblue1)). +assert(gv_color(x11,deepskyblue2)). +assert(gv_color(x11,deepskyblue3)). +assert(gv_color(x11,deepskyblue4)). +assert(gv_color(x11,dimgray)). +assert(gv_color(x11,dimgrey)). +assert(gv_color(x11,dodgerblue)). +assert(gv_color(x11,dodgerblue1)). +assert(gv_color(x11,dodgerblue2)). +assert(gv_color(x11,dodgerblue3)). +assert(gv_color(x11,dodgerblue4)). +assert(gv_color(x11,firebrick)). +assert(gv_color(x11,firebrick1)). +assert(gv_color(x11,firebrick2)). +assert(gv_color(x11,firebrick3)). +assert(gv_color(x11,firebrick4)). +assert(gv_color(x11,floralwhite)). +assert(gv_color(x11,forestgreen)). +assert(gv_color(x11,gainsboro)). +assert(gv_color(x11,ghostwhite)). +assert(gv_color(x11,gold)). +assert(gv_color(x11,gold1)). +assert(gv_color(x11,gold2)). +assert(gv_color(x11,gold3)). +assert(gv_color(x11,gold4)). +assert(gv_color(x11,goldenrod)). +assert(gv_color(x11,goldenrod1)). +assert(gv_color(x11,goldenrod2)). +assert(gv_color(x11,goldenrod3)). +assert(gv_color(x11,goldenrod4)). +assert(gv_color(x11,gray)). +assert(gv_color(x11,gray0)). +assert(gv_color(x11,gray1)). +assert(gv_color(x11,gray10)). +assert(gv_color(x11,gray100)). +assert(gv_color(x11,gray11)). +assert(gv_color(x11,gray12)). +assert(gv_color(x11,gray13)). +assert(gv_color(x11,gray14)). +assert(gv_color(x11,gray15)). +assert(gv_color(x11,gray16)). +assert(gv_color(x11,gray17)). +assert(gv_color(x11,gray18)). +assert(gv_color(x11,gray19)). +assert(gv_color(x11,gray2)). +assert(gv_color(x11,gray20)). +assert(gv_color(x11,gray21)). +assert(gv_color(x11,gray22)). +assert(gv_color(x11,gray23)). +assert(gv_color(x11,gray24)). +assert(gv_color(x11,gray25)). +assert(gv_color(x11,gray26)). +assert(gv_color(x11,gray27)). +assert(gv_color(x11,gray28)). +assert(gv_color(x11,gray29)). +assert(gv_color(x11,gray3)). +assert(gv_color(x11,gray30)). +assert(gv_color(x11,gray31)). +assert(gv_color(x11,gray32)). +assert(gv_color(x11,gray33)). +assert(gv_color(x11,gray34)). +assert(gv_color(x11,gray35)). +assert(gv_color(x11,gray36)). +assert(gv_color(x11,gray37)). +assert(gv_color(x11,gray38)). +assert(gv_color(x11,gray39)). +assert(gv_color(x11,gray4)). +assert(gv_color(x11,gray40)). +assert(gv_color(x11,gray41)). +assert(gv_color(x11,gray42)). +assert(gv_color(x11,gray43)). +assert(gv_color(x11,gray44)). +assert(gv_color(x11,gray45)). +assert(gv_color(x11,gray46)). +assert(gv_color(x11,gray47)). +assert(gv_color(x11,gray48)). +assert(gv_color(x11,gray49)). +assert(gv_color(x11,gray5)). +assert(gv_color(x11,gray50)). +assert(gv_color(x11,gray51)). +assert(gv_color(x11,gray52)). +assert(gv_color(x11,gray53)). +assert(gv_color(x11,gray54)). +assert(gv_color(x11,gray55)). +assert(gv_color(x11,gray56)). +assert(gv_color(x11,gray57)). +assert(gv_color(x11,gray58)). +assert(gv_color(x11,gray59)). +assert(gv_color(x11,gray6)). +assert(gv_color(x11,gray60)). +assert(gv_color(x11,gray61)). +assert(gv_color(x11,gray62)). +assert(gv_color(x11,gray63)). +assert(gv_color(x11,gray64)). +assert(gv_color(x11,gray65)). +assert(gv_color(x11,gray66)). +assert(gv_color(x11,gray67)). +assert(gv_color(x11,gray68)). +assert(gv_color(x11,gray69)). +assert(gv_color(x11,gray7)). +assert(gv_color(x11,gray70)). +assert(gv_color(x11,gray71)). +assert(gv_color(x11,gray72)). +assert(gv_color(x11,gray73)). +assert(gv_color(x11,gray74)). +assert(gv_color(x11,gray75)). +assert(gv_color(x11,gray76)). +assert(gv_color(x11,gray77)). +assert(gv_color(x11,gray78)). +assert(gv_color(x11,gray79)). +assert(gv_color(x11,gray8)). +assert(gv_color(x11,gray80)). +assert(gv_color(x11,gray81)). +assert(gv_color(x11,gray82)). +assert(gv_color(x11,gray83)). +assert(gv_color(x11,gray84)). +assert(gv_color(x11,gray85)). +assert(gv_color(x11,gray86)). +assert(gv_color(x11,gray87)). +assert(gv_color(x11,gray88)). +assert(gv_color(x11,gray89)). +assert(gv_color(x11,gray9)). +assert(gv_color(x11,gray90)). +assert(gv_color(x11,gray91)). +assert(gv_color(x11,gray92)). +assert(gv_color(x11,gray93)). +assert(gv_color(x11,gray94)). +assert(gv_color(x11,gray95)). +assert(gv_color(x11,gray96)). +assert(gv_color(x11,gray97)). +assert(gv_color(x11,gray98)). +assert(gv_color(x11,gray99)). +assert(gv_color(x11,green)). +assert(gv_color(x11,green1)). +assert(gv_color(x11,green2)). +assert(gv_color(x11,green3)). +assert(gv_color(x11,green4)). +assert(gv_color(x11,greenyellow)). +assert(gv_color(x11,grey)). +assert(gv_color(x11,grey0)). +assert(gv_color(x11,grey1)). +assert(gv_color(x11,grey10)). +assert(gv_color(x11,grey100)). +assert(gv_color(x11,grey11)). +assert(gv_color(x11,grey12)). +assert(gv_color(x11,grey13)). +assert(gv_color(x11,grey14)). +assert(gv_color(x11,grey15)). +assert(gv_color(x11,grey16)). +assert(gv_color(x11,grey17)). +assert(gv_color(x11,grey18)). +assert(gv_color(x11,grey19)). +assert(gv_color(x11,grey2)). +assert(gv_color(x11,grey20)). +assert(gv_color(x11,grey21)). +assert(gv_color(x11,grey22)). +assert(gv_color(x11,grey23)). +assert(gv_color(x11,grey24)). +assert(gv_color(x11,grey25)). +assert(gv_color(x11,grey26)). +assert(gv_color(x11,grey27)). +assert(gv_color(x11,grey28)). +assert(gv_color(x11,grey29)). +assert(gv_color(x11,grey3)). +assert(gv_color(x11,grey30)). +assert(gv_color(x11,grey31)). +assert(gv_color(x11,grey32)). +assert(gv_color(x11,grey33)). +assert(gv_color(x11,grey34)). +assert(gv_color(x11,grey35)). +assert(gv_color(x11,grey36)). +assert(gv_color(x11,grey37)). +assert(gv_color(x11,grey38)). +assert(gv_color(x11,grey39)). +assert(gv_color(x11,grey4)). +assert(gv_color(x11,grey40)). +assert(gv_color(x11,grey41)). +assert(gv_color(x11,grey42)). +assert(gv_color(x11,grey43)). +assert(gv_color(x11,grey44)). +assert(gv_color(x11,grey45)). +assert(gv_color(x11,grey46)). +assert(gv_color(x11,grey47)). +assert(gv_color(x11,grey48)). +assert(gv_color(x11,grey49)). +assert(gv_color(x11,grey5)). +assert(gv_color(x11,grey50)). +assert(gv_color(x11,grey51)). +assert(gv_color(x11,grey52)). +assert(gv_color(x11,grey53)). +assert(gv_color(x11,grey54)). +assert(gv_color(x11,grey55)). +assert(gv_color(x11,grey56)). +assert(gv_color(x11,grey57)). +assert(gv_color(x11,grey58)). +assert(gv_color(x11,grey59)). +assert(gv_color(x11,grey6)). +assert(gv_color(x11,grey60)). +assert(gv_color(x11,grey61)). +assert(gv_color(x11,grey62)). +assert(gv_color(x11,grey63)). +assert(gv_color(x11,grey64)). +assert(gv_color(x11,grey65)). +assert(gv_color(x11,grey66)). +assert(gv_color(x11,grey67)). +assert(gv_color(x11,grey68)). +assert(gv_color(x11,grey69)). +assert(gv_color(x11,grey7)). +assert(gv_color(x11,grey70)). +assert(gv_color(x11,grey71)). +assert(gv_color(x11,grey72)). +assert(gv_color(x11,grey73)). +assert(gv_color(x11,grey74)). +assert(gv_color(x11,grey75)). +assert(gv_color(x11,grey76)). +assert(gv_color(x11,grey77)). +assert(gv_color(x11,grey78)). +assert(gv_color(x11,grey79)). +assert(gv_color(x11,grey8)). +assert(gv_color(x11,grey80)). +assert(gv_color(x11,grey81)). +assert(gv_color(x11,grey82)). +assert(gv_color(x11,grey83)). +assert(gv_color(x11,grey84)). +assert(gv_color(x11,grey85)). +assert(gv_color(x11,grey86)). +assert(gv_color(x11,grey87)). +assert(gv_color(x11,grey88)). +assert(gv_color(x11,grey89)). +assert(gv_color(x11,grey9)). +assert(gv_color(x11,grey90)). +assert(gv_color(x11,grey91)). +assert(gv_color(x11,grey92)). +assert(gv_color(x11,grey93)). +assert(gv_color(x11,grey94)). +assert(gv_color(x11,grey95)). +assert(gv_color(x11,grey96)). +assert(gv_color(x11,grey97)). +assert(gv_color(x11,grey98)). +assert(gv_color(x11,grey99)). +assert(gv_color(x11,honeydew)). +assert(gv_color(x11,honeydew1)). +assert(gv_color(x11,honeydew2)). +assert(gv_color(x11,honeydew3)). +assert(gv_color(x11,honeydew4)). +assert(gv_color(x11,hotpink)). +assert(gv_color(x11,hotpink1)). +assert(gv_color(x11,hotpink2)). +assert(gv_color(x11,hotpink3)). +assert(gv_color(x11,hotpink4)). +assert(gv_color(x11,indianred)). +assert(gv_color(x11,indianred1)). +assert(gv_color(x11,indianred2)). +assert(gv_color(x11,indianred3)). +assert(gv_color(x11,indianred4)). +assert(gv_color(x11,indigo)). +assert(gv_color(x11,invis)). +assert(gv_color(x11,ivory)). +assert(gv_color(x11,ivory1)). +assert(gv_color(x11,ivory2)). +assert(gv_color(x11,ivory3)). +assert(gv_color(x11,ivory4)). +assert(gv_color(x11,khaki)). +assert(gv_color(x11,khaki1)). +assert(gv_color(x11,khaki2)). +assert(gv_color(x11,khaki3)). +assert(gv_color(x11,khaki4)). +assert(gv_color(x11,lavender)). +assert(gv_color(x11,lavenderblush)). +assert(gv_color(x11,lavenderblush1)). +assert(gv_color(x11,lavenderblush2)). +assert(gv_color(x11,lavenderblush3)). +assert(gv_color(x11,lavenderblush4)). +assert(gv_color(x11,lawngreen)). +assert(gv_color(x11,lemonchiffon)). +assert(gv_color(x11,lemonchiffon1)). +assert(gv_color(x11,lemonchiffon2)). +assert(gv_color(x11,lemonchiffon3)). +assert(gv_color(x11,lemonchiffon4)). +assert(gv_color(x11,lightblue)). +assert(gv_color(x11,lightblue1)). +assert(gv_color(x11,lightblue2)). +assert(gv_color(x11,lightblue3)). +assert(gv_color(x11,lightblue4)). +assert(gv_color(x11,lightcoral)). +assert(gv_color(x11,lightcyan)). +assert(gv_color(x11,lightcyan1)). +assert(gv_color(x11,lightcyan2)). +assert(gv_color(x11,lightcyan3)). +assert(gv_color(x11,lightcyan4)). +assert(gv_color(x11,lightgoldenrod)). +assert(gv_color(x11,lightgoldenrod1)). +assert(gv_color(x11,lightgoldenrod2)). +assert(gv_color(x11,lightgoldenrod3)). +assert(gv_color(x11,lightgoldenrod4)). +assert(gv_color(x11,lightgoldenrodyellow)). +assert(gv_color(x11,lightgray)). +assert(gv_color(x11,lightgrey)). +assert(gv_color(x11,lightpink)). +assert(gv_color(x11,lightpink1)). +assert(gv_color(x11,lightpink2)). +assert(gv_color(x11,lightpink3)). +assert(gv_color(x11,lightpink4)). +assert(gv_color(x11,lightsalmon)). +assert(gv_color(x11,lightsalmon1)). +assert(gv_color(x11,lightsalmon2)). +assert(gv_color(x11,lightsalmon3)). +assert(gv_color(x11,lightsalmon4)). +assert(gv_color(x11,lightseagreen)). +assert(gv_color(x11,lightskyblue)). +assert(gv_color(x11,lightskyblue1)). +assert(gv_color(x11,lightskyblue2)). +assert(gv_color(x11,lightskyblue3)). +assert(gv_color(x11,lightskyblue4)). +assert(gv_color(x11,lightslateblue)). +assert(gv_color(x11,lightslategray)). +assert(gv_color(x11,lightslategrey)). +assert(gv_color(x11,lightsteelblue)). +assert(gv_color(x11,lightsteelblue1)). +assert(gv_color(x11,lightsteelblue2)). +assert(gv_color(x11,lightsteelblue3)). +assert(gv_color(x11,lightsteelblue4)). +assert(gv_color(x11,lightyellow)). +assert(gv_color(x11,lightyellow1)). +assert(gv_color(x11,lightyellow2)). +assert(gv_color(x11,lightyellow3)). +assert(gv_color(x11,lightyellow4)). +assert(gv_color(x11,limegreen)). +assert(gv_color(x11,linen)). +assert(gv_color(x11,magenta)). +assert(gv_color(x11,magenta1)). +assert(gv_color(x11,magenta2)). +assert(gv_color(x11,magenta3)). +assert(gv_color(x11,magenta4)). +assert(gv_color(x11,maroon)). +assert(gv_color(x11,maroon1)). +assert(gv_color(x11,maroon2)). +assert(gv_color(x11,maroon3)). +assert(gv_color(x11,maroon4)). +assert(gv_color(x11,mediumaquamarine)). +assert(gv_color(x11,mediumblue)). +assert(gv_color(x11,mediumorchid)). +assert(gv_color(x11,mediumorchid1)). +assert(gv_color(x11,mediumorchid2)). +assert(gv_color(x11,mediumorchid3)). +assert(gv_color(x11,mediumorchid4)). +assert(gv_color(x11,mediumpurple)). +assert(gv_color(x11,mediumpurple1)). +assert(gv_color(x11,mediumpurple2)). +assert(gv_color(x11,mediumpurple3)). +assert(gv_color(x11,mediumpurple4)). +assert(gv_color(x11,mediumseagreen)). +assert(gv_color(x11,mediumslateblue)). +assert(gv_color(x11,mediumspringgreen)). +assert(gv_color(x11,mediumturquoise)). +assert(gv_color(x11,mediumvioletred)). +assert(gv_color(x11,midnightblue)). +assert(gv_color(x11,mintcream)). +assert(gv_color(x11,mistyrose)). +assert(gv_color(x11,mistyrose1)). +assert(gv_color(x11,mistyrose2)). +assert(gv_color(x11,mistyrose3)). +assert(gv_color(x11,mistyrose4)). +assert(gv_color(x11,moccasin)). +assert(gv_color(x11,navajowhite)). +assert(gv_color(x11,navajowhite1)). +assert(gv_color(x11,navajowhite2)). +assert(gv_color(x11,navajowhite3)). +assert(gv_color(x11,navajowhite4)). +assert(gv_color(x11,navy)). +assert(gv_color(x11,navyblue)). +assert(gv_color(x11,none)). +assert(gv_color(x11,oldlace)). +assert(gv_color(x11,olivedrab)). +assert(gv_color(x11,olivedrab1)). +assert(gv_color(x11,olivedrab2)). +assert(gv_color(x11,olivedrab3)). +assert(gv_color(x11,olivedrab4)). +assert(gv_color(x11,orange)). +assert(gv_color(x11,orange1)). +assert(gv_color(x11,orange2)). +assert(gv_color(x11,orange3)). +assert(gv_color(x11,orange4)). +assert(gv_color(x11,orangered)). +assert(gv_color(x11,orangered1)). +assert(gv_color(x11,orangered2)). +assert(gv_color(x11,orangered3)). +assert(gv_color(x11,orangered4)). +assert(gv_color(x11,orchid)). +assert(gv_color(x11,orchid1)). +assert(gv_color(x11,orchid2)). +assert(gv_color(x11,orchid3)). +assert(gv_color(x11,orchid4)). +assert(gv_color(x11,palegoldenrod)). +assert(gv_color(x11,palegreen)). +assert(gv_color(x11,palegreen1)). +assert(gv_color(x11,palegreen2)). +assert(gv_color(x11,palegreen3)). +assert(gv_color(x11,palegreen4)). +assert(gv_color(x11,paleturquoise)). +assert(gv_color(x11,paleturquoise1)). +assert(gv_color(x11,paleturquoise2)). +assert(gv_color(x11,paleturquoise3)). +assert(gv_color(x11,paleturquoise4)). +assert(gv_color(x11,palevioletred)). +assert(gv_color(x11,palevioletred1)). +assert(gv_color(x11,palevioletred2)). +assert(gv_color(x11,palevioletred3)). +assert(gv_color(x11,palevioletred4)). +assert(gv_color(x11,papayawhip)). +assert(gv_color(x11,peachpuff)). +assert(gv_color(x11,peachpuff1)). +assert(gv_color(x11,peachpuff2)). +assert(gv_color(x11,peachpuff3)). +assert(gv_color(x11,peachpuff4)). +assert(gv_color(x11,peru)). +assert(gv_color(x11,pink)). +assert(gv_color(x11,pink1)). +assert(gv_color(x11,pink2)). +assert(gv_color(x11,pink3)). +assert(gv_color(x11,pink4)). +assert(gv_color(x11,plum)). +assert(gv_color(x11,plum1)). +assert(gv_color(x11,plum2)). +assert(gv_color(x11,plum3)). +assert(gv_color(x11,plum4)). +assert(gv_color(x11,powderblue)). +assert(gv_color(x11,purple)). +assert(gv_color(x11,purple1)). +assert(gv_color(x11,purple2)). +assert(gv_color(x11,purple3)). +assert(gv_color(x11,purple4)). +assert(gv_color(x11,red)). +assert(gv_color(x11,red1)). +assert(gv_color(x11,red2)). +assert(gv_color(x11,red3)). +assert(gv_color(x11,red4)). +assert(gv_color(x11,rosybrown)). +assert(gv_color(x11,rosybrown1)). +assert(gv_color(x11,rosybrown2)). +assert(gv_color(x11,rosybrown3)). +assert(gv_color(x11,rosybrown4)). +assert(gv_color(x11,royalblue)). +assert(gv_color(x11,royalblue1)). +assert(gv_color(x11,royalblue2)). +assert(gv_color(x11,royalblue3)). +assert(gv_color(x11,royalblue4)). +assert(gv_color(x11,saddlebrown)). +assert(gv_color(x11,salmon)). +assert(gv_color(x11,salmon1)). +assert(gv_color(x11,salmon2)). +assert(gv_color(x11,salmon3)). +assert(gv_color(x11,salmon4)). +assert(gv_color(x11,sandybrown)). +assert(gv_color(x11,seagreen)). +assert(gv_color(x11,seagreen1)). +assert(gv_color(x11,seagreen2)). +assert(gv_color(x11,seagreen3)). +assert(gv_color(x11,seagreen4)). +assert(gv_color(x11,seashell)). +assert(gv_color(x11,seashell1)). +assert(gv_color(x11,seashell2)). +assert(gv_color(x11,seashell3)). +assert(gv_color(x11,seashell4)). +assert(gv_color(x11,sienna)). +assert(gv_color(x11,sienna1)). +assert(gv_color(x11,sienna2)). +assert(gv_color(x11,sienna3)). +assert(gv_color(x11,sienna4)). +assert(gv_color(x11,skyblue)). +assert(gv_color(x11,skyblue1)). +assert(gv_color(x11,skyblue2)). +assert(gv_color(x11,skyblue3)). +assert(gv_color(x11,skyblue4)). +assert(gv_color(x11,slateblue)). +assert(gv_color(x11,slateblue1)). +assert(gv_color(x11,slateblue2)). +assert(gv_color(x11,slateblue3)). +assert(gv_color(x11,slateblue4)). +assert(gv_color(x11,slategray)). +assert(gv_color(x11,slategray1)). +assert(gv_color(x11,slategray2)). +assert(gv_color(x11,slategray3)). +assert(gv_color(x11,slategray4)). +assert(gv_color(x11,slategrey)). +assert(gv_color(x11,snow)). +assert(gv_color(x11,snow1)). +assert(gv_color(x11,snow2)). +assert(gv_color(x11,snow3)). +assert(gv_color(x11,snow4)). +assert(gv_color(x11,springgreen)). +assert(gv_color(x11,springgreen1)). +assert(gv_color(x11,springgreen2)). +assert(gv_color(x11,springgreen3)). +assert(gv_color(x11,springgreen4)). +assert(gv_color(x11,steelblue)). +assert(gv_color(x11,steelblue1)). +assert(gv_color(x11,steelblue2)). +assert(gv_color(x11,steelblue3)). +assert(gv_color(x11,steelblue4)). +assert(gv_color(x11,tan)). +assert(gv_color(x11,tan1)). +assert(gv_color(x11,tan2)). +assert(gv_color(x11,tan3)). +assert(gv_color(x11,tan4)). +assert(gv_color(x11,thistle)). +assert(gv_color(x11,thistle1)). +assert(gv_color(x11,thistle2)). +assert(gv_color(x11,thistle3)). +assert(gv_color(x11,thistle4)). +assert(gv_color(x11,tomato)). +assert(gv_color(x11,tomato1)). +assert(gv_color(x11,tomato2)). +assert(gv_color(x11,tomato3)). +assert(gv_color(x11,tomato4)). +assert(gv_color(x11,transparent)). +assert(gv_color(x11,turquoise)). +assert(gv_color(x11,turquoise1)). +assert(gv_color(x11,turquoise2)). +assert(gv_color(x11,turquoise3)). +assert(gv_color(x11,turquoise4)). +assert(gv_color(x11,violet)). +assert(gv_color(x11,violetred)). +assert(gv_color(x11,violetred1)). +assert(gv_color(x11,violetred2)). +assert(gv_color(x11,violetred3)). +assert(gv_color(x11,violetred4)). +assert(gv_color(x11,wheat)). +assert(gv_color(x11,wheat1)). +assert(gv_color(x11,wheat2)). +assert(gv_color(x11,wheat3)). +assert(gv_color(x11,wheat4)). +assert(gv_color(x11,white)). +assert(gv_color(x11,whitesmoke)). +assert(gv_color(x11,yellow)). +assert(gv_color(x11,yellow1)). +assert(gv_color(x11,yellow2)). +assert(gv_color(x11,yellow3)). +assert(gv_color(x11,yellow4)). +assert(gv_color(x11,yellowgreen)). +assert(gv_color(svg,aliceblue)). +assert(gv_color(svg,antiquewhite)). +assert(gv_color(svg,aqua)). +assert(gv_color(svg,aquamarine)). +assert(gv_color(svg,azure)). +assert(gv_color(svg,beige)). +assert(gv_color(svg,bisque)). +assert(gv_color(svg,black)). +assert(gv_color(svg,blanchedalmond)). +assert(gv_color(svg,blue)). +assert(gv_color(svg,blueviolet)). +assert(gv_color(svg,brown)). +assert(gv_color(svg,burlywood)). +assert(gv_color(svg,cadetblue)). +assert(gv_color(svg,chartreuse)). +assert(gv_color(svg,chocolate)). +assert(gv_color(svg,coral)). +assert(gv_color(svg,cornflowerblue)). +assert(gv_color(svg,cornsilk)). +assert(gv_color(svg,crimson)). +assert(gv_color(svg,cyan)). +assert(gv_color(svg,darkblue)). +assert(gv_color(svg,darkcyan)). +assert(gv_color(svg,darkgoldenrod)). +assert(gv_color(svg,darkgray)). +assert(gv_color(svg,darkgreen)). +assert(gv_color(svg,darkgrey)). +assert(gv_color(svg,darkkhaki)). +assert(gv_color(svg,darkmagenta)). +assert(gv_color(svg,darkolivegreen)). +assert(gv_color(svg,darkorange)). +assert(gv_color(svg,darkorchid)). +assert(gv_color(svg,darkred)). +assert(gv_color(svg,darksalmon)). +assert(gv_color(svg,darkseagreen)). +assert(gv_color(svg,darkslateblue)). +assert(gv_color(svg,darkslategray)). +assert(gv_color(svg,darkslategrey)). +assert(gv_color(svg,darkturquoise)). +assert(gv_color(svg,darkviolet)). +assert(gv_color(svg,deeppink)). +assert(gv_color(svg,deepskyblue)). +assert(gv_color(svg,dimgray)). +assert(gv_color(svg,dimgrey)). +assert(gv_color(svg,dodgerblue)). +assert(gv_color(svg,firebrick)). +assert(gv_color(svg,floralwhite)). +assert(gv_color(svg,forestgreen)). +assert(gv_color(svg,fuchsia)). +assert(gv_color(svg,gainsboro)). +assert(gv_color(svg,ghostwhite)). +assert(gv_color(svg,gold)). +assert(gv_color(svg,goldenrod)). +assert(gv_color(svg,gray)). +assert(gv_color(svg,grey)). +assert(gv_color(svg,green)). +assert(gv_color(svg,greenyellow)). +assert(gv_color(svg,honeydew)). +assert(gv_color(svg,hotpink)). +assert(gv_color(svg,indianred)). +assert(gv_color(svg,indigo)). +assert(gv_color(svg,ivory)). +assert(gv_color(svg,khaki)). +assert(gv_color(svg,lavender)). +assert(gv_color(svg,lavenderblush)). +assert(gv_color(svg,lawngreen)). +assert(gv_color(svg,lemonchiffon)). +assert(gv_color(svg,lightblue)). +assert(gv_color(svg,lightcoral)). +assert(gv_color(svg,lightcyan)). +assert(gv_color(svg,lightgoldenrodyellow)). +assert(gv_color(svg,lightgray)). +assert(gv_color(svg,lightgreen)). +assert(gv_color(svg,lightgrey)). +assert(gv_color(svg,lightpink)). +assert(gv_color(svg,lightsalmon)). +assert(gv_color(svg,lightseagreen)). +assert(gv_color(svg,lightskyblue)). +assert(gv_color(svg,lightslategray)). +assert(gv_color(svg,lightslategrey)). +assert(gv_color(svg,lightsteelblue)). +assert(gv_color(svg,lightyellow)). +assert(gv_color(svg,lime)). +assert(gv_color(svg,limegreen)). +assert(gv_color(svg,linen)). +assert(gv_color(svg,magenta)). +assert(gv_color(svg,maroon)). +assert(gv_color(svg,mediumaquamarine)). +assert(gv_color(svg,mediumblue)). +assert(gv_color(svg,mediumorchid)). +assert(gv_color(svg,mediumpurple)). +assert(gv_color(svg,mediumseagreen)). +assert(gv_color(svg,mediumslateblue)). +assert(gv_color(svg,mediumspringgreen)). +assert(gv_color(svg,mediumturquoise)). +assert(gv_color(svg,mediumvioletred)). +assert(gv_color(svg,midnightblue)). +assert(gv_color(svg,mintcream)). +assert(gv_color(svg,mistyrose)). +assert(gv_color(svg,moccasin)). +assert(gv_color(svg,navajowhite)). +assert(gv_color(svg,navy)). +assert(gv_color(svg,oldlace)). +assert(gv_color(svg,olive)). +assert(gv_color(svg,olivedrab)). +assert(gv_color(svg,orange)). +assert(gv_color(svg,orangered)). +assert(gv_color(svg,orchid)). +assert(gv_color(svg,palegoldenrod)). +assert(gv_color(svg,palegreen)). +assert(gv_color(svg,paleturquoise)). +assert(gv_color(svg,palevioletred)). +assert(gv_color(svg,papayawhip)). +assert(gv_color(svg,peachpuff)). +assert(gv_color(svg,peru)). +assert(gv_color(svg,pink)). +assert(gv_color(svg,plum)). +assert(gv_color(svg,powderblue)). +assert(gv_color(svg,purple)). +assert(gv_color(svg,red)). +assert(gv_color(svg,rosybrown)). +assert(gv_color(svg,royalblue)). +assert(gv_color(svg,saddlebrown)). +assert(gv_color(svg,salmon)). +assert(gv_color(svg,sandybrown)). +assert(gv_color(svg,seagreen)). +assert(gv_color(svg,seashell)). +assert(gv_color(svg,sienna)). +assert(gv_color(svg,silver)). +assert(gv_color(svg,skyblue)). +assert(gv_color(svg,slateblue)). +assert(gv_color(svg,slategray)). +assert(gv_color(svg,slategrey)). +assert(gv_color(svg,snow)). +assert(gv_color(svg,springgreen)). +assert(gv_color(svg,steelblue)). +assert(gv_color(svg,tan)). +assert(gv_color(svg,teal)). +assert(gv_color(svg,thistle)). +assert(gv_color(svg,tomato)). +assert(gv_color(svg,turquoise)). +assert(gv_color(svg,violet)). +assert(gv_color(svg,wheat)). +assert(gv_color(svg,white)). +assert(gv_color(svg,whitesmoke)). +assert(gv_color(svg,yellow)). +assert(gv_color(svg,yellowgreen)). ```

116: 正在比较变动前 65f43b8 和变动后 c6de3d1

[back to content](#compare) ``` diff diff --git a/.gitignore b/.gitignore index 7193a38..bd24270 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ *~ *# *.db -data/* diff --git a/pack.pl b/pack.pl index dfee09c..edfd45f 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.14'). +version('0.0.15'). diff --git a/prolog/gv/gv_attrs.pl b/prolog/gv/gv_attrs.pl index 5d97cb1..fa00670 100644 --- a/prolog/gv/gv_attrs.pl +++ b/prolog/gv/gv_attrs.pl @@ -9,7 +9,7 @@ /** GraphViz attributes @author Wouter Beek -@version 2015/07 +@version 2015/07-2015/08 */ :- use_module(library(apply)). @@ -17,10 +17,10 @@ :- use_module(library(dcg/basics)). :- use_module(library(dcg/dcg_call)). :- use_module(library(dcg/dcg_phrase)). -:- use_module(library(file_ext)). :- use_module(library(gv/gv_attr_type), [gv_attr_type//1]). -:- use_module(library(html/html_download)). +:- use_module(library(http/http_download)). :- use_module(library(lists)). +:- use_module(library(os/file_ext)). :- use_module(library(persistency)). :- use_module(library(xpath)). :- use_module(library(xpath/xpath_table)). diff --git a/gv_color.log b/prolog/gv/gv_color.log similarity index 100% rename from gv_color.log rename to prolog/gv/gv_color.log diff --git a/prolog/gv/gv_color.pl b/prolog/gv/gv_color.pl index d6eb478..57c7f90 100644 --- a/prolog/gv/gv_color.pl +++ b/prolog/gv/gv_color.pl @@ -21,9 +21,9 @@ :- use_module(library(dcg/basics)). :- use_module(library(dcg/dcg_abnf)). :- use_module(library(dcg/dcg_content)). -:- use_module(library(file_ext)). -:- use_module(library(html/html_download)). +:- use_module(library(http/http_download)). :- use_module(library(lists)). +:- use_module(library(os/file_ext)). :- use_module(library(persistency)). :- use_module(library(xpath)). :- use_module(library(xpath/xpath_table)). diff --git a/prolog/gv/gv_graph_comp.pl b/prolog/gv/gv_graph_comp.pl index 930fb32..18cdf7a 100644 --- a/prolog/gv/gv_graph_comp.pl +++ b/prolog/gv/gv_graph_comp.pl @@ -11,7 +11,7 @@ gv_node_statement//2, % +Indent:nonneg % +Vertex:compound gv_ranked_node_collection//2 % +Indent:nonneg - % +Rank:??? + % +Rank ] ). @@ -26,7 +26,7 @@ a_list = ID "=" ID [","] [a_list] @author Wouter Beek @see http://www.graphviz.org/content/dot-language -@version 2015/07 +@version 2015/07-2015/08 */ :- use_module(library(apply)). @@ -68,7 +68,7 @@ gv_edge_statement(I, Dir, edge(From,To,Attrs)) --> gv_node_id(From), " ", gv_edge_operator(Dir), " ", gv_node_id(To), " ", - + % We want `colorscheme/1` from the edges and % `directionality/1` from the graph. gv_attrs(edge, Attrs), @@ -130,7 +130,7 @@ gv_node_statement(I, vertex(Id,Attrs)) --> -%! gv_ranked_node_collection(+Indent:nonneg, Rank:???)// is det. +%! gv_ranked_node_collection(+Indent:nonneg, Rank)// is det. gv_ranked_node_collection(I, Rank) --> indent(I), @@ -138,20 +138,20 @@ gv_ranked_node_collection(I, Rank) --> gv_ranked_node_collection0(I, rank(Rank_V_Term,Content_V_Terms)) --> "\n", - + % The rank attribute. {NewI is I + 1}, indent(NewI), gv_attr(subgraph, rank=same), ";\n", - + % Vertice statements. '*'( gv_node_statement(NewI), [Rank_V_Term|Content_V_Terms], [] ), - + % We want to indent the closing curly brace. indent(I), "\n". diff --git a/gv_attrs.log b/test/gv_attrs.log similarity index 100% rename from gv_attrs.log rename to test/gv_attrs.log ```

117: 正在比较变动前 c6de3d1 和变动后 cab2231

[back to content](#compare) ``` diff diff --git a/gv_attrs.log b/gv_attrs.log new file mode 100644 index 0000000..a9c6010 --- /dev/null +++ b/gv_attrs.log @@ -0,0 +1,169 @@ +assert(gv_attr('Damping',[graph],[double],'0.99','0.0','neato only')). +assert(gv_attr('K',[cluster,graph],[double],'0.3','0','sfdp, fdp only')). +assert(gv_attr('URL',[cluster,edge,graph,node],[escString],_,'','svg, postscript, map only')). +assert(gv_attr('_background',[graph],[string],_,'','')). +assert(gv_attr(area,[cluster,node],[double],'1.0','>0','patchwork only')). +assert(gv_attr(arrowhead,[edge],[arrowType],normal,'','')). +assert(gv_attr(arrowsize,[edge],[double],'1.0','0.0','')). +assert(gv_attr(arrowtail,[edge],[arrowType],normal,'','')). +assert(gv_attr(bb,[graph],[rect],'','','write only')). +assert(gv_attr(bgcolor,[cluster,graph],[color,colorList],_,'','')). +assert(gv_attr(center,[graph],[bool],false,'','')). +assert(gv_attr(charset,[graph],[string],'"UTF-8"','','')). +assert(gv_attr(clusterrank,[graph],[clusterMode],local,'','dot only')). +assert(gv_attr(color,[cluster,edge,node],[color,colorList],black,'','')). +assert(gv_attr(colorscheme,[cluster,edge,graph,node],[string],'','','')). +assert(gv_attr(comment,[edge,graph,node],[string],'','','')). +assert(gv_attr(compound,[graph],[bool],false,'','dot only')). +assert(gv_attr(concentrate,[graph],[bool],false,'','')). +assert(gv_attr(constraint,[edge],[bool],true,'','dot only')). +assert(gv_attr(decorate,[edge],[bool],false,'','')). +assert(gv_attr(defaultdist,[graph],[double],'1+(avg. len)*sqrt(|V|)',epsilon,'neato only')). +assert(gv_attr(dim,[graph],[int],'2','2','sfdp, fdp, neato only')). +assert(gv_attr(dimen,[graph],[int],'2','2','sfdp, fdp, neato only')). +assert(gv_attr(dir,[edge],[dirType],'forward(directed)none(undirected)','','')). +assert(gv_attr(diredgeconstraints,[graph],[string,bool],false,'','neato only')). +assert(gv_attr(distortion,[node],[double],'0.0','-100.0','')). +assert(gv_attr(dpi,[graph],[double],'96.00.0','','svg, bitmap output only')). +assert(gv_attr(edgeURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(edgehref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(edgetarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(edgetooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(epsilon,[graph],[double],'.0001 * # nodes(mode == KK).0001(mode == major)','','neato only')). +assert(gv_attr(esep,[graph],[addDouble,addPoint],'+3','','not dot')). +assert(gv_attr(fillcolor,[cluster,edge,node],[color,colorList],'lightgrey(nodes)black(clusters)','','')). +assert(gv_attr(fixedsize,[node],[bool,string],false,'','')). +assert(gv_attr(fontcolor,[cluster,edge,graph,node],[color],black,'','')). +assert(gv_attr(fontname,[cluster,edge,graph,node],[string],'"Times-Roman"','','')). +assert(gv_attr(fontnames,[graph],[string],'','','svg only')). +assert(gv_attr(fontpath,[graph],[string],'system-dependent','','')). +assert(gv_attr(fontsize,[cluster,edge,graph,node],[double],'14.0','1.0','')). +assert(gv_attr(forcelabels,[graph],[bool],true,'','')). +assert(gv_attr(gradientangle,[cluster,graph,node],[int],'','','')). +assert(gv_attr(group,[node],[string],'','','dot only')). +assert(gv_attr(headURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(head_lp,[edge],[point],'','','write only')). +assert(gv_attr(headclip,[edge],[bool],true,'','')). +assert(gv_attr(headhref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(headlabel,[edge],[lblString],'','','')). +assert(gv_attr(headport,[edge],[portPos],center,'','')). +assert(gv_attr(headtarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(headtooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(height,[node],[double],'0.5','0.02','')). +assert(gv_attr(href,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only')). +assert(gv_attr(id,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only')). +assert(gv_attr(image,[node],[string],'','','')). +assert(gv_attr(imagepath,[graph],[string],'','','')). +assert(gv_attr(imagescale,[node],[bool,string],false,'','')). +assert(gv_attr(inputscale,[graph],[double],_,'','fdp, neato only')). +assert(gv_attr(label,[cluster,edge,graph,node],[lblString],'"\\N" (nodes)"" (otherwise)','','')). +assert(gv_attr(labelURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(label_scheme,[graph],[int],'0','0','sfdp only')). +assert(gv_attr(labelangle,[edge],[double],'-25.0','-180.0','')). +assert(gv_attr(labeldistance,[edge],[double],'1.0','0.0','')). +assert(gv_attr(labelfloat,[edge],[bool],false,'','')). +assert(gv_attr(labelfontcolor,[edge],[color],black,'','')). +assert(gv_attr(labelfontname,[edge],[string],'"Times-Roman"','','')). +assert(gv_attr(labelfontsize,[edge],[double],'14.0','1.0','')). +assert(gv_attr(labelhref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(labeljust,[cluster,graph],[string],'"c"','','')). +assert(gv_attr(labelloc,[cluster,graph,node],[string],'"t"(clusters)"b"(root graphs)"c"(nodes)','','')). +assert(gv_attr(labeltarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(labeltooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(landscape,[graph],[bool],false,'','')). +assert(gv_attr(layer,[cluster,edge,node],[layerRange],'','','')). +assert(gv_attr(layerlistsep,[graph],[string],'","','','')). +assert(gv_attr(layers,[graph],[layerList],'','','')). +assert(gv_attr(layerselect,[graph],[layerRange],'','','')). +assert(gv_attr(layersep,[graph],[string],'" :\\t"','','')). +assert(gv_attr(layout,[graph],[string],'','','')). +assert(gv_attr(len,[edge],[double],'1.0(neato)0.3(fdp)','','fdp, neato only')). +assert(gv_attr(levels,[graph],[int],'MAXINT','0.0','sfdp only')). +assert(gv_attr(levelsgap,[graph],[double],'0.0','','neato only')). +assert(gv_attr(lhead,[edge],[string],'','','dot only')). +assert(gv_attr(lheight,[cluster,graph],[double],'','','write only')). +assert(gv_attr(lp,[cluster,edge,graph],[point],'','','write only')). +assert(gv_attr(ltail,[edge],[string],'','','dot only')). +assert(gv_attr(lwidth,[cluster,graph],[double],'','','write only')). +assert(gv_attr(margin,[cluster,graph,node],[double,point],'','','')). +assert(gv_attr(maxiter,[graph],[int],'100 * # nodes(mode == KK)200(mode == major)600(fdp)','','fdp, neato only')). +assert(gv_attr(mclimit,[graph],[double],'1.0','','dot only')). +assert(gv_attr(mindist,[graph],[double],'1.0','0.0','circo only')). +assert(gv_attr(minlen,[edge],[int],'1','0','dot only')). +assert(gv_attr(mode,[graph],[string],major,'','neato only')). +assert(gv_attr(model,[graph],[string],shortpath,'','neato only')). +assert(gv_attr(mosek,[graph],[bool],false,'','neato only')). +assert(gv_attr(nodesep,[graph],[double],'0.25','0.02','')). +assert(gv_attr(nojustify,[cluster,edge,graph,node],[bool],false,'','')). +assert(gv_attr(normalize,[graph],[double,bool],false,'','not dot')). +assert(gv_attr(notranslate,[graph],[bool],false,'','neato only')). +assert(gv_attr('nslimit nslimit1',[graph],[double],'','','dot only')). +assert(gv_attr(ordering,[graph,node],[string],'','','dot only')). +assert(gv_attr(orientation,[node],[double],'0.0','360.0','')). +assert(gv_attr(orientation,[graph],[string],'','','')). +assert(gv_attr(outputorder,[graph],[outputMode],breadthfirst,'','')). +assert(gv_attr(overlap,[graph],[string,bool],true,'','not dot')). +assert(gv_attr(overlap_scaling,[graph],[double],'-4','-1.0e10','prism only')). +assert(gv_attr(overlap_shrink,[graph],[bool],true,'','prism only')). +assert(gv_attr(pack,[graph],[bool,int],false,'','')). +assert(gv_attr(packmode,[graph],[packMode],node,'','')). +assert(gv_attr(pad,[graph],[double,point],'0.0555 (4 points)','','')). +assert(gv_attr(page,[graph],[double,point],'','','')). +assert(gv_attr(pagedir,[graph],[pagedir],'BL','','')). +assert(gv_attr(pencolor,[cluster],[color],black,'','')). +assert(gv_attr(penwidth,[cluster,edge,node],[double],'1.0','0.0','')). +assert(gv_attr(peripheries,[cluster,node],[int],'shape default(nodes)1(clusters)','0','')). +assert(gv_attr(pin,[node],[bool],false,'','fdp, neato only')). +assert(gv_attr(pos,[edge,node],[point,splineType],'','','')). +assert(gv_attr(quadtree,[graph],[quadType,bool],normal,'','sfdp only')). +assert(gv_attr(quantum,[graph],[double],'0.0','0.0','')). +assert(gv_attr(rank,[subgraph],[rankType],'','','dot only')). +assert(gv_attr(rankdir,[graph],[rankdir],'TB','','dot only')). +assert(gv_attr(ranksep,[graph],[double,doubleList],'0.5(dot)1.0(twopi)','0.02','twopi, dot only')). +assert(gv_attr(ratio,[graph],[double,string],'','','')). +assert(gv_attr(rects,[node],[rect],'','','write only')). +assert(gv_attr(regular,[node],[bool],false,'','')). +assert(gv_attr(remincross,[graph],[bool],true,'','dot only')). +assert(gv_attr(repulsiveforce,[graph],[double],'1.0','0.0','sfdp only')). +assert(gv_attr(resolution,[graph],[double],'96.00.0','','svg, bitmap output only')). +assert(gv_attr(root,[graph,node],[string,bool],'(graphs)false(nodes)','','circo, twopi only')). +assert(gv_attr(rotate,[graph],[int],'0','','')). +assert(gv_attr(rotation,[graph],[double],'0','','sfdp only')). +assert(gv_attr(samehead,[edge],[string],'','','dot only')). +assert(gv_attr(sametail,[edge],[string],'','','dot only')). +assert(gv_attr(samplepoints,[node],[int],'8(output)20(overlap and image maps)','','')). +assert(gv_attr(scale,[graph],[double,point],'','','not dot')). +assert(gv_attr(searchsize,[graph],[int],'30','','dot only')). +assert(gv_attr(sep,[graph],[addDouble,addPoint],'+4','','not dot')). +assert(gv_attr(shape,[node],[shape],ellipse,'','')). +assert(gv_attr(shapefile,[node],[string],'','','')). +assert(gv_attr(showboxes,[edge,graph,node],[int],'0','0','dot only')). +assert(gv_attr(sides,[node],[int],'4','0','')). +assert(gv_attr(size,[graph],[double,point],'','','')). +assert(gv_attr(skew,[node],[double],'0.0','-100.0','')). +assert(gv_attr(smoothing,[graph],[smoothType],'"none"','','sfdp only')). +assert(gv_attr(sortv,[cluster,graph,node],[int],'0','0','')). +assert(gv_attr(splines,[graph],[bool,string],'','','')). +assert(gv_attr(start,[graph],[startType],'','','fdp, neato only')). +assert(gv_attr(style,[cluster,edge,graph,node],[style],'','','')). +assert(gv_attr(stylesheet,[graph],[string],'','','svg only')). +assert(gv_attr(tailURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(tail_lp,[edge],[point],'','','write only')). +assert(gv_attr(tailclip,[edge],[bool],true,'','')). +assert(gv_attr(tailhref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(taillabel,[edge],[lblString],'','','')). +assert(gv_attr(tailport,[edge],[portPos],center,'','')). +assert(gv_attr(tailtarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(tailtooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(target,[cluster,edge,graph,node],[escString,string],_,'','svg, map only')). +assert(gv_attr(tooltip,[cluster,edge,node],[escString],'','','svg, cmap only')). +assert(gv_attr(truecolor,[graph],[bool],'','','bitmap output only')). +assert(gv_attr(vertices,[node],[pointList],'','','write only')). +assert(gv_attr(viewport,[graph],[viewPort],'','','')). +assert(gv_attr(voro_margin,[graph],[double],'0.05','0.0','not dot')). +assert(gv_attr(weight,[edge],[int,double],'1','0(dot,twopi)1(neato,fdp)','')). +assert(gv_attr(width,[node],[double],'0.75','0.01','')). +assert(gv_attr(xdotversion,[graph],[string],'','','xdot only')). +assert(gv_attr(xlabel,[edge,node],[lblString],'','','')). +assert(gv_attr(xlp,[edge,node],[point],'','','write only')). +assert(gv_attr(z,[node],[double],'0.0','-MAXFLOAT-1000','')). diff --git a/gv_color.log b/gv_color.log new file mode 100644 index 0000000..23d6cdf --- /dev/null +++ b/gv_color.log @@ -0,0 +1,802 @@ +assert(gv_color(x11,aliceblue)). +assert(gv_color(x11,antiquewhite)). +assert(gv_color(x11,antiquewhite1)). +assert(gv_color(x11,antiquewhite2)). +assert(gv_color(x11,antiquewhite3)). +assert(gv_color(x11,antiquewhite4)). +assert(gv_color(x11,aquamarine)). +assert(gv_color(x11,aquamarine1)). +assert(gv_color(x11,aquamarine2)). +assert(gv_color(x11,aquamarine3)). +assert(gv_color(x11,aquamarine4)). +assert(gv_color(x11,azure)). +assert(gv_color(x11,azure1)). +assert(gv_color(x11,azure2)). +assert(gv_color(x11,azure3)). +assert(gv_color(x11,azure4)). +assert(gv_color(x11,beige)). +assert(gv_color(x11,bisque)). +assert(gv_color(x11,bisque1)). +assert(gv_color(x11,bisque2)). +assert(gv_color(x11,bisque3)). +assert(gv_color(x11,bisque4)). +assert(gv_color(x11,black)). +assert(gv_color(x11,blanchedalmond)). +assert(gv_color(x11,blue)). +assert(gv_color(x11,blue1)). +assert(gv_color(x11,blue2)). +assert(gv_color(x11,blue3)). +assert(gv_color(x11,blue4)). +assert(gv_color(x11,blueviolet)). +assert(gv_color(x11,brown)). +assert(gv_color(x11,brown1)). +assert(gv_color(x11,brown2)). +assert(gv_color(x11,brown3)). +assert(gv_color(x11,brown4)). +assert(gv_color(x11,burlywood)). +assert(gv_color(x11,burlywood1)). +assert(gv_color(x11,burlywood2)). +assert(gv_color(x11,burlywood3)). +assert(gv_color(x11,burlywood4)). +assert(gv_color(x11,cadetblue)). +assert(gv_color(x11,cadetblue1)). +assert(gv_color(x11,cadetblue2)). +assert(gv_color(x11,cadetblue3)). +assert(gv_color(x11,cadetblue4)). +assert(gv_color(x11,chartreuse)). +assert(gv_color(x11,chartreuse1)). +assert(gv_color(x11,chartreuse2)). +assert(gv_color(x11,chartreuse3)). +assert(gv_color(x11,chartreuse4)). +assert(gv_color(x11,chocolate)). +assert(gv_color(x11,chocolate1)). +assert(gv_color(x11,chocolate2)). +assert(gv_color(x11,chocolate3)). +assert(gv_color(x11,chocolate4)). +assert(gv_color(x11,coral)). +assert(gv_color(x11,coral1)). +assert(gv_color(x11,coral2)). +assert(gv_color(x11,coral3)). +assert(gv_color(x11,coral4)). +assert(gv_color(x11,cornflowerblue)). +assert(gv_color(x11,cornsilk)). +assert(gv_color(x11,cornsilk1)). +assert(gv_color(x11,cornsilk2)). +assert(gv_color(x11,cornsilk3)). +assert(gv_color(x11,cornsilk4)). +assert(gv_color(x11,crimson)). +assert(gv_color(x11,cyan)). +assert(gv_color(x11,cyan1)). +assert(gv_color(x11,cyan2)). +assert(gv_color(x11,cyan3)). +assert(gv_color(x11,cyan4)). +assert(gv_color(x11,darkgoldenrod)). +assert(gv_color(x11,darkgoldenrod1)). +assert(gv_color(x11,darkgoldenrod2)). +assert(gv_color(x11,darkgoldenrod3)). +assert(gv_color(x11,darkgoldenrod4)). +assert(gv_color(x11,darkgreen)). +assert(gv_color(x11,darkkhaki)). +assert(gv_color(x11,darkolivegreen)). +assert(gv_color(x11,darkolivegreen1)). +assert(gv_color(x11,darkolivegreen2)). +assert(gv_color(x11,darkolivegreen3)). +assert(gv_color(x11,darkolivegreen4)). +assert(gv_color(x11,darkorange)). +assert(gv_color(x11,darkorange1)). +assert(gv_color(x11,darkorange2)). +assert(gv_color(x11,darkorange3)). +assert(gv_color(x11,darkorange4)). +assert(gv_color(x11,darkorchid)). +assert(gv_color(x11,darkorchid1)). +assert(gv_color(x11,darkorchid2)). +assert(gv_color(x11,darkorchid3)). +assert(gv_color(x11,darkorchid4)). +assert(gv_color(x11,darksalmon)). +assert(gv_color(x11,darkseagreen)). +assert(gv_color(x11,darkseagreen1)). +assert(gv_color(x11,darkseagreen2)). +assert(gv_color(x11,darkseagreen3)). +assert(gv_color(x11,darkseagreen4)). +assert(gv_color(x11,darkslateblue)). +assert(gv_color(x11,darkslategray)). +assert(gv_color(x11,darkslategray1)). +assert(gv_color(x11,darkslategray2)). +assert(gv_color(x11,darkslategray3)). +assert(gv_color(x11,darkslategray4)). +assert(gv_color(x11,darkslategrey)). +assert(gv_color(x11,darkturquoise)). +assert(gv_color(x11,darkviolet)). +assert(gv_color(x11,deeppink)). +assert(gv_color(x11,deeppink1)). +assert(gv_color(x11,deeppink2)). +assert(gv_color(x11,deeppink3)). +assert(gv_color(x11,deeppink4)). +assert(gv_color(x11,deepskyblue)). +assert(gv_color(x11,deepskyblue1)). +assert(gv_color(x11,deepskyblue2)). +assert(gv_color(x11,deepskyblue3)). +assert(gv_color(x11,deepskyblue4)). +assert(gv_color(x11,dimgray)). +assert(gv_color(x11,dimgrey)). +assert(gv_color(x11,dodgerblue)). +assert(gv_color(x11,dodgerblue1)). +assert(gv_color(x11,dodgerblue2)). +assert(gv_color(x11,dodgerblue3)). +assert(gv_color(x11,dodgerblue4)). +assert(gv_color(x11,firebrick)). +assert(gv_color(x11,firebrick1)). +assert(gv_color(x11,firebrick2)). +assert(gv_color(x11,firebrick3)). +assert(gv_color(x11,firebrick4)). +assert(gv_color(x11,floralwhite)). +assert(gv_color(x11,forestgreen)). +assert(gv_color(x11,gainsboro)). +assert(gv_color(x11,ghostwhite)). +assert(gv_color(x11,gold)). +assert(gv_color(x11,gold1)). +assert(gv_color(x11,gold2)). +assert(gv_color(x11,gold3)). +assert(gv_color(x11,gold4)). +assert(gv_color(x11,goldenrod)). +assert(gv_color(x11,goldenrod1)). +assert(gv_color(x11,goldenrod2)). +assert(gv_color(x11,goldenrod3)). +assert(gv_color(x11,goldenrod4)). +assert(gv_color(x11,gray)). +assert(gv_color(x11,gray0)). +assert(gv_color(x11,gray1)). +assert(gv_color(x11,gray10)). +assert(gv_color(x11,gray100)). +assert(gv_color(x11,gray11)). +assert(gv_color(x11,gray12)). +assert(gv_color(x11,gray13)). +assert(gv_color(x11,gray14)). +assert(gv_color(x11,gray15)). +assert(gv_color(x11,gray16)). +assert(gv_color(x11,gray17)). +assert(gv_color(x11,gray18)). +assert(gv_color(x11,gray19)). +assert(gv_color(x11,gray2)). +assert(gv_color(x11,gray20)). +assert(gv_color(x11,gray21)). +assert(gv_color(x11,gray22)). +assert(gv_color(x11,gray23)). +assert(gv_color(x11,gray24)). +assert(gv_color(x11,gray25)). +assert(gv_color(x11,gray26)). +assert(gv_color(x11,gray27)). +assert(gv_color(x11,gray28)). +assert(gv_color(x11,gray29)). +assert(gv_color(x11,gray3)). +assert(gv_color(x11,gray30)). +assert(gv_color(x11,gray31)). +assert(gv_color(x11,gray32)). +assert(gv_color(x11,gray33)). +assert(gv_color(x11,gray34)). +assert(gv_color(x11,gray35)). +assert(gv_color(x11,gray36)). +assert(gv_color(x11,gray37)). +assert(gv_color(x11,gray38)). +assert(gv_color(x11,gray39)). +assert(gv_color(x11,gray4)). +assert(gv_color(x11,gray40)). +assert(gv_color(x11,gray41)). +assert(gv_color(x11,gray42)). +assert(gv_color(x11,gray43)). +assert(gv_color(x11,gray44)). +assert(gv_color(x11,gray45)). +assert(gv_color(x11,gray46)). +assert(gv_color(x11,gray47)). +assert(gv_color(x11,gray48)). +assert(gv_color(x11,gray49)). +assert(gv_color(x11,gray5)). +assert(gv_color(x11,gray50)). +assert(gv_color(x11,gray51)). +assert(gv_color(x11,gray52)). +assert(gv_color(x11,gray53)). +assert(gv_color(x11,gray54)). +assert(gv_color(x11,gray55)). +assert(gv_color(x11,gray56)). +assert(gv_color(x11,gray57)). +assert(gv_color(x11,gray58)). +assert(gv_color(x11,gray59)). +assert(gv_color(x11,gray6)). +assert(gv_color(x11,gray60)). +assert(gv_color(x11,gray61)). +assert(gv_color(x11,gray62)). +assert(gv_color(x11,gray63)). +assert(gv_color(x11,gray64)). +assert(gv_color(x11,gray65)). +assert(gv_color(x11,gray66)). +assert(gv_color(x11,gray67)). +assert(gv_color(x11,gray68)). +assert(gv_color(x11,gray69)). +assert(gv_color(x11,gray7)). +assert(gv_color(x11,gray70)). +assert(gv_color(x11,gray71)). +assert(gv_color(x11,gray72)). +assert(gv_color(x11,gray73)). +assert(gv_color(x11,gray74)). +assert(gv_color(x11,gray75)). +assert(gv_color(x11,gray76)). +assert(gv_color(x11,gray77)). +assert(gv_color(x11,gray78)). +assert(gv_color(x11,gray79)). +assert(gv_color(x11,gray8)). +assert(gv_color(x11,gray80)). +assert(gv_color(x11,gray81)). +assert(gv_color(x11,gray82)). +assert(gv_color(x11,gray83)). +assert(gv_color(x11,gray84)). +assert(gv_color(x11,gray85)). +assert(gv_color(x11,gray86)). +assert(gv_color(x11,gray87)). +assert(gv_color(x11,gray88)). +assert(gv_color(x11,gray89)). +assert(gv_color(x11,gray9)). +assert(gv_color(x11,gray90)). +assert(gv_color(x11,gray91)). +assert(gv_color(x11,gray92)). +assert(gv_color(x11,gray93)). +assert(gv_color(x11,gray94)). +assert(gv_color(x11,gray95)). +assert(gv_color(x11,gray96)). +assert(gv_color(x11,gray97)). +assert(gv_color(x11,gray98)). +assert(gv_color(x11,gray99)). +assert(gv_color(x11,green)). +assert(gv_color(x11,green1)). +assert(gv_color(x11,green2)). +assert(gv_color(x11,green3)). +assert(gv_color(x11,green4)). +assert(gv_color(x11,greenyellow)). +assert(gv_color(x11,grey)). +assert(gv_color(x11,grey0)). +assert(gv_color(x11,grey1)). +assert(gv_color(x11,grey10)). +assert(gv_color(x11,grey100)). +assert(gv_color(x11,grey11)). +assert(gv_color(x11,grey12)). +assert(gv_color(x11,grey13)). +assert(gv_color(x11,grey14)). +assert(gv_color(x11,grey15)). +assert(gv_color(x11,grey16)). +assert(gv_color(x11,grey17)). +assert(gv_color(x11,grey18)). +assert(gv_color(x11,grey19)). +assert(gv_color(x11,grey2)). +assert(gv_color(x11,grey20)). +assert(gv_color(x11,grey21)). +assert(gv_color(x11,grey22)). +assert(gv_color(x11,grey23)). +assert(gv_color(x11,grey24)). +assert(gv_color(x11,grey25)). +assert(gv_color(x11,grey26)). +assert(gv_color(x11,grey27)). +assert(gv_color(x11,grey28)). +assert(gv_color(x11,grey29)). +assert(gv_color(x11,grey3)). +assert(gv_color(x11,grey30)). +assert(gv_color(x11,grey31)). +assert(gv_color(x11,grey32)). +assert(gv_color(x11,grey33)). +assert(gv_color(x11,grey34)). +assert(gv_color(x11,grey35)). +assert(gv_color(x11,grey36)). +assert(gv_color(x11,grey37)). +assert(gv_color(x11,grey38)). +assert(gv_color(x11,grey39)). +assert(gv_color(x11,grey4)). +assert(gv_color(x11,grey40)). +assert(gv_color(x11,grey41)). +assert(gv_color(x11,grey42)). +assert(gv_color(x11,grey43)). +assert(gv_color(x11,grey44)). +assert(gv_color(x11,grey45)). +assert(gv_color(x11,grey46)). +assert(gv_color(x11,grey47)). +assert(gv_color(x11,grey48)). +assert(gv_color(x11,grey49)). +assert(gv_color(x11,grey5)). +assert(gv_color(x11,grey50)). +assert(gv_color(x11,grey51)). +assert(gv_color(x11,grey52)). +assert(gv_color(x11,grey53)). +assert(gv_color(x11,grey54)). +assert(gv_color(x11,grey55)). +assert(gv_color(x11,grey56)). +assert(gv_color(x11,grey57)). +assert(gv_color(x11,grey58)). +assert(gv_color(x11,grey59)). +assert(gv_color(x11,grey6)). +assert(gv_color(x11,grey60)). +assert(gv_color(x11,grey61)). +assert(gv_color(x11,grey62)). +assert(gv_color(x11,grey63)). +assert(gv_color(x11,grey64)). +assert(gv_color(x11,grey65)). +assert(gv_color(x11,grey66)). +assert(gv_color(x11,grey67)). +assert(gv_color(x11,grey68)). +assert(gv_color(x11,grey69)). +assert(gv_color(x11,grey7)). +assert(gv_color(x11,grey70)). +assert(gv_color(x11,grey71)). +assert(gv_color(x11,grey72)). +assert(gv_color(x11,grey73)). +assert(gv_color(x11,grey74)). +assert(gv_color(x11,grey75)). +assert(gv_color(x11,grey76)). +assert(gv_color(x11,grey77)). +assert(gv_color(x11,grey78)). +assert(gv_color(x11,grey79)). +assert(gv_color(x11,grey8)). +assert(gv_color(x11,grey80)). +assert(gv_color(x11,grey81)). +assert(gv_color(x11,grey82)). +assert(gv_color(x11,grey83)). +assert(gv_color(x11,grey84)). +assert(gv_color(x11,grey85)). +assert(gv_color(x11,grey86)). +assert(gv_color(x11,grey87)). +assert(gv_color(x11,grey88)). +assert(gv_color(x11,grey89)). +assert(gv_color(x11,grey9)). +assert(gv_color(x11,grey90)). +assert(gv_color(x11,grey91)). +assert(gv_color(x11,grey92)). +assert(gv_color(x11,grey93)). +assert(gv_color(x11,grey94)). +assert(gv_color(x11,grey95)). +assert(gv_color(x11,grey96)). +assert(gv_color(x11,grey97)). +assert(gv_color(x11,grey98)). +assert(gv_color(x11,grey99)). +assert(gv_color(x11,honeydew)). +assert(gv_color(x11,honeydew1)). +assert(gv_color(x11,honeydew2)). +assert(gv_color(x11,honeydew3)). +assert(gv_color(x11,honeydew4)). +assert(gv_color(x11,hotpink)). +assert(gv_color(x11,hotpink1)). +assert(gv_color(x11,hotpink2)). +assert(gv_color(x11,hotpink3)). +assert(gv_color(x11,hotpink4)). +assert(gv_color(x11,indianred)). +assert(gv_color(x11,indianred1)). +assert(gv_color(x11,indianred2)). +assert(gv_color(x11,indianred3)). +assert(gv_color(x11,indianred4)). +assert(gv_color(x11,indigo)). +assert(gv_color(x11,invis)). +assert(gv_color(x11,ivory)). +assert(gv_color(x11,ivory1)). +assert(gv_color(x11,ivory2)). +assert(gv_color(x11,ivory3)). +assert(gv_color(x11,ivory4)). +assert(gv_color(x11,khaki)). +assert(gv_color(x11,khaki1)). +assert(gv_color(x11,khaki2)). +assert(gv_color(x11,khaki3)). +assert(gv_color(x11,khaki4)). +assert(gv_color(x11,lavender)). +assert(gv_color(x11,lavenderblush)). +assert(gv_color(x11,lavenderblush1)). +assert(gv_color(x11,lavenderblush2)). +assert(gv_color(x11,lavenderblush3)). +assert(gv_color(x11,lavenderblush4)). +assert(gv_color(x11,lawngreen)). +assert(gv_color(x11,lemonchiffon)). +assert(gv_color(x11,lemonchiffon1)). +assert(gv_color(x11,lemonchiffon2)). +assert(gv_color(x11,lemonchiffon3)). +assert(gv_color(x11,lemonchiffon4)). +assert(gv_color(x11,lightblue)). +assert(gv_color(x11,lightblue1)). +assert(gv_color(x11,lightblue2)). +assert(gv_color(x11,lightblue3)). +assert(gv_color(x11,lightblue4)). +assert(gv_color(x11,lightcoral)). +assert(gv_color(x11,lightcyan)). +assert(gv_color(x11,lightcyan1)). +assert(gv_color(x11,lightcyan2)). +assert(gv_color(x11,lightcyan3)). +assert(gv_color(x11,lightcyan4)). +assert(gv_color(x11,lightgoldenrod)). +assert(gv_color(x11,lightgoldenrod1)). +assert(gv_color(x11,lightgoldenrod2)). +assert(gv_color(x11,lightgoldenrod3)). +assert(gv_color(x11,lightgoldenrod4)). +assert(gv_color(x11,lightgoldenrodyellow)). +assert(gv_color(x11,lightgray)). +assert(gv_color(x11,lightgrey)). +assert(gv_color(x11,lightpink)). +assert(gv_color(x11,lightpink1)). +assert(gv_color(x11,lightpink2)). +assert(gv_color(x11,lightpink3)). +assert(gv_color(x11,lightpink4)). +assert(gv_color(x11,lightsalmon)). +assert(gv_color(x11,lightsalmon1)). +assert(gv_color(x11,lightsalmon2)). +assert(gv_color(x11,lightsalmon3)). +assert(gv_color(x11,lightsalmon4)). +assert(gv_color(x11,lightseagreen)). +assert(gv_color(x11,lightskyblue)). +assert(gv_color(x11,lightskyblue1)). +assert(gv_color(x11,lightskyblue2)). +assert(gv_color(x11,lightskyblue3)). +assert(gv_color(x11,lightskyblue4)). +assert(gv_color(x11,lightslateblue)). +assert(gv_color(x11,lightslategray)). +assert(gv_color(x11,lightslategrey)). +assert(gv_color(x11,lightsteelblue)). +assert(gv_color(x11,lightsteelblue1)). +assert(gv_color(x11,lightsteelblue2)). +assert(gv_color(x11,lightsteelblue3)). +assert(gv_color(x11,lightsteelblue4)). +assert(gv_color(x11,lightyellow)). +assert(gv_color(x11,lightyellow1)). +assert(gv_color(x11,lightyellow2)). +assert(gv_color(x11,lightyellow3)). +assert(gv_color(x11,lightyellow4)). +assert(gv_color(x11,limegreen)). +assert(gv_color(x11,linen)). +assert(gv_color(x11,magenta)). +assert(gv_color(x11,magenta1)). +assert(gv_color(x11,magenta2)). +assert(gv_color(x11,magenta3)). +assert(gv_color(x11,magenta4)). +assert(gv_color(x11,maroon)). +assert(gv_color(x11,maroon1)). +assert(gv_color(x11,maroon2)). +assert(gv_color(x11,maroon3)). +assert(gv_color(x11,maroon4)). +assert(gv_color(x11,mediumaquamarine)). +assert(gv_color(x11,mediumblue)). +assert(gv_color(x11,mediumorchid)). +assert(gv_color(x11,mediumorchid1)). +assert(gv_color(x11,mediumorchid2)). +assert(gv_color(x11,mediumorchid3)). +assert(gv_color(x11,mediumorchid4)). +assert(gv_color(x11,mediumpurple)). +assert(gv_color(x11,mediumpurple1)). +assert(gv_color(x11,mediumpurple2)). +assert(gv_color(x11,mediumpurple3)). +assert(gv_color(x11,mediumpurple4)). +assert(gv_color(x11,mediumseagreen)). +assert(gv_color(x11,mediumslateblue)). +assert(gv_color(x11,mediumspringgreen)). +assert(gv_color(x11,mediumturquoise)). +assert(gv_color(x11,mediumvioletred)). +assert(gv_color(x11,midnightblue)). +assert(gv_color(x11,mintcream)). +assert(gv_color(x11,mistyrose)). +assert(gv_color(x11,mistyrose1)). +assert(gv_color(x11,mistyrose2)). +assert(gv_color(x11,mistyrose3)). +assert(gv_color(x11,mistyrose4)). +assert(gv_color(x11,moccasin)). +assert(gv_color(x11,navajowhite)). +assert(gv_color(x11,navajowhite1)). +assert(gv_color(x11,navajowhite2)). +assert(gv_color(x11,navajowhite3)). +assert(gv_color(x11,navajowhite4)). +assert(gv_color(x11,navy)). +assert(gv_color(x11,navyblue)). +assert(gv_color(x11,none)). +assert(gv_color(x11,oldlace)). +assert(gv_color(x11,olivedrab)). +assert(gv_color(x11,olivedrab1)). +assert(gv_color(x11,olivedrab2)). +assert(gv_color(x11,olivedrab3)). +assert(gv_color(x11,olivedrab4)). +assert(gv_color(x11,orange)). +assert(gv_color(x11,orange1)). +assert(gv_color(x11,orange2)). +assert(gv_color(x11,orange3)). +assert(gv_color(x11,orange4)). +assert(gv_color(x11,orangered)). +assert(gv_color(x11,orangered1)). +assert(gv_color(x11,orangered2)). +assert(gv_color(x11,orangered3)). +assert(gv_color(x11,orangered4)). +assert(gv_color(x11,orchid)). +assert(gv_color(x11,orchid1)). +assert(gv_color(x11,orchid2)). +assert(gv_color(x11,orchid3)). +assert(gv_color(x11,orchid4)). +assert(gv_color(x11,palegoldenrod)). +assert(gv_color(x11,palegreen)). +assert(gv_color(x11,palegreen1)). +assert(gv_color(x11,palegreen2)). +assert(gv_color(x11,palegreen3)). +assert(gv_color(x11,palegreen4)). +assert(gv_color(x11,paleturquoise)). +assert(gv_color(x11,paleturquoise1)). +assert(gv_color(x11,paleturquoise2)). +assert(gv_color(x11,paleturquoise3)). +assert(gv_color(x11,paleturquoise4)). +assert(gv_color(x11,palevioletred)). +assert(gv_color(x11,palevioletred1)). +assert(gv_color(x11,palevioletred2)). +assert(gv_color(x11,palevioletred3)). +assert(gv_color(x11,palevioletred4)). +assert(gv_color(x11,papayawhip)). +assert(gv_color(x11,peachpuff)). +assert(gv_color(x11,peachpuff1)). +assert(gv_color(x11,peachpuff2)). +assert(gv_color(x11,peachpuff3)). +assert(gv_color(x11,peachpuff4)). +assert(gv_color(x11,peru)). +assert(gv_color(x11,pink)). +assert(gv_color(x11,pink1)). +assert(gv_color(x11,pink2)). +assert(gv_color(x11,pink3)). +assert(gv_color(x11,pink4)). +assert(gv_color(x11,plum)). +assert(gv_color(x11,plum1)). +assert(gv_color(x11,plum2)). +assert(gv_color(x11,plum3)). +assert(gv_color(x11,plum4)). +assert(gv_color(x11,powderblue)). +assert(gv_color(x11,purple)). +assert(gv_color(x11,purple1)). +assert(gv_color(x11,purple2)). +assert(gv_color(x11,purple3)). +assert(gv_color(x11,purple4)). +assert(gv_color(x11,red)). +assert(gv_color(x11,red1)). +assert(gv_color(x11,red2)). +assert(gv_color(x11,red3)). +assert(gv_color(x11,red4)). +assert(gv_color(x11,rosybrown)). +assert(gv_color(x11,rosybrown1)). +assert(gv_color(x11,rosybrown2)). +assert(gv_color(x11,rosybrown3)). +assert(gv_color(x11,rosybrown4)). +assert(gv_color(x11,royalblue)). +assert(gv_color(x11,royalblue1)). +assert(gv_color(x11,royalblue2)). +assert(gv_color(x11,royalblue3)). +assert(gv_color(x11,royalblue4)). +assert(gv_color(x11,saddlebrown)). +assert(gv_color(x11,salmon)). +assert(gv_color(x11,salmon1)). +assert(gv_color(x11,salmon2)). +assert(gv_color(x11,salmon3)). +assert(gv_color(x11,salmon4)). +assert(gv_color(x11,sandybrown)). +assert(gv_color(x11,seagreen)). +assert(gv_color(x11,seagreen1)). +assert(gv_color(x11,seagreen2)). +assert(gv_color(x11,seagreen3)). +assert(gv_color(x11,seagreen4)). +assert(gv_color(x11,seashell)). +assert(gv_color(x11,seashell1)). +assert(gv_color(x11,seashell2)). +assert(gv_color(x11,seashell3)). +assert(gv_color(x11,seashell4)). +assert(gv_color(x11,sienna)). +assert(gv_color(x11,sienna1)). +assert(gv_color(x11,sienna2)). +assert(gv_color(x11,sienna3)). +assert(gv_color(x11,sienna4)). +assert(gv_color(x11,skyblue)). +assert(gv_color(x11,skyblue1)). +assert(gv_color(x11,skyblue2)). +assert(gv_color(x11,skyblue3)). +assert(gv_color(x11,skyblue4)). +assert(gv_color(x11,slateblue)). +assert(gv_color(x11,slateblue1)). +assert(gv_color(x11,slateblue2)). +assert(gv_color(x11,slateblue3)). +assert(gv_color(x11,slateblue4)). +assert(gv_color(x11,slategray)). +assert(gv_color(x11,slategray1)). +assert(gv_color(x11,slategray2)). +assert(gv_color(x11,slategray3)). +assert(gv_color(x11,slategray4)). +assert(gv_color(x11,slategrey)). +assert(gv_color(x11,snow)). +assert(gv_color(x11,snow1)). +assert(gv_color(x11,snow2)). +assert(gv_color(x11,snow3)). +assert(gv_color(x11,snow4)). +assert(gv_color(x11,springgreen)). +assert(gv_color(x11,springgreen1)). +assert(gv_color(x11,springgreen2)). +assert(gv_color(x11,springgreen3)). +assert(gv_color(x11,springgreen4)). +assert(gv_color(x11,steelblue)). +assert(gv_color(x11,steelblue1)). +assert(gv_color(x11,steelblue2)). +assert(gv_color(x11,steelblue3)). +assert(gv_color(x11,steelblue4)). +assert(gv_color(x11,tan)). +assert(gv_color(x11,tan1)). +assert(gv_color(x11,tan2)). +assert(gv_color(x11,tan3)). +assert(gv_color(x11,tan4)). +assert(gv_color(x11,thistle)). +assert(gv_color(x11,thistle1)). +assert(gv_color(x11,thistle2)). +assert(gv_color(x11,thistle3)). +assert(gv_color(x11,thistle4)). +assert(gv_color(x11,tomato)). +assert(gv_color(x11,tomato1)). +assert(gv_color(x11,tomato2)). +assert(gv_color(x11,tomato3)). +assert(gv_color(x11,tomato4)). +assert(gv_color(x11,transparent)). +assert(gv_color(x11,turquoise)). +assert(gv_color(x11,turquoise1)). +assert(gv_color(x11,turquoise2)). +assert(gv_color(x11,turquoise3)). +assert(gv_color(x11,turquoise4)). +assert(gv_color(x11,violet)). +assert(gv_color(x11,violetred)). +assert(gv_color(x11,violetred1)). +assert(gv_color(x11,violetred2)). +assert(gv_color(x11,violetred3)). +assert(gv_color(x11,violetred4)). +assert(gv_color(x11,wheat)). +assert(gv_color(x11,wheat1)). +assert(gv_color(x11,wheat2)). +assert(gv_color(x11,wheat3)). +assert(gv_color(x11,wheat4)). +assert(gv_color(x11,white)). +assert(gv_color(x11,whitesmoke)). +assert(gv_color(x11,yellow)). +assert(gv_color(x11,yellow1)). +assert(gv_color(x11,yellow2)). +assert(gv_color(x11,yellow3)). +assert(gv_color(x11,yellow4)). +assert(gv_color(x11,yellowgreen)). +assert(gv_color(svg,aliceblue)). +assert(gv_color(svg,antiquewhite)). +assert(gv_color(svg,aqua)). +assert(gv_color(svg,aquamarine)). +assert(gv_color(svg,azure)). +assert(gv_color(svg,beige)). +assert(gv_color(svg,bisque)). +assert(gv_color(svg,black)). +assert(gv_color(svg,blanchedalmond)). +assert(gv_color(svg,blue)). +assert(gv_color(svg,blueviolet)). +assert(gv_color(svg,brown)). +assert(gv_color(svg,burlywood)). +assert(gv_color(svg,cadetblue)). +assert(gv_color(svg,chartreuse)). +assert(gv_color(svg,chocolate)). +assert(gv_color(svg,coral)). +assert(gv_color(svg,cornflowerblue)). +assert(gv_color(svg,cornsilk)). +assert(gv_color(svg,crimson)). +assert(gv_color(svg,cyan)). +assert(gv_color(svg,darkblue)). +assert(gv_color(svg,darkcyan)). +assert(gv_color(svg,darkgoldenrod)). +assert(gv_color(svg,darkgray)). +assert(gv_color(svg,darkgreen)). +assert(gv_color(svg,darkgrey)). +assert(gv_color(svg,darkkhaki)). +assert(gv_color(svg,darkmagenta)). +assert(gv_color(svg,darkolivegreen)). +assert(gv_color(svg,darkorange)). +assert(gv_color(svg,darkorchid)). +assert(gv_color(svg,darkred)). +assert(gv_color(svg,darksalmon)). +assert(gv_color(svg,darkseagreen)). +assert(gv_color(svg,darkslateblue)). +assert(gv_color(svg,darkslategray)). +assert(gv_color(svg,darkslategrey)). +assert(gv_color(svg,darkturquoise)). +assert(gv_color(svg,darkviolet)). +assert(gv_color(svg,deeppink)). +assert(gv_color(svg,deepskyblue)). +assert(gv_color(svg,dimgray)). +assert(gv_color(svg,dimgrey)). +assert(gv_color(svg,dodgerblue)). +assert(gv_color(svg,firebrick)). +assert(gv_color(svg,floralwhite)). +assert(gv_color(svg,forestgreen)). +assert(gv_color(svg,fuchsia)). +assert(gv_color(svg,gainsboro)). +assert(gv_color(svg,ghostwhite)). +assert(gv_color(svg,gold)). +assert(gv_color(svg,goldenrod)). +assert(gv_color(svg,gray)). +assert(gv_color(svg,grey)). +assert(gv_color(svg,green)). +assert(gv_color(svg,greenyellow)). +assert(gv_color(svg,honeydew)). +assert(gv_color(svg,hotpink)). +assert(gv_color(svg,indianred)). +assert(gv_color(svg,indigo)). +assert(gv_color(svg,ivory)). +assert(gv_color(svg,khaki)). +assert(gv_color(svg,lavender)). +assert(gv_color(svg,lavenderblush)). +assert(gv_color(svg,lawngreen)). +assert(gv_color(svg,lemonchiffon)). +assert(gv_color(svg,lightblue)). +assert(gv_color(svg,lightcoral)). +assert(gv_color(svg,lightcyan)). +assert(gv_color(svg,lightgoldenrodyellow)). +assert(gv_color(svg,lightgray)). +assert(gv_color(svg,lightgreen)). +assert(gv_color(svg,lightgrey)). +assert(gv_color(svg,lightpink)). +assert(gv_color(svg,lightsalmon)). +assert(gv_color(svg,lightseagreen)). +assert(gv_color(svg,lightskyblue)). +assert(gv_color(svg,lightslategray)). +assert(gv_color(svg,lightslategrey)). +assert(gv_color(svg,lightsteelblue)). +assert(gv_color(svg,lightyellow)). +assert(gv_color(svg,lime)). +assert(gv_color(svg,limegreen)). +assert(gv_color(svg,linen)). +assert(gv_color(svg,magenta)). +assert(gv_color(svg,maroon)). +assert(gv_color(svg,mediumaquamarine)). +assert(gv_color(svg,mediumblue)). +assert(gv_color(svg,mediumorchid)). +assert(gv_color(svg,mediumpurple)). +assert(gv_color(svg,mediumseagreen)). +assert(gv_color(svg,mediumslateblue)). +assert(gv_color(svg,mediumspringgreen)). +assert(gv_color(svg,mediumturquoise)). +assert(gv_color(svg,mediumvioletred)). +assert(gv_color(svg,midnightblue)). +assert(gv_color(svg,mintcream)). +assert(gv_color(svg,mistyrose)). +assert(gv_color(svg,moccasin)). +assert(gv_color(svg,navajowhite)). +assert(gv_color(svg,navy)). +assert(gv_color(svg,oldlace)). +assert(gv_color(svg,olive)). +assert(gv_color(svg,olivedrab)). +assert(gv_color(svg,orange)). +assert(gv_color(svg,orangered)). +assert(gv_color(svg,orchid)). +assert(gv_color(svg,palegoldenrod)). +assert(gv_color(svg,palegreen)). +assert(gv_color(svg,paleturquoise)). +assert(gv_color(svg,palevioletred)). +assert(gv_color(svg,papayawhip)). +assert(gv_color(svg,peachpuff)). +assert(gv_color(svg,peru)). +assert(gv_color(svg,pink)). +assert(gv_color(svg,plum)). +assert(gv_color(svg,powderblue)). +assert(gv_color(svg,purple)). +assert(gv_color(svg,red)). +assert(gv_color(svg,rosybrown)). +assert(gv_color(svg,royalblue)). +assert(gv_color(svg,saddlebrown)). +assert(gv_color(svg,salmon)). +assert(gv_color(svg,sandybrown)). +assert(gv_color(svg,seagreen)). +assert(gv_color(svg,seashell)). +assert(gv_color(svg,sienna)). +assert(gv_color(svg,silver)). +assert(gv_color(svg,skyblue)). +assert(gv_color(svg,slateblue)). +assert(gv_color(svg,slategray)). +assert(gv_color(svg,slategrey)). +assert(gv_color(svg,snow)). +assert(gv_color(svg,springgreen)). +assert(gv_color(svg,steelblue)). +assert(gv_color(svg,tan)). +assert(gv_color(svg,teal)). +assert(gv_color(svg,thistle)). +assert(gv_color(svg,tomato)). +assert(gv_color(svg,turquoise)). +assert(gv_color(svg,violet)). +assert(gv_color(svg,wheat)). +assert(gv_color(svg,white)). +assert(gv_color(svg,whitesmoke)). +assert(gv_color(svg,yellow)). +assert(gv_color(svg,yellowgreen)). ```

118: 正在比较变动前 cab2231 和变动后 008c5e6

[back to content](#compare) ``` diff diff --git a/prolog/gv/gv_attrs.log b/prolog/gv/gv_attrs.log new file mode 100644 index 0000000..a9c6010 --- /dev/null +++ b/prolog/gv/gv_attrs.log @@ -0,0 +1,169 @@ +assert(gv_attr('Damping',[graph],[double],'0.99','0.0','neato only')). +assert(gv_attr('K',[cluster,graph],[double],'0.3','0','sfdp, fdp only')). +assert(gv_attr('URL',[cluster,edge,graph,node],[escString],_,'','svg, postscript, map only')). +assert(gv_attr('_background',[graph],[string],_,'','')). +assert(gv_attr(area,[cluster,node],[double],'1.0','>0','patchwork only')). +assert(gv_attr(arrowhead,[edge],[arrowType],normal,'','')). +assert(gv_attr(arrowsize,[edge],[double],'1.0','0.0','')). +assert(gv_attr(arrowtail,[edge],[arrowType],normal,'','')). +assert(gv_attr(bb,[graph],[rect],'','','write only')). +assert(gv_attr(bgcolor,[cluster,graph],[color,colorList],_,'','')). +assert(gv_attr(center,[graph],[bool],false,'','')). +assert(gv_attr(charset,[graph],[string],'"UTF-8"','','')). +assert(gv_attr(clusterrank,[graph],[clusterMode],local,'','dot only')). +assert(gv_attr(color,[cluster,edge,node],[color,colorList],black,'','')). +assert(gv_attr(colorscheme,[cluster,edge,graph,node],[string],'','','')). +assert(gv_attr(comment,[edge,graph,node],[string],'','','')). +assert(gv_attr(compound,[graph],[bool],false,'','dot only')). +assert(gv_attr(concentrate,[graph],[bool],false,'','')). +assert(gv_attr(constraint,[edge],[bool],true,'','dot only')). +assert(gv_attr(decorate,[edge],[bool],false,'','')). +assert(gv_attr(defaultdist,[graph],[double],'1+(avg. len)*sqrt(|V|)',epsilon,'neato only')). +assert(gv_attr(dim,[graph],[int],'2','2','sfdp, fdp, neato only')). +assert(gv_attr(dimen,[graph],[int],'2','2','sfdp, fdp, neato only')). +assert(gv_attr(dir,[edge],[dirType],'forward(directed)none(undirected)','','')). +assert(gv_attr(diredgeconstraints,[graph],[string,bool],false,'','neato only')). +assert(gv_attr(distortion,[node],[double],'0.0','-100.0','')). +assert(gv_attr(dpi,[graph],[double],'96.00.0','','svg, bitmap output only')). +assert(gv_attr(edgeURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(edgehref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(edgetarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(edgetooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(epsilon,[graph],[double],'.0001 * # nodes(mode == KK).0001(mode == major)','','neato only')). +assert(gv_attr(esep,[graph],[addDouble,addPoint],'+3','','not dot')). +assert(gv_attr(fillcolor,[cluster,edge,node],[color,colorList],'lightgrey(nodes)black(clusters)','','')). +assert(gv_attr(fixedsize,[node],[bool,string],false,'','')). +assert(gv_attr(fontcolor,[cluster,edge,graph,node],[color],black,'','')). +assert(gv_attr(fontname,[cluster,edge,graph,node],[string],'"Times-Roman"','','')). +assert(gv_attr(fontnames,[graph],[string],'','','svg only')). +assert(gv_attr(fontpath,[graph],[string],'system-dependent','','')). +assert(gv_attr(fontsize,[cluster,edge,graph,node],[double],'14.0','1.0','')). +assert(gv_attr(forcelabels,[graph],[bool],true,'','')). +assert(gv_attr(gradientangle,[cluster,graph,node],[int],'','','')). +assert(gv_attr(group,[node],[string],'','','dot only')). +assert(gv_attr(headURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(head_lp,[edge],[point],'','','write only')). +assert(gv_attr(headclip,[edge],[bool],true,'','')). +assert(gv_attr(headhref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(headlabel,[edge],[lblString],'','','')). +assert(gv_attr(headport,[edge],[portPos],center,'','')). +assert(gv_attr(headtarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(headtooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(height,[node],[double],'0.5','0.02','')). +assert(gv_attr(href,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only')). +assert(gv_attr(id,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only')). +assert(gv_attr(image,[node],[string],'','','')). +assert(gv_attr(imagepath,[graph],[string],'','','')). +assert(gv_attr(imagescale,[node],[bool,string],false,'','')). +assert(gv_attr(inputscale,[graph],[double],_,'','fdp, neato only')). +assert(gv_attr(label,[cluster,edge,graph,node],[lblString],'"\\N" (nodes)"" (otherwise)','','')). +assert(gv_attr(labelURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(label_scheme,[graph],[int],'0','0','sfdp only')). +assert(gv_attr(labelangle,[edge],[double],'-25.0','-180.0','')). +assert(gv_attr(labeldistance,[edge],[double],'1.0','0.0','')). +assert(gv_attr(labelfloat,[edge],[bool],false,'','')). +assert(gv_attr(labelfontcolor,[edge],[color],black,'','')). +assert(gv_attr(labelfontname,[edge],[string],'"Times-Roman"','','')). +assert(gv_attr(labelfontsize,[edge],[double],'14.0','1.0','')). +assert(gv_attr(labelhref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(labeljust,[cluster,graph],[string],'"c"','','')). +assert(gv_attr(labelloc,[cluster,graph,node],[string],'"t"(clusters)"b"(root graphs)"c"(nodes)','','')). +assert(gv_attr(labeltarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(labeltooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(landscape,[graph],[bool],false,'','')). +assert(gv_attr(layer,[cluster,edge,node],[layerRange],'','','')). +assert(gv_attr(layerlistsep,[graph],[string],'","','','')). +assert(gv_attr(layers,[graph],[layerList],'','','')). +assert(gv_attr(layerselect,[graph],[layerRange],'','','')). +assert(gv_attr(layersep,[graph],[string],'" :\\t"','','')). +assert(gv_attr(layout,[graph],[string],'','','')). +assert(gv_attr(len,[edge],[double],'1.0(neato)0.3(fdp)','','fdp, neato only')). +assert(gv_attr(levels,[graph],[int],'MAXINT','0.0','sfdp only')). +assert(gv_attr(levelsgap,[graph],[double],'0.0','','neato only')). +assert(gv_attr(lhead,[edge],[string],'','','dot only')). +assert(gv_attr(lheight,[cluster,graph],[double],'','','write only')). +assert(gv_attr(lp,[cluster,edge,graph],[point],'','','write only')). +assert(gv_attr(ltail,[edge],[string],'','','dot only')). +assert(gv_attr(lwidth,[cluster,graph],[double],'','','write only')). +assert(gv_attr(margin,[cluster,graph,node],[double,point],'','','')). +assert(gv_attr(maxiter,[graph],[int],'100 * # nodes(mode == KK)200(mode == major)600(fdp)','','fdp, neato only')). +assert(gv_attr(mclimit,[graph],[double],'1.0','','dot only')). +assert(gv_attr(mindist,[graph],[double],'1.0','0.0','circo only')). +assert(gv_attr(minlen,[edge],[int],'1','0','dot only')). +assert(gv_attr(mode,[graph],[string],major,'','neato only')). +assert(gv_attr(model,[graph],[string],shortpath,'','neato only')). +assert(gv_attr(mosek,[graph],[bool],false,'','neato only')). +assert(gv_attr(nodesep,[graph],[double],'0.25','0.02','')). +assert(gv_attr(nojustify,[cluster,edge,graph,node],[bool],false,'','')). +assert(gv_attr(normalize,[graph],[double,bool],false,'','not dot')). +assert(gv_attr(notranslate,[graph],[bool],false,'','neato only')). +assert(gv_attr('nslimit nslimit1',[graph],[double],'','','dot only')). +assert(gv_attr(ordering,[graph,node],[string],'','','dot only')). +assert(gv_attr(orientation,[node],[double],'0.0','360.0','')). +assert(gv_attr(orientation,[graph],[string],'','','')). +assert(gv_attr(outputorder,[graph],[outputMode],breadthfirst,'','')). +assert(gv_attr(overlap,[graph],[string,bool],true,'','not dot')). +assert(gv_attr(overlap_scaling,[graph],[double],'-4','-1.0e10','prism only')). +assert(gv_attr(overlap_shrink,[graph],[bool],true,'','prism only')). +assert(gv_attr(pack,[graph],[bool,int],false,'','')). +assert(gv_attr(packmode,[graph],[packMode],node,'','')). +assert(gv_attr(pad,[graph],[double,point],'0.0555 (4 points)','','')). +assert(gv_attr(page,[graph],[double,point],'','','')). +assert(gv_attr(pagedir,[graph],[pagedir],'BL','','')). +assert(gv_attr(pencolor,[cluster],[color],black,'','')). +assert(gv_attr(penwidth,[cluster,edge,node],[double],'1.0','0.0','')). +assert(gv_attr(peripheries,[cluster,node],[int],'shape default(nodes)1(clusters)','0','')). +assert(gv_attr(pin,[node],[bool],false,'','fdp, neato only')). +assert(gv_attr(pos,[edge,node],[point,splineType],'','','')). +assert(gv_attr(quadtree,[graph],[quadType,bool],normal,'','sfdp only')). +assert(gv_attr(quantum,[graph],[double],'0.0','0.0','')). +assert(gv_attr(rank,[subgraph],[rankType],'','','dot only')). +assert(gv_attr(rankdir,[graph],[rankdir],'TB','','dot only')). +assert(gv_attr(ranksep,[graph],[double,doubleList],'0.5(dot)1.0(twopi)','0.02','twopi, dot only')). +assert(gv_attr(ratio,[graph],[double,string],'','','')). +assert(gv_attr(rects,[node],[rect],'','','write only')). +assert(gv_attr(regular,[node],[bool],false,'','')). +assert(gv_attr(remincross,[graph],[bool],true,'','dot only')). +assert(gv_attr(repulsiveforce,[graph],[double],'1.0','0.0','sfdp only')). +assert(gv_attr(resolution,[graph],[double],'96.00.0','','svg, bitmap output only')). +assert(gv_attr(root,[graph,node],[string,bool],'(graphs)false(nodes)','','circo, twopi only')). +assert(gv_attr(rotate,[graph],[int],'0','','')). +assert(gv_attr(rotation,[graph],[double],'0','','sfdp only')). +assert(gv_attr(samehead,[edge],[string],'','','dot only')). +assert(gv_attr(sametail,[edge],[string],'','','dot only')). +assert(gv_attr(samplepoints,[node],[int],'8(output)20(overlap and image maps)','','')). +assert(gv_attr(scale,[graph],[double,point],'','','not dot')). +assert(gv_attr(searchsize,[graph],[int],'30','','dot only')). +assert(gv_attr(sep,[graph],[addDouble,addPoint],'+4','','not dot')). +assert(gv_attr(shape,[node],[shape],ellipse,'','')). +assert(gv_attr(shapefile,[node],[string],'','','')). +assert(gv_attr(showboxes,[edge,graph,node],[int],'0','0','dot only')). +assert(gv_attr(sides,[node],[int],'4','0','')). +assert(gv_attr(size,[graph],[double,point],'','','')). +assert(gv_attr(skew,[node],[double],'0.0','-100.0','')). +assert(gv_attr(smoothing,[graph],[smoothType],'"none"','','sfdp only')). +assert(gv_attr(sortv,[cluster,graph,node],[int],'0','0','')). +assert(gv_attr(splines,[graph],[bool,string],'','','')). +assert(gv_attr(start,[graph],[startType],'','','fdp, neato only')). +assert(gv_attr(style,[cluster,edge,graph,node],[style],'','','')). +assert(gv_attr(stylesheet,[graph],[string],'','','svg only')). +assert(gv_attr(tailURL,[edge],[escString],'','','svg, map only')). +assert(gv_attr(tail_lp,[edge],[point],'','','write only')). +assert(gv_attr(tailclip,[edge],[bool],true,'','')). +assert(gv_attr(tailhref,[edge],[escString],'','','svg, map only')). +assert(gv_attr(taillabel,[edge],[lblString],'','','')). +assert(gv_attr(tailport,[edge],[portPos],center,'','')). +assert(gv_attr(tailtarget,[edge],[escString],_,'','svg, map only')). +assert(gv_attr(tailtooltip,[edge],[escString],'','','svg, cmap only')). +assert(gv_attr(target,[cluster,edge,graph,node],[escString,string],_,'','svg, map only')). +assert(gv_attr(tooltip,[cluster,edge,node],[escString],'','','svg, cmap only')). +assert(gv_attr(truecolor,[graph],[bool],'','','bitmap output only')). +assert(gv_attr(vertices,[node],[pointList],'','','write only')). +assert(gv_attr(viewport,[graph],[viewPort],'','','')). +assert(gv_attr(voro_margin,[graph],[double],'0.05','0.0','not dot')). +assert(gv_attr(weight,[edge],[int,double],'1','0(dot,twopi)1(neato,fdp)','')). +assert(gv_attr(width,[node],[double],'0.75','0.01','')). +assert(gv_attr(xdotversion,[graph],[string],'','','xdot only')). +assert(gv_attr(xlabel,[edge,node],[lblString],'','','')). +assert(gv_attr(xlp,[edge,node],[point],'','','write only')). +assert(gv_attr(z,[node],[double],'0.0','-MAXFLOAT-1000','')). ```

119: 正在比较变动前 008c5e6 和变动后 dba5c72

[back to content](#compare) ``` diff diff --git a/pack.pl b/pack.pl index edfd45f..ed03c94 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.15'). +version('0.0.16'). ```

120: 正在比较变动前 dba5c72 和变动后 eff64ee

[back to content](#compare) ``` diff diff --git a/pack.pl b/pack.pl index ed03c94..203cbfc 100644 --- a/pack.pl +++ b/pack.pl @@ -6,4 +6,4 @@ name(plGraphViz). packager('Wouter Beek', 'me@wouterbeek.com'). requires('Prolog_Library_Collection'). title(plGraphViz). -version('0.0.16'). +version('0.0.17'). ```

121: 正在比较变动前 eff64ee 和变动后 89eb423

[back to content](#compare) ``` diff diff --git a/test/debug.pl b/test/debug.pl deleted file mode 100644 index b0f85ea..0000000 --- a/test/debug.pl +++ /dev/null @@ -1,15 +0,0 @@ -:- use_module(library(ansi_term)). -:- use_module(library(prolog_pack)). - -pack_ensure_removed(Pack):- - pack_property(Pack, _), !, - pack_remove(Pack). -pack_ensure_removed(_). - -test:- - pack_ensure_removed(plGraphViz), - source_file(test, ThisFile), - file_directory_name(ThisFile, ThisDirectory), - assert(user:file_search_path(gvTest, ThisDirectory)), - assert(user:file_search_path(library, gvTest('../prolog'))). -:- test. ```

122: 正在比较变动前 89eb423 和变动后 2346997

[back to content](#compare) ``` diff diff --git a/prolog/gv/gv_attr_type.pl b/prolog/gv/gv_attr_type.pl index c6508a3..b0dbd69 100644 --- a/prolog/gv/gv_attr_type.pl +++ b/prolog/gv/gv_attr_type.pl @@ -198,7 +198,7 @@ double(N) --> %! doubleList(+Doubles:list(float))// . doubleList(L) --> - '*'(double, L, [separator(colon)]). + *(double, L, [separator(colon)]). @@ -292,7 +292,7 @@ input_changeable(true) --> "!". %! pointList(+Points:list(compound))// . pointList(Points) --> - '*'(point, Points, []). + *(point, Points, []). diff --git a/prolog/gv/gv_graph.pl b/prolog/gv/gv_graph.pl index bff4257..5de2ff1 100644 --- a/prolog/gv/gv_graph.pl +++ b/prolog/gv/gv_graph.pl @@ -160,13 +160,13 @@ gv_graph(G1, I) --> "}\n". gv_edge_statements(I, Dir, L) --> - '*'(gv_edge_statement(I, Dir), L, []), !. + *(gv_edge_statement(I, Dir), L, []), !. gv_node_statements(I, L) --> - '*'(gv_node_statement(I), L, []), !. + *(gv_node_statement(I), L, []), !. gv_ranked_node_collections(I, L) --> - '*'(gv_ranked_node_collection(I), L, []), !. + *(gv_ranked_node_collection(I), L, []), !. diff --git a/prolog/gv/gv_graph_comp.pl b/prolog/gv/gv_graph_comp.pl index 18cdf7a..033d0b9 100644 --- a/prolog/gv/gv_graph_comp.pl +++ b/prolog/gv/gv_graph_comp.pl @@ -146,7 +146,7 @@ gv_ranked_node_collection0(I, rank(Rank_V_Term,Content_V_Terms)) --> ";\n", % Vertice statements. - '*'( + *( gv_node_statement(NewI), [Rank_V_Term|Content_V_Terms], [] @@ -168,7 +168,7 @@ gv_ranked_node_collection0(I, rank(Rank_V_Term,Content_V_Terms)) --> %! )// is det. gv_attrs(Kind, L) --> - bracketed(square, '*'(gv_attr(Kind), L, [])). + bracketed(square, *(gv_attr(Kind), L, [])). %! gv_attr( %! +Context:oneof([edge,graph,node]), diff --git a/test/test.pl b/test/test.pl index 898c04e..ee92ae6 100644 --- a/test/test.pl +++ b/test/test.pl @@ -1,5 +1,3 @@ -:- ensure_loaded(debug). - %/graph :- use_module(library(graph/build_export_graph)). %/gv ```

123: 正在比较变动前 2346997 和变动后 d22d50e

[back to content](#compare) ``` diff diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 26ddd86..0000000 --- a/.gitmodules +++ /dev/null @@ -1,9 +0,0 @@ -[submodule "Prolog-Library-Collection"] - path = Prolog-Library-Collection - url = https://github.com/wouterbeek/Prolog-Library-Collection.git -[submodule "plHtml"] - path = plHtml - url = https://github.com/wouterbeek/plHtml.git -[submodule "plUri"] - path = plUri - url = https://github.com/wouterbeek/plUri.git diff --git a/prolog/graph/build_export_graph.pl b/prolog/graph/build_export_graph.pl index b031d16..507e8ad 100644 --- a/prolog/graph/build_export_graph.pl +++ b/prolog/graph/build_export_graph.pl @@ -1,6 +1,8 @@ :- module( build_export_graph, [ + build_export_graph/2, % +Graph:compound + % -ExportGraph:compound build_export_graph/3 % +Graph:compound % -ExportGraph:compound % +Options:list(compound) @@ -49,7 +51,7 @@ Vertex coordinates: --- @author Wouter Beek -@version 2015/07 +@version 2015/07, 2015/09 */ :- use_module(library(apply)). @@ -110,6 +112,11 @@ is_meta(vertex_uri). +%! build_export_graph(+Graph:compound, -ExportGraph:compound) is det. + +build_export_graph(G, ExportG):- + build_export_graph(G, ExportG, []). + %! build_export_graph( %! +Graph:compound, %! -ExportGraph:compound, ```

124: 正在比较变动前 d22d50e 和变动后 e64cc35

[back to content](#compare) ``` diff diff --git a/install b/install new file mode 100755 index 0000000..849699b --- /dev/null +++ b/install @@ -0,0 +1,218 @@ +#!/usr/bin/env swipl + +:- module(install, []). + +/** Install + +Let's do this! + +@author Wouter Beek +@version 2015/09/23 +*/ + +:- use_module(library(filesex)). +:- use_module(library(lists)). +:- use_module(library(option)). +:- use_module(library(optparse)). +:- use_module(library(prolog_pack)). +:- use_module(library(uri)). + +:- dynamic(author/2). +:- dynamic(download/1). +:- dynamic(home/1). +:- dynamic(maintainer/2). +:- dynamic(name/1). +:- dynamic(packager/2). +:- dynamic(requires/1). +:- dynamic(title/1). +:- dynamic(version/1). + +:- initialization(install). + + + + + +%! install is det. + +install:- + OptSpec = [ + [ % Github + default(true), + help('Whether Github should be used to install requirements.'), + longflags([git,github]), + opt(github), + type(boolean) + ], + [ % Help + default(false), + help('Display help about the install command.'), + longflags([help]), + opt(help), + shortflags([h]), + type(boolean) + ], + [ % Pack + default(true), + help('Whether the Prolog Pack system is used for installing requirements.'), + longflags([pack]), + opt(pack), + type(boolean) + ], + [ % Parent + default(false), + help('Whether existing installations in the parent directory should be taken into account.'), + longflags([parent]), + opt(parent), + type(boolean) + ] + ], + opt_arguments(OptSpec, Opts, _), + + % Process help + (option(help(true), Opts) -> show_help(OptSpec) ; install(Opts)). + + +%! install(+Options:list(compound)) is det. + +install(Opts):- + source_file(install, File), + file_directory_name(File, AppDir), + install(AppDir, AppDir, Opts), + clean_meta, + halt. + + +%! install( +%! +ApplicationDirectory:atom, +%! +LibraryDirectory:atom, +%! +Options:list(compound) +%! ) is det. + +install(AppDir, LibDir, Opts):- + % The pack information is taken from the library directory. + % This allows application requirements to be installed recursively. + directory_file_path(LibDir, 'pack.pl', Info), + access_file(Info, read), + load_meta(Info), + + % Set this library's search path. + name(Name), + assert(user:file_search_path(Name, LibDir)), + + % Pull in the required libraries. + forall(requires(LibName), install_required(AppDir, LibName, Opts)), !. +install(_, _, _):- + msg_warning('Installation failed.'). + + +%! install_required( +%! +ApplicationDirectory:atom, +%! +LibName:atom, +%! +Options:list(compound) +%! ) is det. + +% Developer's delight: library already available from parent directory. +install_required(AppDir, LibName, Opts):- + option(parent(true), Opts), + + file_directory_name(AppDir, ParentDir), + append_directories(ParentDir, LibName, LibDir), + exists_directory(LibDir), !, + + % Print message. + atomic_list_concat(['Library ',LibName,' already installed.'], Msg), + msg_success(Msg). +% Install through the Prolog Pack system. +install_required(_, LibName, Opts):- + option(pack(true), Opts), + + prolog_pack:query_pack_server(search(LibName), Result,[]), + Result = true([pack(LibName,_,_,_,_)]), !, + pack_install(LibName). +% Install through Github. +install_required(AppDir, LibName, Opts):- + option(github(true), Opts), + + % Remove the old version of the library. + append_directories(AppDir, LibName, LibDir), + (exists_directory(LibDir) -> delete_directory_and_contents(LibDir) ; true), + + % Git clone the new version of the library. + atomic_list_concat(['',wouterbeek,LibName], /, Path), + uri_components(Iri, uri_components(https,'github.com',Path,_,_)), + prolog_pack:run_process(path(git), [clone,Iri,LibDir], []), + + % Print message. + atomic_list_concat(['Library ',LibName,' was installed.'], Msg), + msg_success(Msg), + + % Recurse + install(AppDir, LibDir, Opts), !. +% Oops! +install_required(_, LibName, _):- + atomic_list_concat( + ['Installation of library ',LibName,' failed.'], + Msg + ), + msg_warning(Msg). + + + + + +% HELPERS % + +%! append_directories(+Dir1:atom, +Dir2:atom, -Dir3:atom) is det. + +append_directories(Dir1, Dir2, Dir3):- + atomic_list_concat(Subdirs1, /, Dir1), + atomic_list_concat(Subdirs2, /, Dir2), + append(Subdirs1, Subdirs2, Subdirs3), + atomic_list_concat(Subdirs3, /, Dir3). + + + +%! clean_meta is det. + +clean_meta:- + retractall(author/2), + retractall(download/1), + retractall(home/1), + retractall(maintainer/2), + retractall(name/1), + retractall(packager/2), + retractall(requires/1), + retractall(title/1), + retractall(version/1). + + + +%! show_help(+OptionSpecification:list(compound)) is det. + +show_help(OptSpec):- + opt_help(OptSpec, Help), + format(user_output, '~a\n', [Help]), + halt. + + + +%! load_meta(+File:atom) is det. + +load_meta(File):- + clean_meta, + ensure_loaded(File). + + + +%! msg_success(+Message:atom) is det. + +msg_success(X):- + ansi_format([bold,fg(green)], '~a~n', [X]). + + + +%! msg_warning(+Message:atom) is det. + +msg_warning(X):- + ansi_format([bold,fg(red)], '~a~n', [X]). ```

125: 正在比较变动前 e64cc35 和变动后 763a529

[back to content](#compare) ``` diff diff --git a/install b/install deleted file mode 100755 index 849699b..0000000 --- a/install +++ /dev/null @@ -1,218 +0,0 @@ -#!/usr/bin/env swipl - -:- module(install, []). - -/** Install - -Let's do this! - -@author Wouter Beek -@version 2015/09/23 -*/ - -:- use_module(library(filesex)). -:- use_module(library(lists)). -:- use_module(library(option)). -:- use_module(library(optparse)). -:- use_module(library(prolog_pack)). -:- use_module(library(uri)). - -:- dynamic(author/2). -:- dynamic(download/1). -:- dynamic(home/1). -:- dynamic(maintainer/2). -:- dynamic(name/1). -:- dynamic(packager/2). -:- dynamic(requires/1). -:- dynamic(title/1). -:- dynamic(version/1). - -:- initialization(install). - - - - - -%! install is det. - -install:- - OptSpec = [ - [ % Github - default(true), - help('Whether Github should be used to install requirements.'), - longflags([git,github]), - opt(github), - type(boolean) - ], - [ % Help - default(false), - help('Display help about the install command.'), - longflags([help]), - opt(help), - shortflags([h]), - type(boolean) - ], - [ % Pack - default(true), - help('Whether the Prolog Pack system is used for installing requirements.'), - longflags([pack]), - opt(pack), - type(boolean) - ], - [ % Parent - default(false), - help('Whether existing installations in the parent directory should be taken into account.'), - longflags([parent]), - opt(parent), - type(boolean) - ] - ], - opt_arguments(OptSpec, Opts, _), - - % Process help - (option(help(true), Opts) -> show_help(OptSpec) ; install(Opts)). - - -%! install(+Options:list(compound)) is det. - -install(Opts):- - source_file(install, File), - file_directory_name(File, AppDir), - install(AppDir, AppDir, Opts), - clean_meta, - halt. - - -%! install( -%! +ApplicationDirectory:atom, -%! +LibraryDirectory:atom, -%! +Options:list(compound) -%! ) is det. - -install(AppDir, LibDir, Opts):- - % The pack information is taken from the library directory. - % This allows application requirements to be installed recursively. - directory_file_path(LibDir, 'pack.pl', Info), - access_file(Info, read), - load_meta(Info), - - % Set this library's search path. - name(Name), - assert(user:file_search_path(Name, LibDir)), - - % Pull in the required libraries. - forall(requires(LibName), install_required(AppDir, LibName, Opts)), !. -install(_, _, _):- - msg_warning('Installation failed.'). - - -%! install_required( -%! +ApplicationDirectory:atom, -%! +LibName:atom, -%! +Options:list(compound) -%! ) is det. - -% Developer's delight: library already available from parent directory. -install_required(AppDir, LibName, Opts):- - option(parent(true), Opts), - - file_directory_name(AppDir, ParentDir), - append_directories(ParentDir, LibName, LibDir), - exists_directory(LibDir), !, - - % Print message. - atomic_list_concat(['Library ',LibName,' already installed.'], Msg), - msg_success(Msg). -% Install through the Prolog Pack system. -install_required(_, LibName, Opts):- - option(pack(true), Opts), - - prolog_pack:query_pack_server(search(LibName), Result,[]), - Result = true([pack(LibName,_,_,_,_)]), !, - pack_install(LibName). -% Install through Github. -install_required(AppDir, LibName, Opts):- - option(github(true), Opts), - - % Remove the old version of the library. - append_directories(AppDir, LibName, LibDir), - (exists_directory(LibDir) -> delete_directory_and_contents(LibDir) ; true), - - % Git clone the new version of the library. - atomic_list_concat(['',wouterbeek,LibName], /, Path), - uri_components(Iri, uri_components(https,'github.com',Path,_,_)), - prolog_pack:run_process(path(git), [clone,Iri,LibDir], []), - - % Print message. - atomic_list_concat(['Library ',LibName,' was installed.'], Msg), - msg_success(Msg), - - % Recurse - install(AppDir, LibDir, Opts), !. -% Oops! -install_required(_, LibName, _):- - atomic_list_concat( - ['Installation of library ',LibName,' failed.'], - Msg - ), - msg_warning(Msg). - - - - - -% HELPERS % - -%! append_directories(+Dir1:atom, +Dir2:atom, -Dir3:atom) is det. - -append_directories(Dir1, Dir2, Dir3):- - atomic_list_concat(Subdirs1, /, Dir1), - atomic_list_concat(Subdirs2, /, Dir2), - append(Subdirs1, Subdirs2, Subdirs3), - atomic_list_concat(Subdirs3, /, Dir3). - - - -%! clean_meta is det. - -clean_meta:- - retractall(author/2), - retractall(download/1), - retractall(home/1), - retractall(maintainer/2), - retractall(name/1), - retractall(packager/2), - retractall(requires/1), - retractall(title/1), - retractall(version/1). - - - -%! show_help(+OptionSpecification:list(compound)) is det. - -show_help(OptSpec):- - opt_help(OptSpec, Help), - format(user_output, '~a\n', [Help]), - halt. - - - -%! load_meta(+File:atom) is det. - -load_meta(File):- - clean_meta, - ensure_loaded(File). - - - -%! msg_success(+Message:atom) is det. - -msg_success(X):- - ansi_format([bold,fg(green)], '~a~n', [X]). - - - -%! msg_warning(+Message:atom) is det. - -msg_warning(X):- - ansi_format([bold,fg(red)], '~a~n', [X]). diff --git a/prolog/gv/gv_attrs.pl b/prolog/gv/gv_attrs.pl index fa00670..99d6059 100644 --- a/prolog/gv/gv_attrs.pl +++ b/prolog/gv/gv_attrs.pl @@ -121,9 +121,9 @@ assert_gv_attr_row([Name,UsedBy1,Types1,Default1,Minimum,Notes]):- % Downloads the table describing GraphViz attributes from `graphviz.org`. gv_attrs_download:- - verbose_call( - 'updating GraphViz attributes table', + verbose( gv_attrs_download0 + "updating GraphViz attributes table", ). gv_attrs_download0:- diff --git a/prolog/gv/gv_color.pl b/prolog/gv/gv_color.pl index 57c7f90..2c56713 100644 --- a/prolog/gv/gv_color.pl +++ b/prolog/gv/gv_color.pl @@ -88,9 +88,9 @@ wc_weight(Float) --> %! gv_color_download is det. gv_color_download:- - verbose_call( - 'updating the GraphViz color table', - gv_color_download0 + verbose( + gv_color_download0, + 'updating the GraphViz color table' ). gv_color_download0:- diff --git a/prolog/gv/gv_file.pl b/prolog/gv/gv_file.pl index 577a33a..7fd5a58 100644 --- a/prolog/gv/gv_file.pl +++ b/prolog/gv/gv_file.pl @@ -10,7 +10,7 @@ /** GraphViz file @author Wouter Beek -@version 2015/07 +@version 2015/07, 2015/10 */ :- use_module(library(code_ext)). @@ -18,18 +18,13 @@ :- use_module(library(gv/gv_graph)). :- use_module(library(option)). :- use_module(library(process)). - -:- dynamic(user:prolog_file_type/2). -:- multifile(user:prolog_file_type/2). - -user:prolog_file_type(dot, dot). -user:prolog_file_type(pdf, pdf). +:- use_module(library(string_ext)). :- predicate_options(gv_export/3, 3, [ pass_to(file_to_gv/3, 3) ]). :- predicate_options(file_to_gv/3, 3, [ - method(+atom), + method(+oneof([circo,dot,fdp,neato,osage,sfdp,twopi])), output(+atom) ]). @@ -37,39 +32,38 @@ user:prolog_file_type(pdf, pdf). -%! gv_export( -%! +ExportGraph:compound, -%! +OutputFile:atom, -%! +Options:list(nvpair) -%! ) is det. +%! gv_export(+ExportGraph:compound, +File:atom, +Options:list(compound)) is det. % Returns a file containing a GraphViz visualization of the given graph. % % The following options are supported: -% - `method(+Method:atom)` +% * method(+oneof([circo,dot,fdp,neato,osage,sfdp,twopi]) % The algorithm used by GraphViz for positioning the tree nodes. -% Either =dot= (default) or =sfdp=. -% - `output(+FileType:atom)` +% Default is `dot'. +% For possible values see gv_method/1. +% * output(+atom)` % The file type of the generated GraphViz file. -% Default: `pdf`. +% Default is `pdf`. +% For possible values see gv_output_type/1. -gv_export(ExportGraph, OutputFile, Options):- - once(phrase(gv_graph(ExportGraph), Codes)), +gv_export(ExportG, File, Opts):- + once(phrase(gv_graph(ExportG), Cs)), % Be thread-safe. thread_self(Id), - atomic_list_concat([gv_file,Id], '_', ThreadName), - absolute_file_name(ThreadName, TmpFile, [access(write),file_type(dot)]), + string_list_concat(["gv_file",Id], "_", ThreadName), + absolute_file_name(ThreadName, TmpFile, [access(write),extensions([dot])]), setup_call_cleanup( open(TmpFile, write, Write, [encoding(utf8)]), - with_output_to(Write, put_codes(Codes)), + with_output_to(Write, put_codes(Cs)), close(Write) ), - file_to_gv(TmpFile, OutputFile, Options). + file_to_gv(TmpFile, File, Opts). + %! file_to_gv( %! +InputFile:atom, %! +OutputFile:atom, -%! +Options:list(nvpair) +%! +Options:list(compound) %! ) is det. % Converts a GraphViz DOT file to an image file, using a specific % visualization method. @@ -98,8 +92,8 @@ file_to_gv(InputFile, OutputFile, Opts):- must_be(oneof(OutputTypes), OutputType), % Run the GraphViz conversion command in the shell. - format(atom(OutputTypeFlag), '-T~a', [OutputType]), - format(atom(OutputFileFlag), '-o~a', [OutputFile]), + format(atom(OutputTypeFlag), "-T~a", [OutputType]), + format(atom(OutputFileFlag), "-o~a", [OutputFile]), process_create( path(Method), [OutputTypeFlag,file(InputFile),OutputFileFlag], @@ -108,6 +102,8 @@ file_to_gv(InputFile, OutputFile, Opts):- + + % HELPERS % gv_method(circo). ```

126: 正在比较变动前 763a529 和变动后 d962f81

[back to content](#compare) ``` diff diff --git a/install b/install new file mode 100755 index 0000000..849699b --- /dev/null +++ b/install @@ -0,0 +1,218 @@ +#!/usr/bin/env swipl + +:- module(install, []). + +/** Install + +Let's do this! + +@author Wouter Beek +@version 2015/09/23 +*/ + +:- use_module(library(filesex)). +:- use_module(library(lists)). +:- use_module(library(option)). +:- use_module(library(optparse)). +:- use_module(library(prolog_pack)). +:- use_module(library(uri)). + +:- dynamic(author/2). +:- dynamic(download/1). +:- dynamic(home/1). +:- dynamic(maintainer/2). +:- dynamic(name/1). +:- dynamic(packager/2). +:- dynamic(requires/1). +:- dynamic(title/1). +:- dynamic(version/1). + +:- initialization(install). + + + + + +%! install is det. + +install:- + OptSpec = [ + [ % Github + default(true), + help('Whether Github should be used to install requirements.'), + longflags([git,github]), + opt(github), + type(boolean) + ], + [ % Help + default(false), + help('Display help about the install command.'), + longflags([help]), + opt(help), + shortflags([h]), + type(boolean) + ], + [ % Pack + default(true), + help('Whether the Prolog Pack system is used for installing requirements.'), + longflags([pack]), + opt(pack), + type(boolean) + ], + [ % Parent + default(false), + help('Whether existing installations in the parent directory should be taken into account.'), + longflags([parent]), + opt(parent), + type(boolean) + ] + ], + opt_arguments(OptSpec, Opts, _), + + % Process help + (option(help(true), Opts) -> show_help(OptSpec) ; install(Opts)). + + +%! install(+Options:list(compound)) is det. + +install(Opts):- + source_file(install, File), + file_directory_name(File, AppDir), + install(AppDir, AppDir, Opts), + clean_meta, + halt. + + +%! install( +%! +ApplicationDirectory:atom, +%! +LibraryDirectory:atom, +%! +Options:list(compound) +%! ) is det. + +install(AppDir, LibDir, Opts):- + % The pack information is taken from the library directory. + % This allows application requirements to be installed recursively. + directory_file_path(LibDir, 'pack.pl', Info), + access_file(Info, read), + load_meta(Info), + + % Set this library's search path. + name(Name), + assert(user:file_search_path(Name, LibDir)), + + % Pull in the required libraries. + forall(requires(LibName), install_required(AppDir, LibName, Opts)), !. +install(_, _, _):- + msg_warning('Installation failed.'). + + +%! install_required( +%! +ApplicationDirectory:atom, +%! +LibName:atom, +%! +Options:list(compound) +%! ) is det. + +% Developer's delight: library already available from parent directory. +install_required(AppDir, LibName, Opts):- + option(parent(true), Opts), + + file_directory_name(AppDir, ParentDir), + append_directories(ParentDir, LibName, LibDir), + exists_directory(LibDir), !, + + % Print message. + atomic_list_concat(['Library ',LibName,' already installed.'], Msg), + msg_success(Msg). +% Install through the Prolog Pack system. +install_required(_, LibName, Opts):- + option(pack(true), Opts), + + prolog_pack:query_pack_server(search(LibName), Result,[]), + Result = true([pack(LibName,_,_,_,_)]), !, + pack_install(LibName). +% Install through Github. +install_required(AppDir, LibName, Opts):- + option(github(true), Opts), + + % Remove the old version of the library. + append_directories(AppDir, LibName, LibDir), + (exists_directory(LibDir) -> delete_directory_and_contents(LibDir) ; true), + + % Git clone the new version of the library. + atomic_list_concat(['',wouterbeek,LibName], /, Path), + uri_components(Iri, uri_components(https,'github.com',Path,_,_)), + prolog_pack:run_process(path(git), [clone,Iri,LibDir], []), + + % Print message. + atomic_list_concat(['Library ',LibName,' was installed.'], Msg), + msg_success(Msg), + + % Recurse + install(AppDir, LibDir, Opts), !. +% Oops! +install_required(_, LibName, _):- + atomic_list_concat( + ['Installation of library ',LibName,' failed.'], + Msg + ), + msg_warning(Msg). + + + + + +% HELPERS % + +%! append_directories(+Dir1:atom, +Dir2:atom, -Dir3:atom) is det. + +append_directories(Dir1, Dir2, Dir3):- + atomic_list_concat(Subdirs1, /, Dir1), + atomic_list_concat(Subdirs2, /, Dir2), + append(Subdirs1, Subdirs2, Subdirs3), + atomic_list_concat(Subdirs3, /, Dir3). + + + +%! clean_meta is det. + +clean_meta:- + retractall(author/2), + retractall(download/1), + retractall(home/1), + retractall(maintainer/2), + retractall(name/1), + retractall(packager/2), + retractall(requires/1), + retractall(title/1), + retractall(version/1). + + + +%! show_help(+OptionSpecification:list(compound)) is det. + +show_help(OptSpec):- + opt_help(OptSpec, Help), + format(user_output, '~a\n', [Help]), + halt. + + + +%! load_meta(+File:atom) is det. + +load_meta(File):- + clean_meta, + ensure_loaded(File). + + + +%! msg_success(+Message:atom) is det. + +msg_success(X):- + ansi_format([bold,fg(green)], '~a~n', [X]). + + + +%! msg_warning(+Message:atom) is det. + +msg_warning(X):- + ansi_format([bold,fg(red)], '~a~n', [X]). ```

127: 正在比较变动前 d962f81 和变动后 63a5cd7

[back to content](#compare) ``` diff diff --git a/install b/install deleted file mode 100755 index 849699b..0000000 --- a/install +++ /dev/null @@ -1,218 +0,0 @@ -#!/usr/bin/env swipl - -:- module(install, []). - -/** Install - -Let's do this! - -@author Wouter Beek -@version 2015/09/23 -*/ - -:- use_module(library(filesex)). -:- use_module(library(lists)). -:- use_module(library(option)). -:- use_module(library(optparse)). -:- use_module(library(prolog_pack)). -:- use_module(library(uri)). - -:- dynamic(author/2). -:- dynamic(download/1). -:- dynamic(home/1). -:- dynamic(maintainer/2). -:- dynamic(name/1). -:- dynamic(packager/2). -:- dynamic(requires/1). -:- dynamic(title/1). -:- dynamic(version/1). - -:- initialization(install). - - - - - -%! install is det. - -install:- - OptSpec = [ - [ % Github - default(true), - help('Whether Github should be used to install requirements.'), - longflags([git,github]), - opt(github), - type(boolean) - ], - [ % Help - default(false), - help('Display help about the install command.'), - longflags([help]), - opt(help), - shortflags([h]), - type(boolean) - ], - [ % Pack - default(true), - help('Whether the Prolog Pack system is used for installing requirements.'), - longflags([pack]), - opt(pack), - type(boolean) - ], - [ % Parent - default(false), - help('Whether existing installations in the parent directory should be taken into account.'), - longflags([parent]), - opt(parent), - type(boolean) - ] - ], - opt_arguments(OptSpec, Opts, _), - - % Process help - (option(help(true), Opts) -> show_help(OptSpec) ; install(Opts)). - - -%! install(+Options:list(compound)) is det. - -install(Opts):- - source_file(install, File), - file_directory_name(File, AppDir), - install(AppDir, AppDir, Opts), - clean_meta, - halt. - - -%! install( -%! +ApplicationDirectory:atom, -%! +LibraryDirectory:atom, -%! +Options:list(compound) -%! ) is det. - -install(AppDir, LibDir, Opts):- - % The pack information is taken from the library directory. - % This allows application requirements to be installed recursively. - directory_file_path(LibDir, 'pack.pl', Info), - access_file(Info, read), - load_meta(Info), - - % Set this library's search path. - name(Name), - assert(user:file_search_path(Name, LibDir)), - - % Pull in the required libraries. - forall(requires(LibName), install_required(AppDir, LibName, Opts)), !. -install(_, _, _):- - msg_warning('Installation failed.'). - - -%! install_required( -%! +ApplicationDirectory:atom, -%! +LibName:atom, -%! +Options:list(compound) -%! ) is det. - -% Developer's delight: library already available from parent directory. -install_required(AppDir, LibName, Opts):- - option(parent(true), Opts), - - file_directory_name(AppDir, ParentDir), - append_directories(ParentDir, LibName, LibDir), - exists_directory(LibDir), !, - - % Print message. - atomic_list_concat(['Library ',LibName,' already installed.'], Msg), - msg_success(Msg). -% Install through the Prolog Pack system. -install_required(_, LibName, Opts):- - option(pack(true), Opts), - - prolog_pack:query_pack_server(search(LibName), Result,[]), - Result = true([pack(LibName,_,_,_,_)]), !, - pack_install(LibName). -% Install through Github. -install_required(AppDir, LibName, Opts):- - option(github(true), Opts), - - % Remove the old version of the library. - append_directories(AppDir, LibName, LibDir), - (exists_directory(LibDir) -> delete_directory_and_contents(LibDir) ; true), - - % Git clone the new version of the library. - atomic_list_concat(['',wouterbeek,LibName], /, Path), - uri_components(Iri, uri_components(https,'github.com',Path,_,_)), - prolog_pack:run_process(path(git), [clone,Iri,LibDir], []), - - % Print message. - atomic_list_concat(['Library ',LibName,' was installed.'], Msg), - msg_success(Msg), - - % Recurse - install(AppDir, LibDir, Opts), !. -% Oops! -install_required(_, LibName, _):- - atomic_list_concat( - ['Installation of library ',LibName,' failed.'], - Msg - ), - msg_warning(Msg). - - - - - -% HELPERS % - -%! append_directories(+Dir1:atom, +Dir2:atom, -Dir3:atom) is det. - -append_directories(Dir1, Dir2, Dir3):- - atomic_list_concat(Subdirs1, /, Dir1), - atomic_list_concat(Subdirs2, /, Dir2), - append(Subdirs1, Subdirs2, Subdirs3), - atomic_list_concat(Subdirs3, /, Dir3). - - - -%! clean_meta is det. - -clean_meta:- - retractall(author/2), - retractall(download/1), - retractall(home/1), - retractall(maintainer/2), - retractall(name/1), - retractall(packager/2), - retractall(requires/1), - retractall(title/1), - retractall(version/1). - - - -%! show_help(+OptionSpecification:list(compound)) is det. - -show_help(OptSpec):- - opt_help(OptSpec, Help), - format(user_output, '~a\n', [Help]), - halt. - - - -%! load_meta(+File:atom) is det. - -load_meta(File):- - clean_meta, - ensure_loaded(File). - - - -%! msg_success(+Message:atom) is det. - -msg_success(X):- - ansi_format([bold,fg(green)], '~a~n', [X]). - - - -%! msg_warning(+Message:atom) is det. - -msg_warning(X):- - ansi_format([bold,fg(red)], '~a~n', [X]). ```

128: 正在比较变动前 63a5cd7 和变动后 ce95c3c

[back to content](#compare) ``` diff diff --git a/prolog/gv/gv_attrs.pl b/prolog/gv/gv_attrs.pl index 99d6059..1fd4a18 100644 --- a/prolog/gv/gv_attrs.pl +++ b/prolog/gv/gv_attrs.pl @@ -9,17 +9,18 @@ /** GraphViz attributes @author Wouter Beek -@version 2015/07-2015/08 +@version 2015/07-2015/08, 2015/10 */ :- use_module(library(apply)). -:- use_module(library(deb_ext)). +:- use_module(library(debug_ext)). :- use_module(library(dcg/basics)). :- use_module(library(dcg/dcg_call)). :- use_module(library(dcg/dcg_phrase)). :- use_module(library(gv/gv_attr_type), [gv_attr_type//1]). :- use_module(library(http/http_download)). :- use_module(library(lists)). +:- use_module(library(msg_ext)). :- use_module(library(os/file_ext)). :- use_module(library(persistency)). :- use_module(library(xpath)). @@ -35,15 +36,15 @@ %! ) is nondet. :- persistent( - gv_attr( - name:atom, - used_by:list(oneof([cluster,edge,graph,node,subgraph])), - types:list(atom), - default, - minimum, - notes:atom - ) -). + gv_attr( + name:atom, + used_by:list(oneof([cluster,edge,graph,node,subgraph])), + types:list(atom), + default, + minimum, + notes:atom + ) + ). :- initialization(gv_attrs_init). @@ -122,8 +123,8 @@ assert_gv_attr_row([Name,UsedBy1,Types1,Default1,Minimum,Notes]):- gv_attrs_download:- verbose( - gv_attrs_download0 - "updating GraphViz attributes table", + gv_attrs_download0, + "updating GraphViz attributes table" ). gv_attrs_download0:- diff --git a/prolog/gv/gv_color.pl b/prolog/gv/gv_color.pl index 2c56713..fa79bea 100644 --- a/prolog/gv/gv_color.pl +++ b/prolog/gv/gv_color.pl @@ -13,16 +13,17 @@ @author Wouter Beek @tbd Color value `transparent` is only available in the output formats ps, svg, fig, vmrl, and the bitmap formats. -@version 2015/08 +@version 2015/08, 2015/10 */ :- use_module(library(apply)). -:- use_module(library(deb_ext)). +:- use_module(library(debug_ext)). :- use_module(library(dcg/basics)). :- use_module(library(dcg/dcg_abnf)). :- use_module(library(dcg/dcg_content)). :- use_module(library(http/http_download)). :- use_module(library(lists)). +:- use_module(library(msg_ext)). :- use_module(library(os/file_ext)). :- use_module(library(persistency)). :- use_module(library(xpath)). ```

129: 正在比较变动前 ce95c3c 和变动后 44cd5a6

[back to content](#compare) ``` diff diff --git a/prolog/gv/gv_attr_type.pl b/prolog/gv/gv_attr_type.pl index b0dbd69..5ab08a6 100644 --- a/prolog/gv/gv_attr_type.pl +++ b/prolog/gv/gv_attr_type.pl @@ -202,11 +202,14 @@ doubleList(L) --> -%! escString(+String:atom)// . +%! escString(+String:or([atom,string]))// . % @tbd Support for context-dependent replacements. escString(S1) --> - {atom_phrase(escape_double_quotes, S1, S2)}, + {( string(S1) + -> string_phrase(escape_double_quotes, S1, S2) + ; atom_phrase(escape_double_quotes, S1, S2) + )}, quoted(atom(S2)). escape_double_quotes, [92,34] --> diff --git a/prolog/gv/gv_graph_comp.pl b/prolog/gv/gv_graph_comp.pl index 033d0b9..3aec4e6 100644 --- a/prolog/gv/gv_graph_comp.pl +++ b/prolog/gv/gv_graph_comp.pl @@ -26,7 +26,7 @@ a_list = ID "=" ID [","] [a_list] @author Wouter Beek @see http://www.graphviz.org/content/dot-language -@version 2015/07-2015/08 +@version 2015/07-2015/08, 2015/10 */ :- use_module(library(apply)). @@ -38,6 +38,7 @@ a_list = ID "=" ID [","] [a_list] :- use_module(library(dcg/dcg_quoted)). :- use_module(library(gv/gv_attrs)). :- use_module(library(gv/gv_html)). +:- use_module(library(error)). :- use_module(library(lists)). :- use_module(library(ordsets)). @@ -82,8 +83,9 @@ gv_edge_statement(I, Dir, edge(From,To,Attrs)) --> % @arg Directed Whether an edge is directed (operator `->`) or % undirected (operator `--`). -gv_edge_operator(false) --> !, "--". -gv_edge_operator(true) --> "->". +gv_edge_operator(Dir) --> + {must_be(boolean, Dir)}, + ({Dir == false} -> "--" ; {Dir == true} -> "->"). @@ -113,9 +115,9 @@ gv_generic_attributes_statement(Kind, I, Attrs) --> %! gv_kind(+Kind:oneof([edge,graph,node]))// . -gv_kind(edge) --> "edge". -gv_kind(graph) --> "graph". -gv_kind(node) --> "node". +gv_kind(Kind) --> + {must_be(oneof([edge,graph,node]), Kind)}, + atom(Kind). @@ -142,8 +144,8 @@ gv_ranked_node_collection0(I, rank(Rank_V_Term,Content_V_Terms)) --> % The rank attribute. {NewI is I + 1}, indent(NewI), - gv_attr(subgraph, rank=same), - ";\n", + gv_attr(subgraph, rank(same)), + "\n", % Vertice statements. *( @@ -170,10 +172,8 @@ gv_ranked_node_collection0(I, rank(Rank_V_Term,Content_V_Terms)) --> gv_attrs(Kind, L) --> bracketed(square, *(gv_attr(Kind), L, [])). -%! gv_attr( -%! +Context:oneof([edge,graph,node]), -%! +Attribute:nvpair -%! )// is det. + +%! gv_attr(+Context:oneof([edge,graph,node]), +Attribute:compound)// is det. % A single GraphViz attribute. % We assume that the attribute has already been validated. @@ -276,10 +276,12 @@ gv_keyword --> "subgraph". % inside GraphViz node identifiers. gv_node_id(Id) --> - gv_id(Id). + gv_id(Id), !. %gv_node_id(_) --> % gv_id(_), % gv_port. +gv_node_id(Id) --> + {type_error(gv_node_id, Id)}. ```

130: 正在比较变动前 44cd5a6 和变动后 c0c5e18

[back to content](#compare) ``` diff diff --git a/prolog/graph/build_export_graph.pl b/prolog/graph/build_export_graph.pl index 507e8ad..b6d367b 100644 --- a/prolog/graph/build_export_graph.pl +++ b/prolog/graph/build_export_graph.pl @@ -1,9 +1,9 @@ :- module( build_export_graph, [ - build_export_graph/2, % +Graph:compound + build_export_graph/2, % +Graph % -ExportGraph:compound - build_export_graph/3 % +Graph:compound + build_export_graph/3 % +Graph % -ExportGraph:compound % +Options:list(compound) ] @@ -18,13 +18,13 @@ Support for building GIF representations. ## Graph ```prolog -graph(Vs:ordset(compound),Ranks,Es:compound,Attributes:list(nvpair)) +graph(Vs:ordset(compound),Ranks,Es:compound,Attributes:list(compound)) ``` ### Edge ```prolog -edge(FromVertexId,ToVertexId,Attributes:list(nvpair)) +edge(FromVertexId,ToVertexId,Attributes:list(compound)) ``` ### Rank @@ -36,7 +36,7 @@ rank(RankVertex:compound,ContentVertices:ordset(compound)) ### Vertex ```prolog -vertex(Id,Attributes:list(nvpair)) +vertex(Id,Attributes:list(compound)) ``` # Property functions @@ -51,10 +51,12 @@ Vertex coordinates: --- @author Wouter Beek -@version 2015/07, 2015/09 +@version 2015/07, 2015/09-2015/10 */ :- use_module(library(apply)). +:- use_module(library(graph/s/s_graph)). +:- use_module(library(lambda)). :- use_module(library(list_ext)). :- use_module(library(option_ext)). :- use_module(library(ordsets)). @@ -112,34 +114,32 @@ is_meta(vertex_uri). -%! build_export_graph(+Graph:compound, -ExportGraph:compound) is det. +%! build_export_graph(+Graph, -ExportGraph:compound) is det. +% Wrapper around build_export_graph/3. build_export_graph(G, ExportG):- build_export_graph(G, ExportG, []). + %! build_export_graph( -%! +Graph:compound, +%! +Graph, %! -ExportGraph:compound, %! +Options:list(compound) %! ) is det. +% Graph is either: +% * a coumpound term `graph(Vs,Es)`, or +% * an unlabeled graph as defined by `library(ugraph)`. -build_export_graph(graph(Vs,Es), graph(VTerms,ETerms,GAttrs), Opts1):- +build_export_graph(G, graph(VTerms,ETerms,GAttrs), Opts1):- + graph_components(G, Vs, Es), meta_options(is_meta, Opts1, Opts2), - - % V terms. - maplist(vertex_term0(Vs, Opts2), Vs, VTerms), - - % Edge terms. - maplist(edge_term0(Vs, Opts2), Es, ETerms), - - % Graph attributes. + maplist(\V^VTerm^vertex_term(Vs, V, VTerm, Opts2), Vs, VTerms), + maplist(\E^ETerm^edge_term(Vs, E, ETerm, Opts2), Es, ETerms), graph_attributes(GAttrs, Opts2). -vertex_term0(Vs, Opts, V, VTerm):- - vertex_term(Vs, V, VTerm, Opts). - -edge_term0(Vs, Opts, E, ETerm):- - edge_term(Vs, E, ETerm, Opts). +graph_components(graph(Vs,Es), Vs, Es):- !. +graph_components(G, Vs, Es):- + s_graph_components(G, Vs, Es). @@ -178,12 +178,9 @@ edge_term(Vs, E, edge(FromId,ToId,EAttrs), Opts):- % Id. ( option(edge_id(IdFunction), Opts) -> call(IdFunction, E, FromId, ToId) - ; ( E = edge(FromV,_,ToV) - -> true - ; E = edge(FromV,ToV) - ), - nth0chk(FromId, Vs, FromV), - nth0chk(ToId, Vs, ToV) + ; edge_components(E, FromV, ToV), + nth0chk(FromId, Vs, FromV), + nth0chk(ToId, Vs, ToV) ), % Label. @@ -215,7 +212,7 @@ edge_term(Vs, E, edge(FromId,ToId,EAttrs), Opts):- %! graph_attributes( -%! -GraphAttributes:list(nvpair), +%! -GraphAttributes:list(compound), %! +Options:list(compound) %! ) is det. % The following options are supported: @@ -358,7 +355,15 @@ vertex_term(Vs, V, vertex(VId,VAttrs), Opts):- % HELPERS % -%! merge_options(+FromOptions:list(nvpair), -ToOptions:list(nvpair)) is det. +%! edge_components(+Edge:compound, -FromV, -ToV) is det. + +edge_components(edge(FromV,_,ToV), FromV, ToV):- !. +edge_components(edge(FromV,ToV), FromV, ToV):- !. +edge_components(FromV-ToV, FromV, ToV):- !. + + + +%! merge_options(+FromOptions:list(compound), -ToOptions:list(compound)) is det. merge_options([], []). % Skip uninstantiated values. ```

131: 正在比较变动前 c0c5e18 和变动后 603344f

[back to content](#compare) ``` diff diff --git a/data/gv_attrs_scrape.pl b/data/gv_attrs_scrape.pl new file mode 100644 index 0000000..190b988 --- /dev/null +++ b/data/gv_attrs_scrape.pl @@ -0,0 +1,124 @@ +:- module( + gv_attrs_scrape, + [ + gv_attrs_scrape/1 % +File:atom + ] +). + +/** GraphViz: Scrape attributes + +Writes compound terms of the following form to file: + +```prolog +gv_attr( + ?Name:atom, + ?UsedBy:list(oneof([cluster,edge,graph,node,subgraph])), + ?Types:list(atom), + ?Default, + ?Minimum, + ?Notes:atom +) is nondet. +``` + +@author Wouter Beek +@version 2015/10 +*/ + +:- use_module(library(apply)). +:- use_module(library(dcg/basics), except([string//1])). +:- use_module(library(dcg/dcg_phrase)). +:- use_module(library(gv/gv_attr_type)). +:- use_module(library(http/http_download)). +:- use_module(library(iostream)). +:- use_module(library(lists)). +:- use_module(library(msg_ext)). +:- use_module(library(pl/pl_term)). +:- use_module(library(xpath)). +:- use_module(library(xpath/xpath_table)). + + + + + +%! gv_attrs_scrape(+File:atom) is det. + +gv_attrs_scrape(File):- + setup_call_cleanup( + open_any(File, write, Write, Close, []), + verbose( + gv_attrs_download(Write), + "Updating the GraphViz attributes table." + ), + close_any(Close) + ). + + +gv_attrs_download(Write):- + gv_attrs_iri(Iri), + html_download(Iri, Dom), + xpath_chk(Dom, //table(@align=lower_case(center)), TableDom), + xpath_table(TableDom, _, Rows), + maplist(write_attr_row(Write), Rows). + + +write_attr_row(Write, [Name,UsedBy1,Types1,Default1,Minimum,Notes]):- + atom_phrase(translate_usedby(UsedBy2), UsedBy1), + once(atom_phrase(translate_type(Types2), Types1)), + sort(UsedBy2, UsedBy3), + translate_default(Default1, Default2), + with_output_to( + Write, + write_fact(gv_attr(Name, UsedBy3, Types2, Default2, Minimum, Notes)) + ). + +gv_attrs_iri('http://www.graphviz.org/doc/info/attrs.html'). + + + + + +% HELPERS % + +%! translate_default(+Default1:atom, -Default2:atom) is det. + +% The empty string is represented by the empty atom. +translate_default('""', ''):- !. +% The absence of a default value is represented by an uninstantiated variable. +translate_default('', _):- !. +translate_default(Default, Default). + + + +%! translate_type(-Types:list(atom))// is det. + +translate_type([H|T]) --> + gv_attr_type(H), + whites, + translate_type(T). +translate_type([H]) --> + gv_attr_type(H). +translate_type([]) --> "". + + + +%! translated_usedby( +%! -UsedBy:list(oneof([cluster,edge,graph,node,subgraph])) +%! )// is det. + +translate_usedby([cluster|T]) --> + "C", !, + translate_usedby(T). +translate_usedby([edge|T]) --> + "E", !, + translate_usedby(T). +translate_usedby([graph|T]) --> + "G", !, + translate_usedby(T). +translate_usedby([node|T]) --> + "N", !, + translate_usedby(T). +translate_usedby([subgraph|T]) --> + "S", !, + translate_usedby(T). +translate_usedby([]) --> + "". diff --git a/data/gv_color_scrape.pl b/data/gv_color_scrape.pl new file mode 100644 index 0000000..3ac5d44 --- /dev/null +++ b/data/gv_color_scrape.pl @@ -0,0 +1,56 @@ +:- module( + gv_color_scrape, + [ + gv_color_scrape/1 % +File:atom + ] +). + +/** GraphViz: Scrape colors + +@author Wouter Beek +@version 2015/10 +*/ + +:- use_module(library(apply)). +:- use_module(library(http/http_download)). +:- use_module(library(iostream)). +:- use_module(library(lists)). +:- use_module(library(msg_ext)). +:- use_module(library(pl/pl_term)). +:- use_module(library(xpath)). +:- use_module(library(xpath/xpath_table)). + + + + + +%! gv_color_scrape(+File:atom) is det. + +gv_color_scrape(File):- + setup_call_cleanup( + open_any(File, write, Write, Close, []), + verbose( + gv_color_download(Write), + "Updating the GraphViz color table." + ), + close_any(Close) + ). + + +gv_color_download(Write):- + gv_color_iri(Iri), + html_download(Iri, Dom), + xpath_chk(Dom, //table(1), TableDom1), + xpath_chk(Dom, //table(2), TableDom2), + maplist(write_color_table(Write), [x11,svg], [TableDom1,TableDom2]). + + +write_color_table(Write, Colorscheme, TableDom):- + xpath_table(TableDom, _, Rows), + append(Rows, Cells), + forall( + member(Cell, Cells), + with_output_to(Write, write_fact(gv_color(Colorscheme, Cell))) + ). + +gv_color_iri('http://www.graphviz.org/doc/info/colors.html'). diff --git a/gv_attrs.log b/gv_attrs.log deleted file mode 100644 index a9c6010..0000000 --- a/gv_attrs.log +++ /dev/null @@ -1,169 +0,0 @@ -assert(gv_attr('Damping',[graph],[double],'0.99','0.0','neato only')). -assert(gv_attr('K',[cluster,graph],[double],'0.3','0','sfdp, fdp only')). -assert(gv_attr('URL',[cluster,edge,graph,node],[escString],_,'','svg, postscript, map only')). -assert(gv_attr('_background',[graph],[string],_,'','')). -assert(gv_attr(area,[cluster,node],[double],'1.0','>0','patchwork only')). -assert(gv_attr(arrowhead,[edge],[arrowType],normal,'','')). -assert(gv_attr(arrowsize,[edge],[double],'1.0','0.0','')). -assert(gv_attr(arrowtail,[edge],[arrowType],normal,'','')). -assert(gv_attr(bb,[graph],[rect],'','','write only')). -assert(gv_attr(bgcolor,[cluster,graph],[color,colorList],_,'','')). -assert(gv_attr(center,[graph],[bool],false,'','')). -assert(gv_attr(charset,[graph],[string],'"UTF-8"','','')). -assert(gv_attr(clusterrank,[graph],[clusterMode],local,'','dot only')). -assert(gv_attr(color,[cluster,edge,node],[color,colorList],black,'','')). -assert(gv_attr(colorscheme,[cluster,edge,graph,node],[string],'','','')). -assert(gv_attr(comment,[edge,graph,node],[string],'','','')). -assert(gv_attr(compound,[graph],[bool],false,'','dot only')). -assert(gv_attr(concentrate,[graph],[bool],false,'','')). -assert(gv_attr(constraint,[edge],[bool],true,'','dot only')). -assert(gv_attr(decorate,[edge],[bool],false,'','')). -assert(gv_attr(defaultdist,[graph],[double],'1+(avg. len)*sqrt(|V|)',epsilon,'neato only')). -assert(gv_attr(dim,[graph],[int],'2','2','sfdp, fdp, neato only')). -assert(gv_attr(dimen,[graph],[int],'2','2','sfdp, fdp, neato only')). -assert(gv_attr(dir,[edge],[dirType],'forward(directed)none(undirected)','','')). -assert(gv_attr(diredgeconstraints,[graph],[string,bool],false,'','neato only')). -assert(gv_attr(distortion,[node],[double],'0.0','-100.0','')). -assert(gv_attr(dpi,[graph],[double],'96.00.0','','svg, bitmap output only')). -assert(gv_attr(edgeURL,[edge],[escString],'','','svg, map only')). -assert(gv_attr(edgehref,[edge],[escString],'','','svg, map only')). -assert(gv_attr(edgetarget,[edge],[escString],_,'','svg, map only')). -assert(gv_attr(edgetooltip,[edge],[escString],'','','svg, cmap only')). -assert(gv_attr(epsilon,[graph],[double],'.0001 * # nodes(mode == KK).0001(mode == major)','','neato only')). -assert(gv_attr(esep,[graph],[addDouble,addPoint],'+3','','not dot')). -assert(gv_attr(fillcolor,[cluster,edge,node],[color,colorList],'lightgrey(nodes)black(clusters)','','')). -assert(gv_attr(fixedsize,[node],[bool,string],false,'','')). -assert(gv_attr(fontcolor,[cluster,edge,graph,node],[color],black,'','')). -assert(gv_attr(fontname,[cluster,edge,graph,node],[string],'"Times-Roman"','','')). -assert(gv_attr(fontnames,[graph],[string],'','','svg only')). -assert(gv_attr(fontpath,[graph],[string],'system-dependent','','')). -assert(gv_attr(fontsize,[cluster,edge,graph,node],[double],'14.0','1.0','')). -assert(gv_attr(forcelabels,[graph],[bool],true,'','')). -assert(gv_attr(gradientangle,[cluster,graph,node],[int],'','','')). -assert(gv_attr(group,[node],[string],'','','dot only')). -assert(gv_attr(headURL,[edge],[escString],'','','svg, map only')). -assert(gv_attr(head_lp,[edge],[point],'','','write only')). -assert(gv_attr(headclip,[edge],[bool],true,'','')). -assert(gv_attr(headhref,[edge],[escString],'','','svg, map only')). -assert(gv_attr(headlabel,[edge],[lblString],'','','')). -assert(gv_attr(headport,[edge],[portPos],center,'','')). -assert(gv_attr(headtarget,[edge],[escString],_,'','svg, map only')). -assert(gv_attr(headtooltip,[edge],[escString],'','','svg, cmap only')). -assert(gv_attr(height,[node],[double],'0.5','0.02','')). -assert(gv_attr(href,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only')). -assert(gv_attr(id,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only')). -assert(gv_attr(image,[node],[string],'','','')). -assert(gv_attr(imagepath,[graph],[string],'','','')). -assert(gv_attr(imagescale,[node],[bool,string],false,'','')). -assert(gv_attr(inputscale,[graph],[double],_,'','fdp, neato only')). -assert(gv_attr(label,[cluster,edge,graph,node],[lblString],'"\\N" (nodes)"" (otherwise)','','')). -assert(gv_attr(labelURL,[edge],[escString],'','','svg, map only')). -assert(gv_attr(label_scheme,[graph],[int],'0','0','sfdp only')). -assert(gv_attr(labelangle,[edge],[double],'-25.0','-180.0','')). -assert(gv_attr(labeldistance,[edge],[double],'1.0','0.0','')). -assert(gv_attr(labelfloat,[edge],[bool],false,'','')). -assert(gv_attr(labelfontcolor,[edge],[color],black,'','')). -assert(gv_attr(labelfontname,[edge],[string],'"Times-Roman"','','')). -assert(gv_attr(labelfontsize,[edge],[double],'14.0','1.0','')). -assert(gv_attr(labelhref,[edge],[escString],'','','svg, map only')). -assert(gv_attr(labeljust,[cluster,graph],[string],'"c"','','')). -assert(gv_attr(labelloc,[cluster,graph,node],[string],'"t"(clusters)"b"(root graphs)"c"(nodes)','','')). -assert(gv_attr(labeltarget,[edge],[escString],_,'','svg, map only')). -assert(gv_attr(labeltooltip,[edge],[escString],'','','svg, cmap only')). -assert(gv_attr(landscape,[graph],[bool],false,'','')). -assert(gv_attr(layer,[cluster,edge,node],[layerRange],'','','')). -assert(gv_attr(layerlistsep,[graph],[string],'","','','')). -assert(gv_attr(layers,[graph],[layerList],'','','')). -assert(gv_attr(layerselect,[graph],[layerRange],'','','')). -assert(gv_attr(layersep,[graph],[string],'" :\\t"','','')). -assert(gv_attr(layout,[graph],[string],'','','')). -assert(gv_attr(len,[edge],[double],'1.0(neato)0.3(fdp)','','fdp, neato only')). -assert(gv_attr(levels,[graph],[int],'MAXINT','0.0','sfdp only')). -assert(gv_attr(levelsgap,[graph],[double],'0.0','','neato only')). -assert(gv_attr(lhead,[edge],[string],'','','dot only')). -assert(gv_attr(lheight,[cluster,graph],[double],'','','write only')). -assert(gv_attr(lp,[cluster,edge,graph],[point],'','','write only')). -assert(gv_attr(ltail,[edge],[string],'','','dot only')). -assert(gv_attr(lwidth,[cluster,graph],[double],'','','write only')). -assert(gv_attr(margin,[cluster,graph,node],[double,point],'','','')). -assert(gv_attr(maxiter,[graph],[int],'100 * # nodes(mode == KK)200(mode == major)600(fdp)','','fdp, neato only')). -assert(gv_attr(mclimit,[graph],[double],'1.0','','dot only')). -assert(gv_attr(mindist,[graph],[double],'1.0','0.0','circo only')). -assert(gv_attr(minlen,[edge],[int],'1','0','dot only')). -assert(gv_attr(mode,[graph],[string],major,'','neato only')). -assert(gv_attr(model,[graph],[string],shortpath,'','neato only')). -assert(gv_attr(mosek,[graph],[bool],false,'','neato only')). -assert(gv_attr(nodesep,[graph],[double],'0.25','0.02','')). -assert(gv_attr(nojustify,[cluster,edge,graph,node],[bool],false,'','')). -assert(gv_attr(normalize,[graph],[double,bool],false,'','not dot')). -assert(gv_attr(notranslate,[graph],[bool],false,'','neato only')). -assert(gv_attr('nslimit nslimit1',[graph],[double],'','','dot only')). -assert(gv_attr(ordering,[graph,node],[string],'','','dot only')). -assert(gv_attr(orientation,[node],[double],'0.0','360.0','')). -assert(gv_attr(orientation,[graph],[string],'','','')). -assert(gv_attr(outputorder,[graph],[outputMode],breadthfirst,'','')). -assert(gv_attr(overlap,[graph],[string,bool],true,'','not dot')). -assert(gv_attr(overlap_scaling,[graph],[double],'-4','-1.0e10','prism only')). -assert(gv_attr(overlap_shrink,[graph],[bool],true,'','prism only')). -assert(gv_attr(pack,[graph],[bool,int],false,'','')). -assert(gv_attr(packmode,[graph],[packMode],node,'','')). -assert(gv_attr(pad,[graph],[double,point],'0.0555 (4 points)','','')). -assert(gv_attr(page,[graph],[double,point],'','','')). -assert(gv_attr(pagedir,[graph],[pagedir],'BL','','')). -assert(gv_attr(pencolor,[cluster],[color],black,'','')). -assert(gv_attr(penwidth,[cluster,edge,node],[double],'1.0','0.0','')). -assert(gv_attr(peripheries,[cluster,node],[int],'shape default(nodes)1(clusters)','0','')). -assert(gv_attr(pin,[node],[bool],false,'','fdp, neato only')). -assert(gv_attr(pos,[edge,node],[point,splineType],'','','')). -assert(gv_attr(quadtree,[graph],[quadType,bool],normal,'','sfdp only')). -assert(gv_attr(quantum,[graph],[double],'0.0','0.0','')). -assert(gv_attr(rank,[subgraph],[rankType],'','','dot only')). -assert(gv_attr(rankdir,[graph],[rankdir],'TB','','dot only')). -assert(gv_attr(ranksep,[graph],[double,doubleList],'0.5(dot)1.0(twopi)','0.02','twopi, dot only')). -assert(gv_attr(ratio,[graph],[double,string],'','','')). -assert(gv_attr(rects,[node],[rect],'','','write only')). -assert(gv_attr(regular,[node],[bool],false,'','')). -assert(gv_attr(remincross,[graph],[bool],true,'','dot only')). -assert(gv_attr(repulsiveforce,[graph],[double],'1.0','0.0','sfdp only')). -assert(gv_attr(resolution,[graph],[double],'96.00.0','','svg, bitmap output only')). -assert(gv_attr(root,[graph,node],[string,bool],'(graphs)false(nodes)','','circo, twopi only')). -assert(gv_attr(rotate,[graph],[int],'0','','')). -assert(gv_attr(rotation,[graph],[double],'0','','sfdp only')). -assert(gv_attr(samehead,[edge],[string],'','','dot only')). -assert(gv_attr(sametail,[edge],[string],'','','dot only')). -assert(gv_attr(samplepoints,[node],[int],'8(output)20(overlap and image maps)','','')). -assert(gv_attr(scale,[graph],[double,point],'','','not dot')). -assert(gv_attr(searchsize,[graph],[int],'30','','dot only')). -assert(gv_attr(sep,[graph],[addDouble,addPoint],'+4','','not dot')). -assert(gv_attr(shape,[node],[shape],ellipse,'','')). -assert(gv_attr(shapefile,[node],[string],'','','')). -assert(gv_attr(showboxes,[edge,graph,node],[int],'0','0','dot only')). -assert(gv_attr(sides,[node],[int],'4','0','')). -assert(gv_attr(size,[graph],[double,point],'','','')). -assert(gv_attr(skew,[node],[double],'0.0','-100.0','')). -assert(gv_attr(smoothing,[graph],[smoothType],'"none"','','sfdp only')). -assert(gv_attr(sortv,[cluster,graph,node],[int],'0','0','')). -assert(gv_attr(splines,[graph],[bool,string],'','','')). -assert(gv_attr(start,[graph],[startType],'','','fdp, neato only')). -assert(gv_attr(style,[cluster,edge,graph,node],[style],'','','')). -assert(gv_attr(stylesheet,[graph],[string],'','','svg only')). -assert(gv_attr(tailURL,[edge],[escString],'','','svg, map only')). -assert(gv_attr(tail_lp,[edge],[point],'','','write only')). -assert(gv_attr(tailclip,[edge],[bool],true,'','')). -assert(gv_attr(tailhref,[edge],[escString],'','','svg, map only')). -assert(gv_attr(taillabel,[edge],[lblString],'','','')). -assert(gv_attr(tailport,[edge],[portPos],center,'','')). -assert(gv_attr(tailtarget,[edge],[escString],_,'','svg, map only')). -assert(gv_attr(tailtooltip,[edge],[escString],'','','svg, cmap only')). -assert(gv_attr(target,[cluster,edge,graph,node],[escString,string],_,'','svg, map only')). -assert(gv_attr(tooltip,[cluster,edge,node],[escString],'','','svg, cmap only')). -assert(gv_attr(truecolor,[graph],[bool],'','','bitmap output only')). -assert(gv_attr(vertices,[node],[pointList],'','','write only')). -assert(gv_attr(viewport,[graph],[viewPort],'','','')). -assert(gv_attr(voro_margin,[graph],[double],'0.05','0.0','not dot')). -assert(gv_attr(weight,[edge],[int,double],'1','0(dot,twopi)1(neato,fdp)','')). -assert(gv_attr(width,[node],[double],'0.75','0.01','')). -assert(gv_attr(xdotversion,[graph],[string],'','','xdot only')). -assert(gv_attr(xlabel,[edge,node],[lblString],'','','')). -assert(gv_attr(xlp,[edge,node],[point],'','','write only')). -assert(gv_attr(z,[node],[double],'0.0','-MAXFLOAT-1000','')). diff --git a/gv_color.log b/gv_color.log deleted file mode 100644 index 23d6cdf..0000000 --- a/gv_color.log +++ /dev/null @@ -1,802 +0,0 @@ -assert(gv_color(x11,aliceblue)). -assert(gv_color(x11,antiquewhite)). -assert(gv_color(x11,antiquewhite1)). -assert(gv_color(x11,antiquewhite2)). -assert(gv_color(x11,antiquewhite3)). -assert(gv_color(x11,antiquewhite4)). -assert(gv_color(x11,aquamarine)). -assert(gv_color(x11,aquamarine1)). -assert(gv_color(x11,aquamarine2)). -assert(gv_color(x11,aquamarine3)). -assert(gv_color(x11,aquamarine4)). -assert(gv_color(x11,azure)). -assert(gv_color(x11,azure1)). -assert(gv_color(x11,azure2)). -assert(gv_color(x11,azure3)). -assert(gv_color(x11,azure4)). -assert(gv_color(x11,beige)). -assert(gv_color(x11,bisque)). -assert(gv_color(x11,bisque1)). -assert(gv_color(x11,bisque2)). -assert(gv_color(x11,bisque3)). -assert(gv_color(x11,bisque4)). -assert(gv_color(x11,black)). -assert(gv_color(x11,blanchedalmond)). -assert(gv_color(x11,blue)). -assert(gv_color(x11,blue1)). -assert(gv_color(x11,blue2)). -assert(gv_color(x11,blue3)). -assert(gv_color(x11,blue4)). -assert(gv_color(x11,blueviolet)). -assert(gv_color(x11,brown)). -assert(gv_color(x11,brown1)). -assert(gv_color(x11,brown2)). -assert(gv_color(x11,brown3)). -assert(gv_color(x11,brown4)). -assert(gv_color(x11,burlywood)). -assert(gv_color(x11,burlywood1)). -assert(gv_color(x11,burlywood2)). -assert(gv_color(x11,burlywood3)). -assert(gv_color(x11,burlywood4)). -assert(gv_color(x11,cadetblue)). -assert(gv_color(x11,cadetblue1)). -assert(gv_color(x11,cadetblue2)). -assert(gv_color(x11,cadetblue3)). -assert(gv_color(x11,cadetblue4)). -assert(gv_color(x11,chartreuse)). -assert(gv_color(x11,chartreuse1)). -assert(gv_color(x11,chartreuse2)). -assert(gv_color(x11,chartreuse3)). -assert(gv_color(x11,chartreuse4)). -assert(gv_color(x11,chocolate)). -assert(gv_color(x11,chocolate1)). -assert(gv_color(x11,chocolate2)). -assert(gv_color(x11,chocolate3)). -assert(gv_color(x11,chocolate4)). -assert(gv_color(x11,coral)). -assert(gv_color(x11,coral1)). -assert(gv_color(x11,coral2)). -assert(gv_color(x11,coral3)). -assert(gv_color(x11,coral4)). -assert(gv_color(x11,cornflowerblue)). -assert(gv_color(x11,cornsilk)). -assert(gv_color(x11,cornsilk1)). -assert(gv_color(x11,cornsilk2)). -assert(gv_color(x11,cornsilk3)). -assert(gv_color(x11,cornsilk4)). -assert(gv_color(x11,crimson)). -assert(gv_color(x11,cyan)). -assert(gv_color(x11,cyan1)). -assert(gv_color(x11,cyan2)). -assert(gv_color(x11,cyan3)). -assert(gv_color(x11,cyan4)). -assert(gv_color(x11,darkgoldenrod)). -assert(gv_color(x11,darkgoldenrod1)). -assert(gv_color(x11,darkgoldenrod2)). -assert(gv_color(x11,darkgoldenrod3)). -assert(gv_color(x11,darkgoldenrod4)). -assert(gv_color(x11,darkgreen)). -assert(gv_color(x11,darkkhaki)). -assert(gv_color(x11,darkolivegreen)). -assert(gv_color(x11,darkolivegreen1)). -assert(gv_color(x11,darkolivegreen2)). -assert(gv_color(x11,darkolivegreen3)). -assert(gv_color(x11,darkolivegreen4)). -assert(gv_color(x11,darkorange)). -assert(gv_color(x11,darkorange1)). -assert(gv_color(x11,darkorange2)). -assert(gv_color(x11,darkorange3)). -assert(gv_color(x11,darkorange4)). -assert(gv_color(x11,darkorchid)). -assert(gv_color(x11,darkorchid1)). -assert(gv_color(x11,darkorchid2)). -assert(gv_color(x11,darkorchid3)). -assert(gv_color(x11,darkorchid4)). -assert(gv_color(x11,darksalmon)). -assert(gv_color(x11,darkseagreen)). -assert(gv_color(x11,darkseagreen1)). -assert(gv_color(x11,darkseagreen2)). -assert(gv_color(x11,darkseagreen3)). -assert(gv_color(x11,darkseagreen4)). -assert(gv_color(x11,darkslateblue)). -assert(gv_color(x11,darkslategray)). -assert(gv_color(x11,darkslategray1)). -assert(gv_color(x11,darkslategray2)). -assert(gv_color(x11,darkslategray3)). -assert(gv_color(x11,darkslategray4)). -assert(gv_color(x11,darkslategrey)). -assert(gv_color(x11,darkturquoise)). -assert(gv_color(x11,darkviolet)). -assert(gv_color(x11,deeppink)). -assert(gv_color(x11,deeppink1)). -assert(gv_color(x11,deeppink2)). -assert(gv_color(x11,deeppink3)). -assert(gv_color(x11,deeppink4)). -assert(gv_color(x11,deepskyblue)). -assert(gv_color(x11,deepskyblue1)). -assert(gv_color(x11,deepskyblue2)). -assert(gv_color(x11,deepskyblue3)). -assert(gv_color(x11,deepskyblue4)). -assert(gv_color(x11,dimgray)). -assert(gv_color(x11,dimgrey)). -assert(gv_color(x11,dodgerblue)). -assert(gv_color(x11,dodgerblue1)). -assert(gv_color(x11,dodgerblue2)). -assert(gv_color(x11,dodgerblue3)). -assert(gv_color(x11,dodgerblue4)). -assert(gv_color(x11,firebrick)). -assert(gv_color(x11,firebrick1)). -assert(gv_color(x11,firebrick2)). -assert(gv_color(x11,firebrick3)). -assert(gv_color(x11,firebrick4)). -assert(gv_color(x11,floralwhite)). -assert(gv_color(x11,forestgreen)). -assert(gv_color(x11,gainsboro)). -assert(gv_color(x11,ghostwhite)). -assert(gv_color(x11,gold)). -assert(gv_color(x11,gold1)). -assert(gv_color(x11,gold2)). -assert(gv_color(x11,gold3)). -assert(gv_color(x11,gold4)). -assert(gv_color(x11,goldenrod)). -assert(gv_color(x11,goldenrod1)). -assert(gv_color(x11,goldenrod2)). -assert(gv_color(x11,goldenrod3)). -assert(gv_color(x11,goldenrod4)). -assert(gv_color(x11,gray)). -assert(gv_color(x11,gray0)). -assert(gv_color(x11,gray1)). -assert(gv_color(x11,gray10)). -assert(gv_color(x11,gray100)). -assert(gv_color(x11,gray11)). -assert(gv_color(x11,gray12)). -assert(gv_color(x11,gray13)). -assert(gv_color(x11,gray14)). -assert(gv_color(x11,gray15)). -assert(gv_color(x11,gray16)). -assert(gv_color(x11,gray17)). -assert(gv_color(x11,gray18)). -assert(gv_color(x11,gray19)). -assert(gv_color(x11,gray2)). -assert(gv_color(x11,gray20)). -assert(gv_color(x11,gray21)). -assert(gv_color(x11,gray22)). -assert(gv_color(x11,gray23)). -assert(gv_color(x11,gray24)). -assert(gv_color(x11,gray25)). -assert(gv_color(x11,gray26)). -assert(gv_color(x11,gray27)). -assert(gv_color(x11,gray28)). -assert(gv_color(x11,gray29)). -assert(gv_color(x11,gray3)). -assert(gv_color(x11,gray30)). -assert(gv_color(x11,gray31)). -assert(gv_color(x11,gray32)). -assert(gv_color(x11,gray33)). -assert(gv_color(x11,gray34)). -assert(gv_color(x11,gray35)). -assert(gv_color(x11,gray36)). -assert(gv_color(x11,gray37)). -assert(gv_color(x11,gray38)). -assert(gv_color(x11,gray39)). -assert(gv_color(x11,gray4)). -assert(gv_color(x11,gray40)). -assert(gv_color(x11,gray41)). -assert(gv_color(x11,gray42)). -assert(gv_color(x11,gray43)). -assert(gv_color(x11,gray44)). -assert(gv_color(x11,gray45)). -assert(gv_color(x11,gray46)). -assert(gv_color(x11,gray47)). -assert(gv_color(x11,gray48)). -assert(gv_color(x11,gray49)). -assert(gv_color(x11,gray5)). -assert(gv_color(x11,gray50)). -assert(gv_color(x11,gray51)). -assert(gv_color(x11,gray52)). -assert(gv_color(x11,gray53)). -assert(gv_color(x11,gray54)). -assert(gv_color(x11,gray55)). -assert(gv_color(x11,gray56)). -assert(gv_color(x11,gray57)). -assert(gv_color(x11,gray58)). -assert(gv_color(x11,gray59)). -assert(gv_color(x11,gray6)). -assert(gv_color(x11,gray60)). -assert(gv_color(x11,gray61)). -assert(gv_color(x11,gray62)). -assert(gv_color(x11,gray63)). -assert(gv_color(x11,gray64)). -assert(gv_color(x11,gray65)). -assert(gv_color(x11,gray66)). -assert(gv_color(x11,gray67)). -assert(gv_color(x11,gray68)). -assert(gv_color(x11,gray69)). -assert(gv_color(x11,gray7)). -assert(gv_color(x11,gray70)). -assert(gv_color(x11,gray71)). -assert(gv_color(x11,gray72)). -assert(gv_color(x11,gray73)). -assert(gv_color(x11,gray74)). -assert(gv_color(x11,gray75)). -assert(gv_color(x11,gray76)). -assert(gv_color(x11,gray77)). -assert(gv_color(x11,gray78)). -assert(gv_color(x11,gray79)). -assert(gv_color(x11,gray8)). -assert(gv_color(x11,gray80)). -assert(gv_color(x11,gray81)). -assert(gv_color(x11,gray82)). -assert(gv_color(x11,gray83)). -assert(gv_color(x11,gray84)). -assert(gv_color(x11,gray85)). -assert(gv_color(x11,gray86)). -assert(gv_color(x11,gray87)). -assert(gv_color(x11,gray88)). -assert(gv_color(x11,gray89)). -assert(gv_color(x11,gray9)). -assert(gv_color(x11,gray90)). -assert(gv_color(x11,gray91)). -assert(gv_color(x11,gray92)). -assert(gv_color(x11,gray93)). -assert(gv_color(x11,gray94)). -assert(gv_color(x11,gray95)). -assert(gv_color(x11,gray96)). -assert(gv_color(x11,gray97)). -assert(gv_color(x11,gray98)). -assert(gv_color(x11,gray99)). -assert(gv_color(x11,green)). -assert(gv_color(x11,green1)). -assert(gv_color(x11,green2)). -assert(gv_color(x11,green3)). -assert(gv_color(x11,green4)). -assert(gv_color(x11,greenyellow)). -assert(gv_color(x11,grey)). -assert(gv_color(x11,grey0)). -assert(gv_color(x11,grey1)). -assert(gv_color(x11,grey10)). -assert(gv_color(x11,grey100)). -assert(gv_color(x11,grey11)). -assert(gv_color(x11,grey12)). -assert(gv_color(x11,grey13)). -assert(gv_color(x11,grey14)). -assert(gv_color(x11,grey15)). -assert(gv_color(x11,grey16)). -assert(gv_color(x11,grey17)). -assert(gv_color(x11,grey18)). -assert(gv_color(x11,grey19)). -assert(gv_color(x11,grey2)). -assert(gv_color(x11,grey20)). -assert(gv_color(x11,grey21)). -assert(gv_color(x11,grey22)). -assert(gv_color(x11,grey23)). -assert(gv_color(x11,grey24)). -assert(gv_color(x11,grey25)). -assert(gv_color(x11,grey26)). -assert(gv_color(x11,grey27)). -assert(gv_color(x11,grey28)). -assert(gv_color(x11,grey29)). -assert(gv_color(x11,grey3)). -assert(gv_color(x11,grey30)). -assert(gv_color(x11,grey31)). -assert(gv_color(x11,grey32)). -assert(gv_color(x11,grey33)). -assert(gv_color(x11,grey34)). -assert(gv_color(x11,grey35)). -assert(gv_color(x11,grey36)). -assert(gv_color(x11,grey37)). -assert(gv_color(x11,grey38)). -assert(gv_color(x11,grey39)). -assert(gv_color(x11,grey4)). -assert(gv_color(x11,grey40)). -assert(gv_color(x11,grey41)). -assert(gv_color(x11,grey42)). -assert(gv_color(x11,grey43)). -assert(gv_color(x11,grey44)). -assert(gv_color(x11,grey45)). -assert(gv_color(x11,grey46)). -assert(gv_color(x11,grey47)). -assert(gv_color(x11,grey48)). -assert(gv_color(x11,grey49)). -assert(gv_color(x11,grey5)). -assert(gv_color(x11,grey50)). -assert(gv_color(x11,grey51)). -assert(gv_color(x11,grey52)). -assert(gv_color(x11,grey53)). -assert(gv_color(x11,grey54)). -assert(gv_color(x11,grey55)). -assert(gv_color(x11,grey56)). -assert(gv_color(x11,grey57)). -assert(gv_color(x11,grey58)). -assert(gv_color(x11,grey59)). -assert(gv_color(x11,grey6)). -assert(gv_color(x11,grey60)). -assert(gv_color(x11,grey61)). -assert(gv_color(x11,grey62)). -assert(gv_color(x11,grey63)). -assert(gv_color(x11,grey64)). -assert(gv_color(x11,grey65)). -assert(gv_color(x11,grey66)). -assert(gv_color(x11,grey67)). -assert(gv_color(x11,grey68)). -assert(gv_color(x11,grey69)). -assert(gv_color(x11,grey7)). -assert(gv_color(x11,grey70)). -assert(gv_color(x11,grey71)). -assert(gv_color(x11,grey72)). -assert(gv_color(x11,grey73)). -assert(gv_color(x11,grey74)). -assert(gv_color(x11,grey75)). -assert(gv_color(x11,grey76)). -assert(gv_color(x11,grey77)). -assert(gv_color(x11,grey78)). -assert(gv_color(x11,grey79)). -assert(gv_color(x11,grey8)). -assert(gv_color(x11,grey80)). -assert(gv_color(x11,grey81)). -assert(gv_color(x11,grey82)). -assert(gv_color(x11,grey83)). -assert(gv_color(x11,grey84)). -assert(gv_color(x11,grey85)). -assert(gv_color(x11,grey86)). -assert(gv_color(x11,grey87)). -assert(gv_color(x11,grey88)). -assert(gv_color(x11,grey89)). -assert(gv_color(x11,grey9)). -assert(gv_color(x11,grey90)). -assert(gv_color(x11,grey91)). -assert(gv_color(x11,grey92)). -assert(gv_color(x11,grey93)). -assert(gv_color(x11,grey94)). -assert(gv_color(x11,grey95)). -assert(gv_color(x11,grey96)). -assert(gv_color(x11,grey97)). -assert(gv_color(x11,grey98)). -assert(gv_color(x11,grey99)). -assert(gv_color(x11,honeydew)). -assert(gv_color(x11,honeydew1)). -assert(gv_color(x11,honeydew2)). -assert(gv_color(x11,honeydew3)). -assert(gv_color(x11,honeydew4)). -assert(gv_color(x11,hotpink)). -assert(gv_color(x11,hotpink1)). -assert(gv_color(x11,hotpink2)). -assert(gv_color(x11,hotpink3)). -assert(gv_color(x11,hotpink4)). -assert(gv_color(x11,indianred)). -assert(gv_color(x11,indianred1)). -assert(gv_color(x11,indianred2)). -assert(gv_color(x11,indianred3)). -assert(gv_color(x11,indianred4)). -assert(gv_color(x11,indigo)). -assert(gv_color(x11,invis)). -assert(gv_color(x11,ivory)). -assert(gv_color(x11,ivory1)). -assert(gv_color(x11,ivory2)). -assert(gv_color(x11,ivory3)). -assert(gv_color(x11,ivory4)). -assert(gv_color(x11,khaki)). -assert(gv_color(x11,khaki1)). -assert(gv_color(x11,khaki2)). -assert(gv_color(x11,khaki3)). -assert(gv_color(x11,khaki4)). -assert(gv_color(x11,lavender)). -assert(gv_color(x11,lavenderblush)). -assert(gv_color(x11,lavenderblush1)). -assert(gv_color(x11,lavenderblush2)). -assert(gv_color(x11,lavenderblush3)). -assert(gv_color(x11,lavenderblush4)). -assert(gv_color(x11,lawngreen)). -assert(gv_color(x11,lemonchiffon)). -assert(gv_color(x11,lemonchiffon1)). -assert(gv_color(x11,lemonchiffon2)). -assert(gv_color(x11,lemonchiffon3)). -assert(gv_color(x11,lemonchiffon4)). -assert(gv_color(x11,lightblue)). -assert(gv_color(x11,lightblue1)). -assert(gv_color(x11,lightblue2)). -assert(gv_color(x11,lightblue3)). -assert(gv_color(x11,lightblue4)). -assert(gv_color(x11,lightcoral)). -assert(gv_color(x11,lightcyan)). -assert(gv_color(x11,lightcyan1)). -assert(gv_color(x11,lightcyan2)). -assert(gv_color(x11,lightcyan3)). -assert(gv_color(x11,lightcyan4)). -assert(gv_color(x11,lightgoldenrod)). -assert(gv_color(x11,lightgoldenrod1)). -assert(gv_color(x11,lightgoldenrod2)). -assert(gv_color(x11,lightgoldenrod3)). -assert(gv_color(x11,lightgoldenrod4)). -assert(gv_color(x11,lightgoldenrodyellow)). -assert(gv_color(x11,lightgray)). -assert(gv_color(x11,lightgrey)). -assert(gv_color(x11,lightpink)). -assert(gv_color(x11,lightpink1)). -assert(gv_color(x11,lightpink2)). -assert(gv_color(x11,lightpink3)). -assert(gv_color(x11,lightpink4)). -assert(gv_color(x11,lightsalmon)). -assert(gv_color(x11,lightsalmon1)). -assert(gv_color(x11,lightsalmon2)). -assert(gv_color(x11,lightsalmon3)). -assert(gv_color(x11,lightsalmon4)). -assert(gv_color(x11,lightseagreen)). -assert(gv_color(x11,lightskyblue)). -assert(gv_color(x11,lightskyblue1)). -assert(gv_color(x11,lightskyblue2)). -assert(gv_color(x11,lightskyblue3)). -assert(gv_color(x11,lightskyblue4)). -assert(gv_color(x11,lightslateblue)). -assert(gv_color(x11,lightslategray)). -assert(gv_color(x11,lightslategrey)). -assert(gv_color(x11,lightsteelblue)). -assert(gv_color(x11,lightsteelblue1)). -assert(gv_color(x11,lightsteelblue2)). -assert(gv_color(x11,lightsteelblue3)). -assert(gv_color(x11,lightsteelblue4)). -assert(gv_color(x11,lightyellow)). -assert(gv_color(x11,lightyellow1)). -assert(gv_color(x11,lightyellow2)). -assert(gv_color(x11,lightyellow3)). -assert(gv_color(x11,lightyellow4)). -assert(gv_color(x11,limegreen)). -assert(gv_color(x11,linen)). -assert(gv_color(x11,magenta)). -assert(gv_color(x11,magenta1)). -assert(gv_color(x11,magenta2)). -assert(gv_color(x11,magenta3)). -assert(gv_color(x11,magenta4)). -assert(gv_color(x11,maroon)). -assert(gv_color(x11,maroon1)). -assert(gv_color(x11,maroon2)). -assert(gv_color(x11,maroon3)). -assert(gv_color(x11,maroon4)). -assert(gv_color(x11,mediumaquamarine)). -assert(gv_color(x11,mediumblue)). -assert(gv_color(x11,mediumorchid)). -assert(gv_color(x11,mediumorchid1)). -assert(gv_color(x11,mediumorchid2)). -assert(gv_color(x11,mediumorchid3)). -assert(gv_color(x11,mediumorchid4)). -assert(gv_color(x11,mediumpurple)). -assert(gv_color(x11,mediumpurple1)). -assert(gv_color(x11,mediumpurple2)). -assert(gv_color(x11,mediumpurple3)). -assert(gv_color(x11,mediumpurple4)). -assert(gv_color(x11,mediumseagreen)). -assert(gv_color(x11,mediumslateblue)). -assert(gv_color(x11,mediumspringgreen)). -assert(gv_color(x11,mediumturquoise)). -assert(gv_color(x11,mediumvioletred)). -assert(gv_color(x11,midnightblue)). -assert(gv_color(x11,mintcream)). -assert(gv_color(x11,mistyrose)). -assert(gv_color(x11,mistyrose1)). -assert(gv_color(x11,mistyrose2)). -assert(gv_color(x11,mistyrose3)). -assert(gv_color(x11,mistyrose4)). -assert(gv_color(x11,moccasin)). -assert(gv_color(x11,navajowhite)). -assert(gv_color(x11,navajowhite1)). -assert(gv_color(x11,navajowhite2)). -assert(gv_color(x11,navajowhite3)). -assert(gv_color(x11,navajowhite4)). -assert(gv_color(x11,navy)). -assert(gv_color(x11,navyblue)). -assert(gv_color(x11,none)). -assert(gv_color(x11,oldlace)). -assert(gv_color(x11,olivedrab)). -assert(gv_color(x11,olivedrab1)). -assert(gv_color(x11,olivedrab2)). -assert(gv_color(x11,olivedrab3)). -assert(gv_color(x11,olivedrab4)). -assert(gv_color(x11,orange)). -assert(gv_color(x11,orange1)). -assert(gv_color(x11,orange2)). -assert(gv_color(x11,orange3)). -assert(gv_color(x11,orange4)). -assert(gv_color(x11,orangered)). -assert(gv_color(x11,orangered1)). -assert(gv_color(x11,orangered2)). -assert(gv_color(x11,orangered3)). -assert(gv_color(x11,orangered4)). -assert(gv_color(x11,orchid)). -assert(gv_color(x11,orchid1)). -assert(gv_color(x11,orchid2)). -assert(gv_color(x11,orchid3)). -assert(gv_color(x11,orchid4)). -assert(gv_color(x11,palegoldenrod)). -assert(gv_color(x11,palegreen)). -assert(gv_color(x11,palegreen1)). -assert(gv_color(x11,palegreen2)). -assert(gv_color(x11,palegreen3)). -assert(gv_color(x11,palegreen4)). -assert(gv_color(x11,paleturquoise)). -assert(gv_color(x11,paleturquoise1)). -assert(gv_color(x11,paleturquoise2)). -assert(gv_color(x11,paleturquoise3)). -assert(gv_color(x11,paleturquoise4)). -assert(gv_color(x11,palevioletred)). -assert(gv_color(x11,palevioletred1)). -assert(gv_color(x11,palevioletred2)). -assert(gv_color(x11,palevioletred3)). -assert(gv_color(x11,palevioletred4)). -assert(gv_color(x11,papayawhip)). -assert(gv_color(x11,peachpuff)). -assert(gv_color(x11,peachpuff1)). -assert(gv_color(x11,peachpuff2)). -assert(gv_color(x11,peachpuff3)). -assert(gv_color(x11,peachpuff4)). -assert(gv_color(x11,peru)). -assert(gv_color(x11,pink)). -assert(gv_color(x11,pink1)). -assert(gv_color(x11,pink2)). -assert(gv_color(x11,pink3)). -assert(gv_color(x11,pink4)). -assert(gv_color(x11,plum)). -assert(gv_color(x11,plum1)). -assert(gv_color(x11,plum2)). -assert(gv_color(x11,plum3)). -assert(gv_color(x11,plum4)). -assert(gv_color(x11,powderblue)). -assert(gv_color(x11,purple)). -assert(gv_color(x11,purple1)). -assert(gv_color(x11,purple2)). -assert(gv_color(x11,purple3)). -assert(gv_color(x11,purple4)). -assert(gv_color(x11,red)). -assert(gv_color(x11,red1)). -assert(gv_color(x11,red2)). -assert(gv_color(x11,red3)). -assert(gv_color(x11,red4)). -assert(gv_color(x11,rosybrown)). -assert(gv_color(x11,rosybrown1)). -assert(gv_color(x11,rosybrown2)). -assert(gv_color(x11,rosybrown3)). -assert(gv_color(x11,rosybrown4)). -assert(gv_color(x11,royalblue)). -assert(gv_color(x11,royalblue1)). -assert(gv_color(x11,royalblue2)). -assert(gv_color(x11,royalblue3)). -assert(gv_color(x11,royalblue4)). -assert(gv_color(x11,saddlebrown)). -assert(gv_color(x11,salmon)). -assert(gv_color(x11,salmon1)). -assert(gv_color(x11,salmon2)). -assert(gv_color(x11,salmon3)). -assert(gv_color(x11,salmon4)). -assert(gv_color(x11,sandybrown)). -assert(gv_color(x11,seagreen)). -assert(gv_color(x11,seagreen1)). -assert(gv_color(x11,seagreen2)). -assert(gv_color(x11,seagreen3)). -assert(gv_color(x11,seagreen4)). -assert(gv_color(x11,seashell)). -assert(gv_color(x11,seashell1)). -assert(gv_color(x11,seashell2)). -assert(gv_color(x11,seashell3)). -assert(gv_color(x11,seashell4)). -assert(gv_color(x11,sienna)). -assert(gv_color(x11,sienna1)). -assert(gv_color(x11,sienna2)). -assert(gv_color(x11,sienna3)). -assert(gv_color(x11,sienna4)). -assert(gv_color(x11,skyblue)). -assert(gv_color(x11,skyblue1)). -assert(gv_color(x11,skyblue2)). -assert(gv_color(x11,skyblue3)). -assert(gv_color(x11,skyblue4)). -assert(gv_color(x11,slateblue)). -assert(gv_color(x11,slateblue1)). -assert(gv_color(x11,slateblue2)). -assert(gv_color(x11,slateblue3)). -assert(gv_color(x11,slateblue4)). -assert(gv_color(x11,slategray)). -assert(gv_color(x11,slategray1)). -assert(gv_color(x11,slategray2)). -assert(gv_color(x11,slategray3)). -assert(gv_color(x11,slategray4)). -assert(gv_color(x11,slategrey)). -assert(gv_color(x11,snow)). -assert(gv_color(x11,snow1)). -assert(gv_color(x11,snow2)). -assert(gv_color(x11,snow3)). -assert(gv_color(x11,snow4)). -assert(gv_color(x11,springgreen)). -assert(gv_color(x11,springgreen1)). -assert(gv_color(x11,springgreen2)). -assert(gv_color(x11,springgreen3)). -assert(gv_color(x11,springgreen4)). -assert(gv_color(x11,steelblue)). -assert(gv_color(x11,steelblue1)). -assert(gv_color(x11,steelblue2)). -assert(gv_color(x11,steelblue3)). -assert(gv_color(x11,steelblue4)). -assert(gv_color(x11,tan)). -assert(gv_color(x11,tan1)). -assert(gv_color(x11,tan2)). -assert(gv_color(x11,tan3)). -assert(gv_color(x11,tan4)). -assert(gv_color(x11,thistle)). -assert(gv_color(x11,thistle1)). -assert(gv_color(x11,thistle2)). -assert(gv_color(x11,thistle3)). -assert(gv_color(x11,thistle4)). -assert(gv_color(x11,tomato)). -assert(gv_color(x11,tomato1)). -assert(gv_color(x11,tomato2)). -assert(gv_color(x11,tomato3)). -assert(gv_color(x11,tomato4)). -assert(gv_color(x11,transparent)). -assert(gv_color(x11,turquoise)). -assert(gv_color(x11,turquoise1)). -assert(gv_color(x11,turquoise2)). -assert(gv_color(x11,turquoise3)). -assert(gv_color(x11,turquoise4)). -assert(gv_color(x11,violet)). -assert(gv_color(x11,violetred)). -assert(gv_color(x11,violetred1)). -assert(gv_color(x11,violetred2)). -assert(gv_color(x11,violetred3)). -assert(gv_color(x11,violetred4)). -assert(gv_color(x11,wheat)). -assert(gv_color(x11,wheat1)). -assert(gv_color(x11,wheat2)). -assert(gv_color(x11,wheat3)). -assert(gv_color(x11,wheat4)). -assert(gv_color(x11,white)). -assert(gv_color(x11,whitesmoke)). -assert(gv_color(x11,yellow)). -assert(gv_color(x11,yellow1)). -assert(gv_color(x11,yellow2)). -assert(gv_color(x11,yellow3)). -assert(gv_color(x11,yellow4)). -assert(gv_color(x11,yellowgreen)). -assert(gv_color(svg,aliceblue)). -assert(gv_color(svg,antiquewhite)). -assert(gv_color(svg,aqua)). -assert(gv_color(svg,aquamarine)). -assert(gv_color(svg,azure)). -assert(gv_color(svg,beige)). -assert(gv_color(svg,bisque)). -assert(gv_color(svg,black)). -assert(gv_color(svg,blanchedalmond)). -assert(gv_color(svg,blue)). -assert(gv_color(svg,blueviolet)). -assert(gv_color(svg,brown)). -assert(gv_color(svg,burlywood)). -assert(gv_color(svg,cadetblue)). -assert(gv_color(svg,chartreuse)). -assert(gv_color(svg,chocolate)). -assert(gv_color(svg,coral)). -assert(gv_color(svg,cornflowerblue)). -assert(gv_color(svg,cornsilk)). -assert(gv_color(svg,crimson)). -assert(gv_color(svg,cyan)). -assert(gv_color(svg,darkblue)). -assert(gv_color(svg,darkcyan)). -assert(gv_color(svg,darkgoldenrod)). -assert(gv_color(svg,darkgray)). -assert(gv_color(svg,darkgreen)). -assert(gv_color(svg,darkgrey)). -assert(gv_color(svg,darkkhaki)). -assert(gv_color(svg,darkmagenta)). -assert(gv_color(svg,darkolivegreen)). -assert(gv_color(svg,darkorange)). -assert(gv_color(svg,darkorchid)). -assert(gv_color(svg,darkred)). -assert(gv_color(svg,darksalmon)). -assert(gv_color(svg,darkseagreen)). -assert(gv_color(svg,darkslateblue)). -assert(gv_color(svg,darkslategray)). -assert(gv_color(svg,darkslategrey)). -assert(gv_color(svg,darkturquoise)). -assert(gv_color(svg,darkviolet)). -assert(gv_color(svg,deeppink)). -assert(gv_color(svg,deepskyblue)). -assert(gv_color(svg,dimgray)). -assert(gv_color(svg,dimgrey)). -assert(gv_color(svg,dodgerblue)). -assert(gv_color(svg,firebrick)). -assert(gv_color(svg,floralwhite)). -assert(gv_color(svg,forestgreen)). -assert(gv_color(svg,fuchsia)). -assert(gv_color(svg,gainsboro)). -assert(gv_color(svg,ghostwhite)). -assert(gv_color(svg,gold)). -assert(gv_color(svg,goldenrod)). -assert(gv_color(svg,gray)). -assert(gv_color(svg,grey)). -assert(gv_color(svg,green)). -assert(gv_color(svg,greenyellow)). -assert(gv_color(svg,honeydew)). -assert(gv_color(svg,hotpink)). -assert(gv_color(svg,indianred)). -assert(gv_color(svg,indigo)). -assert(gv_color(svg,ivory)). -assert(gv_color(svg,khaki)). -assert(gv_color(svg,lavender)). -assert(gv_color(svg,lavenderblush)). -assert(gv_color(svg,lawngreen)). -assert(gv_color(svg,lemonchiffon)). -assert(gv_color(svg,lightblue)). -assert(gv_color(svg,lightcoral)). -assert(gv_color(svg,lightcyan)). -assert(gv_color(svg,lightgoldenrodyellow)). -assert(gv_color(svg,lightgray)). -assert(gv_color(svg,lightgreen)). -assert(gv_color(svg,lightgrey)). -assert(gv_color(svg,lightpink)). -assert(gv_color(svg,lightsalmon)). -assert(gv_color(svg,lightseagreen)). -assert(gv_color(svg,lightskyblue)). -assert(gv_color(svg,lightslategray)). -assert(gv_color(svg,lightslategrey)). -assert(gv_color(svg,lightsteelblue)). -assert(gv_color(svg,lightyellow)). -assert(gv_color(svg,lime)). -assert(gv_color(svg,limegreen)). -assert(gv_color(svg,linen)). -assert(gv_color(svg,magenta)). -assert(gv_color(svg,maroon)). -assert(gv_color(svg,mediumaquamarine)). -assert(gv_color(svg,mediumblue)). -assert(gv_color(svg,mediumorchid)). -assert(gv_color(svg,mediumpurple)). -assert(gv_color(svg,mediumseagreen)). -assert(gv_color(svg,mediumslateblue)). -assert(gv_color(svg,mediumspringgreen)). -assert(gv_color(svg,mediumturquoise)). -assert(gv_color(svg,mediumvioletred)). -assert(gv_color(svg,midnightblue)). -assert(gv_color(svg,mintcream)). -assert(gv_color(svg,mistyrose)). -assert(gv_color(svg,moccasin)). -assert(gv_color(svg,navajowhite)). -assert(gv_color(svg,navy)). -assert(gv_color(svg,oldlace)). -assert(gv_color(svg,olive)). -assert(gv_color(svg,olivedrab)). -assert(gv_color(svg,orange)). -assert(gv_color(svg,orangered)). -assert(gv_color(svg,orchid)). -assert(gv_color(svg,palegoldenrod)). -assert(gv_color(svg,palegreen)). -assert(gv_color(svg,paleturquoise)). -assert(gv_color(svg,palevioletred)). -assert(gv_color(svg,papayawhip)). -assert(gv_color(svg,peachpuff)). -assert(gv_color(svg,peru)). -assert(gv_color(svg,pink)). -assert(gv_color(svg,plum)). -assert(gv_color(svg,powderblue)). -assert(gv_color(svg,purple)). -assert(gv_color(svg,red)). -assert(gv_color(svg,rosybrown)). -assert(gv_color(svg,royalblue)). -assert(gv_color(svg,saddlebrown)). -assert(gv_color(svg,salmon)). -assert(gv_color(svg,sandybrown)). -assert(gv_color(svg,seagreen)). -assert(gv_color(svg,seashell)). -assert(gv_color(svg,sienna)). -assert(gv_color(svg,silver)). -assert(gv_color(svg,skyblue)). -assert(gv_color(svg,slateblue)). -assert(gv_color(svg,slategray)). -assert(gv_color(svg,slategrey)). -assert(gv_color(svg,snow)). -assert(gv_color(svg,springgreen)). -assert(gv_color(svg,steelblue)). -assert(gv_color(svg,tan)). -assert(gv_color(svg,teal)). -assert(gv_color(svg,thistle)). -assert(gv_color(svg,tomato)). -assert(gv_color(svg,turquoise)). -assert(gv_color(svg,violet)). -assert(gv_color(svg,wheat)). -assert(gv_color(svg,white)). -assert(gv_color(svg,whitesmoke)). -assert(gv_color(svg,yellow)). -assert(gv_color(svg,yellowgreen)). diff --git a/prolog/gv/gv_attrs.data b/prolog/gv/gv_attrs.data new file mode 100644 index 0000000..95fc680 --- /dev/null +++ b/prolog/gv/gv_attrs.data @@ -0,0 +1,169 @@ +gv_attr('Damping',[graph],[double],'0.99','0.0','neato only'). +gv_attr('K',[cluster,graph],[double],'0.3','0','sfdp, fdp only'). +gv_attr('URL',[cluster,edge,graph,node],[escString],_G59448,'','svg, postscript, map only'). +gv_attr('_background',[graph],[string],_G59644,'',''). +gv_attr(area,[cluster,node],[double],'1.0','>0','patchwork only'). +gv_attr(arrowhead,[edge],[arrowType],normal,'',''). +gv_attr(arrowsize,[edge],[double],'1.0','0.0',''). +gv_attr(arrowtail,[edge],[arrowType],normal,'',''). +gv_attr(bb,[graph],[rect],'','','write only'). +gv_attr(bgcolor,[cluster,graph],[color,colorList],_G60571,'',''). +gv_attr(center,[graph],[bool],false,'',''). +gv_attr(charset,[graph],[string],'"UTF-8"','',''). +gv_attr(clusterrank,[graph],[clusterMode],local,'','dot only'). +gv_attr(color,[cluster,edge,node],[color,colorList],black,'',''). +gv_attr(colorscheme,[cluster,edge,graph,node],[string],'','',''). +gv_attr(comment,[edge,graph,node],[string],'','',''). +gv_attr(compound,[graph],[bool],false,'','dot only'). +gv_attr(concentrate,[graph],[bool],false,'',''). +gv_attr(constraint,[edge],[bool],true,'','dot only'). +gv_attr(decorate,[edge],[bool],false,'',''). +gv_attr(defaultdist,[graph],[double],'1+(avg. len)*sqrt(|V|)',epsilon,'neato only'). +gv_attr(dim,[graph],[int],'2','2','sfdp, fdp, neato only'). +gv_attr(dimen,[graph],[int],'2','2','sfdp, fdp, neato only'). +gv_attr(dir,[edge],[dirType],'forward(directed)none(undirected)','',''). +gv_attr(diredgeconstraints,[graph],[string,bool],false,'','neato only'). +gv_attr(distortion,[node],[double],'0.0','-100.0',''). +gv_attr(dpi,[graph],[double],'96.00.0','','svg, bitmap output only'). +gv_attr(edgeURL,[edge],[escString],'','','svg, map only'). +gv_attr(edgehref,[edge],[escString],'','','svg, map only'). +gv_attr(edgetarget,[edge],[escString],_G63711,'','svg, map only'). +gv_attr(edgetooltip,[edge],[escString],'','','svg, cmap only'). +gv_attr(epsilon,[graph],[double],'.0001 * # nodes(mode == KK).0001(mode == major)','','neato only'). +gv_attr(esep,[graph],[addDouble,addPoint],'+3','','not dot'). +gv_attr(fillcolor,[cluster,edge,node],[color,colorList],'lightgrey(nodes)black(clusters)','',''). +gv_attr(fixedsize,[node],[bool,string],false,'',''). +gv_attr(fontcolor,[cluster,edge,graph,node],[color],black,'',''). +gv_attr(fontname,[cluster,edge,graph,node],[string],'"Times-Roman"','',''). +gv_attr(fontnames,[graph],[string],'','','svg only'). +gv_attr(fontpath,[graph],[string],'system-dependent','',''). +gv_attr(fontsize,[cluster,edge,graph,node],[double],'14.0','1.0',''). +gv_attr(forcelabels,[graph],[bool],true,'',''). +gv_attr(gradientangle,[cluster,graph,node],[int],'','',''). +gv_attr(group,[node],[string],'','','dot only'). +gv_attr(headURL,[edge],[escString],'','','svg, map only'). +gv_attr(head_lp,[edge],[point],'','','write only'). +gv_attr(headclip,[edge],[bool],true,'',''). +gv_attr(headhref,[edge],[escString],'','','svg, map only'). +gv_attr(headlabel,[edge],[lblString],'','',''). +gv_attr(headport,[edge],[portPos],center,'',''). +gv_attr(headtarget,[edge],[escString],_G4892,'','svg, map only'). +gv_attr(headtooltip,[edge],[escString],'','','svg, cmap only'). +gv_attr(height,[node],[double],'0.5','0.02',''). +gv_attr(href,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only'). +gv_attr(id,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only'). +gv_attr(image,[node],[string],'','',''). +gv_attr(imagepath,[graph],[string],'','',''). +gv_attr(imagescale,[node],[bool,string],false,'',''). +gv_attr(inputscale,[graph],[double],_G6250,'','fdp, neato only'). +gv_attr(label,[cluster,edge,graph,node],[lblString],'"\\N" (nodes)"" (otherwise)','',''). +gv_attr(labelURL,[edge],[escString],'','','svg, map only'). +gv_attr(label_scheme,[graph],[int],'0','0','sfdp only'). +gv_attr(labelangle,[edge],[double],'-25.0','-180.0',''). +gv_attr(labeldistance,[edge],[double],'1.0','0.0',''). +gv_attr(labelfloat,[edge],[bool],false,'',''). +gv_attr(labelfontcolor,[edge],[color],black,'',''). +gv_attr(labelfontname,[edge],[string],'"Times-Roman"','',''). +gv_attr(labelfontsize,[edge],[double],'14.0','1.0',''). +gv_attr(labelhref,[edge],[escString],'','','svg, map only'). +gv_attr(labeljust,[cluster,graph],[string],'"c"','',''). +gv_attr(labelloc,[cluster,graph,node],[string],'"t"(clusters)"b"(root graphs)"c"(nodes)','',''). +gv_attr(labeltarget,[edge],[escString],_G8276,'','svg, map only'). +gv_attr(labeltooltip,[edge],[escString],'','','svg, cmap only'). +gv_attr(landscape,[graph],[bool],false,'',''). +gv_attr(layer,[cluster,edge,node],[layerRange],'','',''). +gv_attr(layerlistsep,[graph],[string],'","','',''). +gv_attr(layers,[graph],[layerList],'','',''). +gv_attr(layerselect,[graph],[layerRange],'','',''). +gv_attr(layersep,[graph],[string],'" :\\t"','',''). +gv_attr(layout,[graph],[string],'','',''). +gv_attr(len,[edge],[double],'1.0(neato)0.3(fdp)','','fdp, neato only'). +gv_attr(levels,[graph],[int],'MAXINT','0.0','sfdp only'). +gv_attr(levelsgap,[graph],[double],'0.0','','neato only'). +gv_attr(lhead,[edge],[string],'','','dot only'). +gv_attr(lheight,[cluster,graph],[double],'','','write only'). +gv_attr(lp,[cluster,edge,graph],[point],'','','write only'). +gv_attr(ltail,[edge],[string],'','','dot only'). +gv_attr(lwidth,[cluster,graph],[double],'','','write only'). +gv_attr(margin,[cluster,graph,node],[double,point],'','',''). +gv_attr(maxiter,[graph],[int],'100 * # nodes(mode == KK)200(mode == major)600(fdp)','','fdp, neato only'). +gv_attr(mclimit,[graph],[double],'1.0','','dot only'). +gv_attr(mindist,[graph],[double],'1.0','0.0','circo only'). +gv_attr(minlen,[edge],[int],'1','0','dot only'). +gv_attr(mode,[graph],[string],major,'','neato only'). +gv_attr(model,[graph],[string],shortpath,'','neato only'). +gv_attr(mosek,[graph],[bool],false,'','neato only'). +gv_attr(nodesep,[graph],[double],'0.25','0.02',''). +gv_attr(nojustify,[cluster,edge,graph,node],[bool],false,'',''). +gv_attr(normalize,[graph],[double,bool],false,'','not dot'). +gv_attr(notranslate,[graph],[bool],false,'','neato only'). +gv_attr(nslimitnslimit1,[graph],[double],'','','dot only'). +gv_attr(ordering,[graph,node],[string],'','','dot only'). +gv_attr(orientation,[node],[double],'0.0','360.0',''). +gv_attr(orientation,[graph],[string],'','',''). +gv_attr(outputorder,[graph],[outputMode],breadthfirst,'',''). +gv_attr(overlap,[graph],[string,bool],true,'','not dot'). +gv_attr(overlap_scaling,[graph],[double],'-4','-1.0e10','prism only'). +gv_attr(overlap_shrink,[graph],[bool],true,'','prism only'). +gv_attr(pack,[graph],[bool,int],false,'',''). +gv_attr(packmode,[graph],[packMode],node,'',''). +gv_attr(pad,[graph],[double,point],'0.0555 (4 points)','',''). +gv_attr(page,[graph],[double,point],'','',''). +gv_attr(pagedir,[graph],[pagedir],'BL','',''). +gv_attr(pencolor,[cluster],[color],black,'',''). +gv_attr(penwidth,[cluster,edge,node],[double],'1.0','0.0',''). +gv_attr(peripheries,[cluster,node],[int],'shape default(nodes)1(clusters)','0',''). +gv_attr(pin,[node],[bool],false,'','fdp, neato only'). +gv_attr(pos,[edge,node],[point,splineType],'','',''). +gv_attr(quadtree,[graph],[quadType,bool],normal,'','sfdp only'). +gv_attr(quantum,[graph],[double],'0.0','0.0',''). +gv_attr(rank,[subgraph],[rankType],'','','dot only'). +gv_attr(rankdir,[graph],[rankdir],'TB','','dot only'). +gv_attr(ranksep,[graph],[double,doubleList],'0.5(dot)1.0(twopi)','0.02','twopi, dot only'). +gv_attr(ratio,[graph],[double,string],'','',''). +gv_attr(rects,[node],[rect],'','','write only'). +gv_attr(regular,[node],[bool],false,'',''). +gv_attr(remincross,[graph],[bool],true,'','dot only'). +gv_attr(repulsiveforce,[graph],[double],'1.0','0.0','sfdp only'). +gv_attr(resolution,[graph],[double],'96.00.0','','svg, bitmap output only'). +gv_attr(root,[graph,node],[string,bool],'(graphs)false(nodes)','','circo, twopi only'). +gv_attr(rotate,[graph],[int],'0','',''). +gv_attr(rotation,[graph],[double],'0','','sfdp only'). +gv_attr(samehead,[edge],[string],'','','dot only'). +gv_attr(sametail,[edge],[string],'','','dot only'). +gv_attr(samplepoints,[node],[int],'8(output)20(overlap and image maps)','',''). +gv_attr(scale,[graph],[double,point],'','','not dot'). +gv_attr(searchsize,[graph],[int],'30','','dot only'). +gv_attr(sep,[graph],[addDouble,addPoint],'+4','','not dot'). +gv_attr(shape,[node],[shape],ellipse,'',''). +gv_attr(shapefile,[node],[string],'','',''). +gv_attr(showboxes,[edge,graph,node],[int],'0','0','dot only'). +gv_attr(sides,[node],[int],'4','0',''). +gv_attr(size,[graph],[double,point],'','',''). +gv_attr(skew,[node],[double],'0.0','-100.0',''). +gv_attr(smoothing,[graph],[smoothType],'"none"','','sfdp only'). +gv_attr(sortv,[cluster,graph,node],[int],'0','0',''). +gv_attr(splines,[graph],[bool,string],'','',''). +gv_attr(start,[graph],[startType],'','','fdp, neato only'). +gv_attr(style,[cluster,edge,graph,node],[style],'','',''). +gv_attr(stylesheet,[graph],[string],'','','svg only'). +gv_attr(tailURL,[edge],[escString],'','','svg, map only'). +gv_attr(tail_lp,[edge],[point],'','','write only'). +gv_attr(tailclip,[edge],[bool],true,'',''). +gv_attr(tailhref,[edge],[escString],'','','svg, map only'). +gv_attr(taillabel,[edge],[lblString],'','',''). +gv_attr(tailport,[edge],[portPos],center,'',''). +gv_attr(tailtarget,[edge],[escString],_G21528,'','svg, map only'). +gv_attr(tailtooltip,[edge],[escString],'','','svg, cmap only'). +gv_attr(target,[cluster,edge,graph,node],[escString,string],_G21878,'','svg, map only'). +gv_attr(tooltip,[cluster,edge,node],[escString],'','','svg, cmap only'). +gv_attr(truecolor,[graph],[bool],'','','bitmap output only'). +gv_attr(vertices,[node],[pointList],'','','write only'). +gv_attr(viewport,[graph],[viewPort],'','',''). +gv_attr(voro_margin,[graph],[double],'0.05','0.0','not dot'). +gv_attr(weight,[edge],[int,double],'1','0(dot,twopi)1(neato,fdp)',''). +gv_attr(width,[node],[double],'0.75','0.01',''). +gv_attr(xdotversion,[graph],[string],'','','xdot only'). +gv_attr(xlabel,[edge,node],[lblString],'','',''). +gv_attr(xlp,[edge,node],[point],'','','write only'). +gv_attr(z,[node],[double],'0.0','-MAXFLOAT-1000',''). diff --git a/prolog/gv/gv_attrs.log b/prolog/gv/gv_attrs.log deleted file mode 100644 index a9c6010..0000000 --- a/prolog/gv/gv_attrs.log +++ /dev/null @@ -1,169 +0,0 @@ -assert(gv_attr('Damping',[graph],[double],'0.99','0.0','neato only')). -assert(gv_attr('K',[cluster,graph],[double],'0.3','0','sfdp, fdp only')). -assert(gv_attr('URL',[cluster,edge,graph,node],[escString],_,'','svg, postscript, map only')). -assert(gv_attr('_background',[graph],[string],_,'','')). -assert(gv_attr(area,[cluster,node],[double],'1.0','>0','patchwork only')). -assert(gv_attr(arrowhead,[edge],[arrowType],normal,'','')). -assert(gv_attr(arrowsize,[edge],[double],'1.0','0.0','')). -assert(gv_attr(arrowtail,[edge],[arrowType],normal,'','')). -assert(gv_attr(bb,[graph],[rect],'','','write only')). -assert(gv_attr(bgcolor,[cluster,graph],[color,colorList],_,'','')). -assert(gv_attr(center,[graph],[bool],false,'','')). -assert(gv_attr(charset,[graph],[string],'"UTF-8"','','')). -assert(gv_attr(clusterrank,[graph],[clusterMode],local,'','dot only')). -assert(gv_attr(color,[cluster,edge,node],[color,colorList],black,'','')). -assert(gv_attr(colorscheme,[cluster,edge,graph,node],[string],'','','')). -assert(gv_attr(comment,[edge,graph,node],[string],'','','')). -assert(gv_attr(compound,[graph],[bool],false,'','dot only')). -assert(gv_attr(concentrate,[graph],[bool],false,'','')). -assert(gv_attr(constraint,[edge],[bool],true,'','dot only')). -assert(gv_attr(decorate,[edge],[bool],false,'','')). -assert(gv_attr(defaultdist,[graph],[double],'1+(avg. len)*sqrt(|V|)',epsilon,'neato only')). -assert(gv_attr(dim,[graph],[int],'2','2','sfdp, fdp, neato only')). -assert(gv_attr(dimen,[graph],[int],'2','2','sfdp, fdp, neato only')). -assert(gv_attr(dir,[edge],[dirType],'forward(directed)none(undirected)','','')). -assert(gv_attr(diredgeconstraints,[graph],[string,bool],false,'','neato only')). -assert(gv_attr(distortion,[node],[double],'0.0','-100.0','')). -assert(gv_attr(dpi,[graph],[double],'96.00.0','','svg, bitmap output only')). -assert(gv_attr(edgeURL,[edge],[escString],'','','svg, map only')). -assert(gv_attr(edgehref,[edge],[escString],'','','svg, map only')). -assert(gv_attr(edgetarget,[edge],[escString],_,'','svg, map only')). -assert(gv_attr(edgetooltip,[edge],[escString],'','','svg, cmap only')). -assert(gv_attr(epsilon,[graph],[double],'.0001 * # nodes(mode == KK).0001(mode == major)','','neato only')). -assert(gv_attr(esep,[graph],[addDouble,addPoint],'+3','','not dot')). -assert(gv_attr(fillcolor,[cluster,edge,node],[color,colorList],'lightgrey(nodes)black(clusters)','','')). -assert(gv_attr(fixedsize,[node],[bool,string],false,'','')). -assert(gv_attr(fontcolor,[cluster,edge,graph,node],[color],black,'','')). -assert(gv_attr(fontname,[cluster,edge,graph,node],[string],'"Times-Roman"','','')). -assert(gv_attr(fontnames,[graph],[string],'','','svg only')). -assert(gv_attr(fontpath,[graph],[string],'system-dependent','','')). -assert(gv_attr(fontsize,[cluster,edge,graph,node],[double],'14.0','1.0','')). -assert(gv_attr(forcelabels,[graph],[bool],true,'','')). -assert(gv_attr(gradientangle,[cluster,graph,node],[int],'','','')). -assert(gv_attr(group,[node],[string],'','','dot only')). -assert(gv_attr(headURL,[edge],[escString],'','','svg, map only')). -assert(gv_attr(head_lp,[edge],[point],'','','write only')). -assert(gv_attr(headclip,[edge],[bool],true,'','')). -assert(gv_attr(headhref,[edge],[escString],'','','svg, map only')). -assert(gv_attr(headlabel,[edge],[lblString],'','','')). -assert(gv_attr(headport,[edge],[portPos],center,'','')). -assert(gv_attr(headtarget,[edge],[escString],_,'','svg, map only')). -assert(gv_attr(headtooltip,[edge],[escString],'','','svg, cmap only')). -assert(gv_attr(height,[node],[double],'0.5','0.02','')). -assert(gv_attr(href,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only')). -assert(gv_attr(id,[cluster,edge,graph,node],[escString],'','','svg, postscript, map only')). -assert(gv_attr(image,[node],[string],'','','')). -assert(gv_attr(imagepath,[graph],[string],'','','')). -assert(gv_attr(imagescale,[node],[bool,string],false,'','')). -assert(gv_attr(inputscale,[graph],[double],_,'','fdp, neato only')). -assert(gv_attr(label,[cluster,edge,graph,node],[lblString],'"\\N" (nodes)"" (otherwise)','','')). -assert(gv_attr(labelURL,[edge],[escString],'','','svg, map only')). -assert(gv_attr(label_scheme,[graph],[int],'0','0','sfdp only')). -assert(gv_attr(labelangle,[edge],[double],'-25.0','-180.0','')). -assert(gv_attr(labeldistance,[edge],[double],'1.0','0.0','')). -assert(gv_attr(labelfloat,[edge],[bool],false,'','')). -assert(gv_attr(labelfontcolor,[edge],[color],black,'','')). -assert(gv_attr(labelfontname,[edge],[string],'"Times-Roman"','','')). -assert(gv_attr(labelfontsize,[edge],[double],'14.0','1.0','')). -assert(gv_attr(labelhref,[edge],[escString],'','','svg, map only')). -assert(gv_attr(labeljust,[cluster,graph],[string],'"c"','','')). -assert(gv_attr(labelloc,[cluster,graph,node],[string],'"t"(clusters)"b"(root graphs)"c"(nodes)','','')). -assert(gv_attr(labeltarget,[edge],[escString],_,'','svg, map only')). -assert(gv_attr(labeltooltip,[edge],[escString],'','','svg, cmap only')). -assert(gv_attr(landscape,[graph],[bool],false,'','')). -assert(gv_attr(layer,[cluster,edge,node],[layerRange],'','','')). -assert(gv_attr(layerlistsep,[graph],[string],'","','','')). -assert(gv_attr(layers,[graph],[layerList],'','','')). -assert(gv_attr(layerselect,[graph],[layerRange],'','','')). -assert(gv_attr(layersep,[graph],[string],'" :\\t"','','')). -assert(gv_attr(layout,[graph],[string],'','','')). -assert(gv_attr(len,[edge],[double],'1.0(neato)0.3(fdp)','','fdp, neato only')). -assert(gv_attr(levels,[graph],[int],'MAXINT','0.0','sfdp only')). -assert(gv_attr(levelsgap,[graph],[double],'0.0','','neato only')). -assert(gv_attr(lhead,[edge],[string],'','','dot only')). -assert(gv_attr(lheight,[cluster,graph],[double],'','','write only')). -assert(gv_attr(lp,[cluster,edge,graph],[point],'','','write only')). -assert(gv_attr(ltail,[edge],[string],'','','dot only')). -assert(gv_attr(lwidth,[cluster,graph],[double],'','','write only')). -assert(gv_attr(margin,[cluster,graph,node],[double,point],'','','')). -assert(gv_attr(maxiter,[graph],[int],'100 * # nodes(mode == KK)200(mode == major)600(fdp)','','fdp, neato only')). -assert(gv_attr(mclimit,[graph],[double],'1.0','','dot only')). -assert(gv_attr(mindist,[graph],[double],'1.0','0.0','circo only')). -assert(gv_attr(minlen,[edge],[int],'1','0','dot only')). -assert(gv_attr(mode,[graph],[string],major,'','neato only')). -assert(gv_attr(model,[graph],[string],shortpath,'','neato only')). -assert(gv_attr(mosek,[graph],[bool],false,'','neato only')). -assert(gv_attr(nodesep,[graph],[double],'0.25','0.02','')). -assert(gv_attr(nojustify,[cluster,edge,graph,node],[bool],false,'','')). -assert(gv_attr(normalize,[graph],[double,bool],false,'','not dot')). -assert(gv_attr(notranslate,[graph],[bool],false,'','neato only')). -assert(gv_attr('nslimit nslimit1',[graph],[double],'','','dot only')). -assert(gv_attr(ordering,[graph,node],[string],'','','dot only')). -assert(gv_attr(orientation,[node],[double],'0.0','360.0','')). -assert(gv_attr(orientation,[graph],[string],'','','')). -assert(gv_attr(outputorder,[graph],[outputMode],breadthfirst,'','')). -assert(gv_attr(overlap,[graph],[string,bool],true,'','not dot')). -assert(gv_attr(overlap_scaling,[graph],[double],'-4','-1.0e10','prism only')). -assert(gv_attr(overlap_shrink,[graph],[bool],true,'','prism only')). -assert(gv_attr(pack,[graph],[bool,int],false,'','')). -assert(gv_attr(packmode,[graph],[packMode],node,'','')). -assert(gv_attr(pad,[graph],[double,point],'0.0555 (4 points)','','')). -assert(gv_attr(page,[graph],[double,point],'','','')). -assert(gv_attr(pagedir,[graph],[pagedir],'BL','','')). -assert(gv_attr(pencolor,[cluster],[color],black,'','')). -assert(gv_attr(penwidth,[cluster,edge,node],[double],'1.0','0.0','')). -assert(gv_attr(peripheries,[cluster,node],[int],'shape default(nodes)1(clusters)','0','')). -assert(gv_attr(pin,[node],[bool],false,'','fdp, neato only')). -assert(gv_attr(pos,[edge,node],[point,splineType],'','','')). -assert(gv_attr(quadtree,[graph],[quadType,bool],normal,'','sfdp only')). -assert(gv_attr(quantum,[graph],[double],'0.0','0.0','')). -assert(gv_attr(rank,[subgraph],[rankType],'','