|
20 | 20 | dot_graph/2, % +Out, :Goal_1 |
21 | 21 | dot_graph/3, % +Out, :Goal_1, +Options |
22 | 22 | dot_html_replace/2, % +Unescaped, -Escaped |
23 | | - dot_id/1, % -Id |
24 | | - dot_id/2, % +Term, -Id |
25 | 23 | dot_node/2, % +Out, +Term |
26 | 24 | dot_node/3, % +Out, +Term, +Options |
27 | 25 | dot_node_id/2, % +Out, +Id |
|
37 | 35 |
|
38 | 36 | :- use_module(library(apply)). |
39 | 37 | :- use_module(library(error)). |
40 | | -:- use_module(library(uuid)). |
41 | 38 | :- use_module(library(yall)). |
42 | 39 |
|
43 | 40 | :- use_module(library(dcg)). |
44 | 41 | :- use_module(library(dict)). |
45 | 42 | :- use_module(library(debug_ext)). |
46 | 43 | :- use_module(library(file_ext)). |
47 | | -:- use_module(library(hash_ext)). |
| 44 | +:- use_module(library(term_ext)). |
48 | 45 |
|
49 | 46 | :- use_module(dot_html). |
50 | 47 |
|
|
74 | 71 | % preferable. However, there are legitimate use cases where the |
75 | 72 | % programmer would like to generate and use the DOT IDs herself. |
76 | 73 | % For these purposes, dot_arc_id/[3,4] can be used -- in |
77 | | -% combination with dot_id/2 -- instead. |
| 74 | +% combination with ascii_id/2 -- instead. |
78 | 75 |
|
79 | 76 | dot_arc(Out, FromTerm, ToTerm) :- |
80 | 77 | dot_arc(Out, FromTerm, ToTerm, options{}). |
81 | 78 |
|
82 | 79 |
|
83 | 80 | dot_arc(Out, FromTerm, ToTerm, Options) :- |
84 | | - maplist(dot_id, [FromTerm,ToTerm], [FromId,ToId]), |
| 81 | + maplist(ascii_id, [FromTerm,ToTerm], [FromId,ToId]), |
85 | 82 | dot_arc_id(Out, FromId, ToId, Options). |
86 | 83 |
|
87 | 84 |
|
|
163 | 160 |
|
164 | 161 |
|
165 | 162 | dot_cluster(Out, Term, Goal_1, Options) :- |
166 | | - dot_id(Term, Id), |
| 163 | + ascii_id(Term, Id), |
167 | 164 | dot_cluster_id(Out, Id, Goal_1, Options). |
168 | 165 |
|
169 | 166 |
|
|
176 | 173 |
|
177 | 174 |
|
178 | 175 | dot_cluster_arc(Out, FromTerm, ToTerm, Options) :- |
179 | | - maplist(dot_id, [FromTerm,ToTerm], [FromId,ToId]), |
| 176 | + maplist(ascii_id, [FromTerm,ToTerm], [FromId,ToId]), |
180 | 177 | dot_cluster_arc_id(Out, FromId, ToId, Options). |
181 | 178 |
|
182 | 179 |
|
|
227 | 224 | % preferable. However, there are legitimate use cases where the |
228 | 225 | % programmer would like to generate and use the DOT IDs |
229 | 226 | % themselves. For these purposes, dot_edge_id/[3,4] can be used |
230 | | -% -- in combination with dot_id/2 -- instead. |
| 227 | +% -- in combination with ascii_id/2 -- instead. |
231 | 228 |
|
232 | 229 | dot_edge(Out, FromTerm, ToTerm) :- |
233 | 230 | dot_edge(Out, FromTerm, ToTerm, options{}). |
234 | 231 |
|
235 | 232 |
|
236 | 233 | dot_edge(Out, FromTerm, ToTerm, Options) :- |
237 | | - maplist(dot_id, [FromTerm,ToTerm], [FromId,ToId]), |
| 234 | + maplist(ascii_id, [FromTerm,ToTerm], [FromId,ToId]), |
238 | 235 | dot_edge_id(Out, FromId, ToId, Options). |
239 | 236 |
|
240 | 237 |
|
|
348 | 345 |
|
349 | 346 |
|
350 | 347 |
|
351 | | -%! dot_id(-Id:atom) is det. |
352 | | - |
353 | | -dot_id(Id) :- |
354 | | - uuid(Id0, [format(integer)]), |
355 | | - atom_concat(n, Id0, Id). |
356 | | - |
357 | | - |
358 | | - |
359 | | -%! dot_id(+Term:term, -Id:atom) is det. |
360 | | -% |
361 | | -% Create a DOT ID that can be used to represent a Prolog term in the |
362 | | -% DOT language. When the same Prolog term is supplied, the DOT ID is |
363 | | -% also the same. |
364 | | - |
365 | | -dot_id(Term, Id) :- |
366 | | - % DOT IDs cannot contain all characters allowed in Prolog terms. |
367 | | - % Also, Prolog terms can have arbitrary length. For these reasons, |
368 | | - % we calculate the MD5 hash of a serialization of the Prolog term. |
369 | | - md5(Term, Hash), |
370 | | - % DOT IDs must start with an ASCII letter. Since an MD5 hash may |
371 | | - % start with a decimal digit, an specific ASCII letter is prefixed. |
372 | | - atomic_concat(n, Hash, Id). |
373 | | - |
374 | | - |
375 | | - |
376 | 348 | %! dot_node(+Out:stream, +Term:term) is det. |
377 | 349 | %! dot_node(+Out:stream, +Term:term, +Options:options) is det. |
378 | 350 | % |
|
400 | 372 | % preferable. However, there are legitimate use cases where the |
401 | 373 | % programmer would like to generate and use the DOT IDs |
402 | 374 | % themselves. For these purposes, dot_node_id/[2,3] can be used -- |
403 | | -% in combination with dot_id/2 -- instead. |
| 375 | +% in combination with ascii_id/2 -- instead. |
404 | 376 |
|
405 | 377 | dot_node(Out, Term) :- |
406 | 378 | dot_node(Out, Term, options{label: Term}). |
407 | 379 |
|
408 | 380 |
|
409 | 381 | dot_node(Out, Term, Options) :- |
410 | | - dot_id(Term, Id), |
| 382 | + ascii_id(Term, Id), |
411 | 383 | dot_node_id(Out, Id, Options). |
412 | 384 |
|
413 | 385 |
|
|
0 commit comments