Skip to content
Snippets Groups Projects
Commit 94c775a5 authored by Jaime Arias's avatar Jaime Arias
Browse files

fix: save to graphviz

parent ad1bb43c
No related branches found
No related tags found
No related merge requests found
Pipeline #9292 passed with stages
in 10 minutes and 43 seconds
......@@ -259,17 +259,21 @@ Graph *Graph::GenerateRandomGraph(const int n_states, const int n_transitions,
std::string Graph::ToString() {
std::stringstream ss;
ss << "digraph g {";
ss << "digraph g {\n";
ss << " start [shape=point, width=0];\n\n";
ss << " start -> " << this->initial_node()->name() << ";";
for (Node *n : this->states()) {
for (const auto &v : n->successors()) {
// remove the trailing _ from labels
string label = v.first;
label.pop_back();
ss << "\n " << n->name() << " -> " << v.second->name() << " [label=\""
<< label << "\"]";
ss << "\n " << n->name() << " -> " << v.second->name() << " [label = \""
<< label << "\"];";
}
}
ss << "\n " << this->initial_node()->name() << "[initialstate]\n}";
ss << "\n}";
return ss.str();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment