11#include "mcrl2/lts/lts_io.h"
12#include "mcrl2/lts/parse.h"
13#include "mcrl2/lts/detail/liblts_swap_to_from_probabilistic_lts.h"
15using namespace mcrl2::
core;
24 os <<
"digraph G {" << std::endl;
25 os <<
"center = TRUE;" << std::endl;
26 os <<
"mclimit = 10.0;" << std::endl;
27 os <<
"nodesep = 0.05;" << std::endl;
28 os <<
"node [ width=0.25, height=0.25, label=\"\" ];" << std::endl;
31 if (initial_probabilistic_state().size()<=1)
33 const std::size_t initial_state=initial_probabilistic_state().get();
36 os << state_label(initial_state).name();
40 os <<
"S" << initial_state;
45 throw mcrl2::runtime_error(
"Cannnot save a probabilistic transition system in .dot format.");
48 os <<
" [ peripheries=2 ];" << std::endl;
49 for (std::size_t i=0; i<num_states(); i++)
53 const std::string& label = state_label(i).label();
56 os << state_label(i).name() <<
" [label=\"" << label <<
"\"];" << std::endl;
61 os <<
"S" << i << std::endl;
66 for (
const transition& t: get_transitions())
70 if (probabilistic_state(t.to()).size()>1)
72 throw mcrl2::runtime_error(
"Cannot save probabilistic states in .dot format.");
74 os << state_label(t.from()).name() <<
"->" << state_label(probabilistic_state(t.to()).get()).name() <<
"[label=\"" <<
75 mcrl2::lts::pp(action_label(t.label())) <<
"\"];" << std::endl;
79 os <<
"S" << t.from() <<
" -> " <<
"S" << t.to() <<
"[label=\"" <<
80 mcrl2::lts::pp(action_label(apply_hidden_label_map(t.label()))) <<
"\"];" << std::endl;
84 os <<
"}" << std::endl;
89 std::ofstream os(filename.c_str());
92 throw mcrl2::runtime_error(
"cannot open DOT file '" + filename +
"' for writing.");
101 detail::translate_to_probabilistic_lts
104 probabilistic_state<std::size_t, mcrl2::utilities::probabilistic_arbitrary_precision_fraction>,
105 detail::lts_dot_base>(*
this,l);
111 if (filename.empty() || filename==
"-")
117 std::ofstream os(filename.c_str());
120 throw mcrl2::runtime_error(
"cannot open DOT file '" + filename +
"' for writing.");
A class to contain labelled transition systems in graphviz format.
void save(const std::string &filename) const
Save the labelled transition system to a file.
void save(std::ostream &os) const
Save the labelled transition system to a stream.
A class to contain labelled transition systems in graphviz format.
void save(std::ostream &os) const
Save the labelled transition system to a stream.
void save(const std::string &filename) const
Save the labelled transition system to a file.