From 027cf79fbe651af6d5fe9a71db6234cda1fd547d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 10 Feb 2019 18:19:12 +0100 Subject: Move trie->dot from trie to graphs. Add value printing. --- trie.inc.h | 49 +------------------------------------------------ 1 file changed, 1 insertion(+), 48 deletions(-) (limited to 'trie.inc.h') 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 #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; -- cgit v1.2.3