diff options
Diffstat (limited to 'trie.inc.h')
-rw-r--r-- | trie.inc.h | 49 |
1 files changed, 1 insertions, 48 deletions
@@ -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; |