27 template <
typename Aut>
46 using super_t::super_t;
50 const char*
gray =
"color = DimGray";
58 #if defined __GNUC__ && ! defined __clang__
61 # pragma GCC diagnostic push
62 # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
65 #if defined __GNUC__ && ! defined __clang__
66 # pragma GCC diagnostic pop
94 ?
"texmode = math, lblstyle = auto"
95 :
"arrowhead = vee, arrowsize = .6")
100 " d2toptions = \"--format tikz --tikzedgelabels"
101 " --graphstyle=automaton --crop --nominsize --autosize\"\n"
102 " d2tdocpreamble = \""
103 " \\usepackage{amssymb}"
104 " \\usetikzlibrary{arrows.meta, automata, bending}"
105 " \\tikzstyle{automaton}=[shorten >=1pt, pos=.4,"
106 " >={Stealth[bend,round]}, initial text=]"
107 " \\tikzstyle{named}=[rectangle, rounded corners]"
108 " \\tikzstyle{initial}=[initial by arrow]"
109 " \\tikzstyle{accepting}=[accepting by arrow]"
124 const std::string& kind,
const weight_t& w)
131 if (
ws_.show_one() || !
ws_.is_one(w))
133 bos_ <<
", " << kind <<
" text={";
145 bool has_attributes =
false;
148 has_attributes =
true;
155 if (
aut_->state_has_name(s))
157 bos_ <<
"label = \"";
161 static bool debug = getenv(
"VCSN_DEBUG");
163 bos_ <<
" (" << s <<
')';
164 bos_ <<
"\", style = \"named";
169 sep =
"style = \"state, ";
170 if (
format_(sep,
"initial",
aut_->get_initial_weight(s)))
175 if (
format_(sep,
"accepting",
aut_->get_final_weight(s)))
182 if (
aut_->state_has_name(s))
184 has_attributes =
true;
185 bos_ <<
" [label = \"";
189 static bool debug = getenv(
"VCSN_DEBUG");
191 bos_ <<
" (" << s <<
')';
192 bos_ <<
"\", shape = box";
194 if (!
aut_->state_is_strict(s))
201 has_attributes =
true;
203 bos_ <<
"style = dashed";
213 has_attributes =
true;
227 if (!
aut_->initial_transitions().empty()
228 || !
aut_->final_transitions().empty())
232 " node [shape = point, width = 0]\n";
262 if (!
aut_->states().empty())
267 ?
"texmode = math, style = state"
268 :
"shape = circle, style = rounded, width = 0.5")
270 for (
auto s :
aut_->states())
285 if (src ==
aut_->pre())
293 if (dst ==
aut_->post())
305 if (!e.empty() || useless)
308 const char* sep =
"";
311 bos_ <<
"label = \"";
329 std::map<state_t, polynomial_t> dsts;
330 for (
auto src :
aut_->all_states())
331 if (
aut_->state_is_strict(src)
335 for (
auto t:
aut_->all_out(src))
339 ps_.new_weight(dsts[
aut_->dst_of(t)],
340 aut_->label_of(t),
aut_->weight_of(t));
341 for (
const auto& p: dsts)
349 boost::iostreams::flush(
bos_);
356 boost::iostreams::flush(
bos_);
361 detail::io::filtering_ostream
bos_;
369 template <
typename Aut>
371 dot(
const Aut& aut, std::ostream& out,
bool dot2tex =
false)
automaton_t aut_
The automaton we have to output.
void print_epilogue_()
Finish the dot graph.
weightset_t_of< automaton_t > weightset_t
bool format_(const std::string &sep, const std::string &kind, const weight_t &w)
Format a TikZ attribute.
bool dot2tex_
Whether to format for dot2tex.
detail::io::filtering_ostream bos_
The output stream, with a backslashify filter.
void print_prologue_()
Start the dot graph.
states_t finals_()
The list of final states, sorted.
void print_transitions_(const state_t src, const state_t dst, const polynomial_t &entry)
Print the transitions between state src and state dst.
state_t_of< automaton_t > state_t
void disable_()
Disable the escaping of backslashes.
states_t initials_()
The list of initial states, sorted.
void print_transitions_()
Print all the transitions, sorted by src state, then dst state.
std::string to_string(direction d)
Conversion to string.
const polynomialset_t ps_
Short-hand to the polynomialset used to print the entries.
const weightset_t & ws_
Short-hand to the weightset.
dotter(const automaton_t &aut, std::ostream &out, bool dot2tex=false)
Format an automaton into Dot.
std::ostream & os_
Output stream.
std::ostream & operator()()
Print the automaton on the stream.
std::ostream & dot(const Aut &aut, std::ostream &out, bool dot2tex=false)
ATTRIBUTE_PURE bool has(const std::deque< T, Allocator > &s, const T &e)
Whether e is member of s.
transition_t_of< automaton_t > transition_t
states_t< Aut > useful_states(const Aut &a, bool strict=true)
The set of useful states, including possibly pre() and post().
void enable_()
Enable the escaping of backslashes.
void print_state_(state_t s)
Pretty-print state s for both dot and dot2tex.
typename polynomialset_t::value_t polynomial_t
weight_t_of< automaton_t > weight_t
Factor common bits in automaton formatting.
std::unordered_set< state_t_of< Aut > > useful_
Useful states, without evaluating the lazy states.
void print_states_()
Print the states.