Created
May 16, 2014 02:41
-
-
Save soap-DEIM/cad92a653ba113777809 to your computer and use it in GitHub Desktop.
graphicviz-dot example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <fstream> | |
#define VISUAL(caller, callee, ofs) \ | |
ofs << caller << "->"; \ | |
callee(ofs); \ | |
ofs << ';' << '\n' | |
void foo(std::ofstream &ofs) | |
{ | |
printf("%s\n", __func__); | |
ofs << __func__; | |
} | |
void bar(std::ofstream &ofs) | |
{ | |
printf("%s\n", __func__); | |
ofs << __func__; | |
} | |
int main() | |
{ | |
std::ofstream ofs("viz.dot"); | |
printf("%s\n", __func__); | |
ofs << "digraph" << '{' << '\n'; | |
VISUAL(__func__, foo, ofs); | |
VISUAL(__func__, bar, ofs); | |
ofs << '}' << '\n'; | |
ofs.close(); | |
return 0; | |
} | |
/* to generate png, execute: */ | |
/* dot -Tpng viz.dot -o viz.png */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment