Created
May 21, 2014 00:11
-
-
Save jroesch/7cf909255b8f1a6de3ad to your computer and use it in GitHub Desktop.
Dot Printer
This file contains hidden or 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 <fstream> | |
| using namespace std; | |
| void print2Dot(elem *elm) { | |
| std::fstream fs; | |
| int count = 0; | |
| fs << "diagraph G {" << endl | |
| fs.open("output.dot", std::fstream::out) | |
| recursePrint2Dot(0, fs, elm); | |
| fs << "}" << endl; | |
| fs.close(); | |
| } | |
| int recursePrint2Dot(int count, fstream file, elem *elm) { | |
| auto right = recursePrint2Dot(count + 1, file, elm->smallChild), | |
| left = recrusePrint2Dot(right, file, elm->bigChild); | |
| file << "\t" << "node" << count << " -> " << "node" << right << endl; | |
| file << "\t" << "node" << count << " -> " << "node" << left << endl; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment