Skip to content

Instantly share code, notes, and snippets.

@Green-Sky
Last active November 12, 2020 01:01
Show Gist options
  • Save Green-Sky/d41f7ff7f03e2adf2d0775d8d05faaa0 to your computer and use it in GitHub Desktop.
Save Green-Sky/d41f7ff7f03e2adf2d0775d8d05faaa0 to your computer and use it in GitHub Desktop.
Generates a .dot GraphViz
// Generates a .dot GraphViz
// license is CC0 (this means public domain in most countries)
std::ostream& operator<<(std::ostream& out, const std::vector<entt::organizer::vertex>& nodes) {
out << "digraph EnTT_organizer {\n";
for (size_t i = 0; i < nodes.size(); i++) {
out << "n" << i << "[label=\"" << (nodes[i].name() == nullptr ? "NoName" : nodes[i].name()) << "\"];\n";
}
for (size_t i = 0; i < nodes.size(); i++) {
for (const size_t child : nodes[i].children()) {
out << "n" << child << " -> " << "n" << i << ";\n";
}
}
out << "}";
return out;
}
std::ostream& operator<<(std::ostream& out, /*const*/ entt::organizer& org) {
const auto nodes = org.graph();
out << nodes;
return out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment