Well, today I want to talk about two utilities that have helped me a lot, one of them is graphviz.org. Graphviz, which has versions for Windows, Mac or Linux (in my case I have tried in Linux and Mac OS), is a powerful Open Source tool that allows to easily generate almost any graphic, cool stuff like this:
Or simpler things than recreating a binary tree that I explained in the previous section, https://www.larebelion.com/2020/04/arboles-binarios.html.
Imagine that in code C, you want to represent the resulting binary tree, with few lines of code you could get something like this:
Let me a simple C function to add to the previous tree and generate this:
static void _generating_graphviz_details(const tree_t node, const void *extra) { FILE *f = (FILE *) extra; fprintf(f, " node_%p [label=\"{%p | content: %d | { <izqda> %p | <dcha> %p}\"];\n", node, node, node->content, node->left, node->right ); if (node->left != NULL) { fprintf(f, " node_%p:left -> node_%p;\n", node, node->left); } if (node->right != NULL) { fprintf(f, " node_%p:dcha -> node_%p;\n", node, node->dcha); } fprintf(f, "f"); }
Okay, hopefully this tiny contribution will help you in the dynamic generation of your graphics.