aboutsummaryrefslogtreecommitdiff
path: root/trie.inc.h
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-02-10 18:19:12 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-02-10 18:19:12 +0100
commit027cf79fbe651af6d5fe9a71db6234cda1fd547d (patch)
tree61cc8bdd2d361b17e1c9f46329e74749800ef195 /trie.inc.h
parentAdd space to FMT(LLIST(T)). (diff)
downloadcalp-027cf79fbe651af6d5fe9a71db6234cda1fd547d.tar.gz
calp-027cf79fbe651af6d5fe9a71db6234cda1fd547d.tar.xz
Move trie->dot from trie to graphs. Add value printing.
Diffstat (limited to 'trie.inc.h')
-rw-r--r--trie.inc.h49
1 files changed, 1 insertions, 48 deletions
diff --git a/trie.inc.h b/trie.inc.h
index c6f3a0e8..c03cee22 100644
--- a/trie.inc.h
+++ b/trie.inc.h
@@ -5,6 +5,7 @@
#include <stdarg.h>
#include "err.h"
+#include "macro.h"
INIT_F ( TRIE(TYPE) ) {
NEW(TRIE_NODE(TYPE), t, '\0');
@@ -119,54 +120,6 @@ int EMPTY(TRIE(TYPE))(TRIE(TYPE)* this) {
return this->root->child == NULL;
}
-int TRIE_DOT(TYPE) ( TRIE(TYPE)* trie, FILE* f ) {
- TRIE_NODE(TYPE)* n = trie->root->child;
- fprintf(f, "\"%p\" [label=root fontcolor=gray, color=gray];", trie);
- while (n != NULL) {
- fprintf(f, "\"%p\" -> \"%p\" [color=gray]\n",
- (void*) trie,
- (void*) n);
- fprintf(f, "subgraph \"cluster_%c\" {\n",
- n->c);
- TRIE_DOT_HELP(TYPE) ( n, f );
- fputs("}", f);
- n = n->next;
- }
- return 0;
-}
-
-int TRIE_DOT_HELP(TYPE) ( TRIE_NODE(TYPE)* root, FILE* f ) {
- fprintf(f, "\"%p\"[label = \"%c\" style=filled fillcolor=\"%s\"];\n",
- (void*) root, root->c,
- root->value == NULL ? "white" : "green");
- TRIE_NODE(TYPE)* child = root->child;
-
- // ----------------------------------------
- if (root->value != NULL) {
- if (! EMPTY(LLIST(key_val))(&root->value->params)) {
- fprintf(f, "subgraph \"cluster_param_%p\"{\n color=blue;\n", root);
- FOR(LLIST(key_val), link, &root->value->params) {
- fprintf(f, "\"%p\" [shape=rectangle, label=\"%s := %s\"];", link,
- link->value->key.mem,
- link->value->val.mem);
- }
- fputs("}", f);
- FOR(LLIST(key_val), link, &root->value->params) {
- fprintf(f, "\"%p\" -> \"%p\";\n", root, link);
- }
- }
- }
- // ----------------------------------------
-
- while (child != NULL) {
- fprintf(f, "\"%p\" -> \"%p\";\n",
- (void*) root, (void*) child);
- TRIE_DOT_HELP(TYPE)(child, f);
- child = child->next;
- }
- return 0;
-}
-
FMT_F(TRIE_NODE(TYPE)) {
va_list ap;