6 #ifndef TURI_DOT_GRAPH_HPP 7 #define TURI_DOT_GRAPH_HPP 22 inline bool add_vertex(
const std::string& vid,
const std::string& vlabel=
"") {
23 if (m_vertices.count(vid))
return false;
24 m_vertices.insert(vid);
25 m_vertex_label[vid] = vlabel;
29 inline void add_edge(
const std::string& src,
const std::string& dest) {
30 m_edges.push_back({src, dest});
33 inline void print(std::ostream& out) {
34 out <<
"digraph G {\n";
35 for(
auto vertex: m_vertices) {
36 out <<
"\t\"" << vertex <<
"\" ";
38 out <<
"[label=\"" << m_vertex_label[vertex] <<
"\"]\n";
40 for(
auto edge: m_edges) {
41 out <<
"\t\"" << edge.first <<
"\" -> \"" << edge.second <<
"\"\n";
48 std::set<std::string> m_vertices;
49 std::vector<std::pair<std::string, std::string>> m_edges;
50 std::map<std::string, std::string> m_vertex_label;