17 #ifndef AWALI_ALGOS_TIKZ_HH
18 # define AWALI_ALGOS_TIKZ_HH
22 # include <unordered_map>
23 # include <unordered_set>
30 namespace awali {
namespace sttc {
41 template <
typename Aut>
56 using super_type::super_type;
66 if (
ws_.show_one() || !
ws_.is_one(w))
68 os_ <<
',' << kind <<
" text=$\\langle ";
69 ws_.print(w,
os_,
"latex") <<
"\\rangle$";
77 "\\documentclass{standalone}\n"
78 " \\usepackage{tikz}\n"
79 " \\usetikzlibrary{arrows, automata, positioning}\n"
80 " \\tikzstyle{automaton}=[shorten >=1pt, pos=.4,\n"
81 " >=stealth', initial text=]\n"
82 " \\tikzstyle{accepting}=[accepting by arrow]\n"
85 "\\begin{tikzpicture}[automaton]\n"
88 for (
auto s :
aut_->states())
90 os_ <<
" \\node[state";
91 format(
"initial",
aut_->get_initial_weight(s));
92 format(
"accepting",
aut_->get_final_weight(s));
107 for (
auto src :
aut_->states())
109 std::set<state_t> ds;
110 for (
auto t:
aut_->out(src))
111 ds.insert(
aut_->dst_of(t));
114 os_ <<
" \\path[->] (";
118 << (src == dst ?
"[loop above]" :
"")
127 "\\end{tikzpicture}\n"
136 template <
typename AutPtr>
138 tikz(
const AutPtr& aut, std::ostream& out)
Factor common bits in automaton formatting.
Definition: grail.hh:43
std::string format_entry_(state_t src, state_t dst, const std::string &fmt="text")
The labels and weights of transitions from src to dst.
Definition: grail.hh:88
const automaton_t & aut_
The automaton we have to output.
Definition: grail.hh:154
weight_t_of< automaton_t > weight_t
Definition: grail.hh:62
Aut automaton_t
Definition: grail.hh:45
const weightset_t & ws_
Short-hand to the weightset.
Definition: grail.hh:160
std::ostream & os_
Output stream.
Definition: grail.hh:156
Format automaton to TikZ format.
Definition: tikz.hh:43
std::string format_entry_(state_t src, state_t dst, const std::string &fmt="text")
The labels and weights of transitions from src to dst.
Definition: grail.hh:88
const automaton_t & aut_
The automaton we have to output.
Definition: grail.hh:154
const weightset_t & ws_
Short-hand to the weightset.
Definition: grail.hh:160
void operator()()
Definition: tikz.hh:74
std::ostream & os_
Output stream.
Definition: grail.hh:156
void format(const std::string &kind, const weight_t &w)
Format a TikZ attribute.
Definition: tikz.hh:61
std::ostream & tikz(const AutPtr &aut, std::ostream &out)
Format automaton to TikZ format.
Definition: tikz.hh:138
Main namespace of Awali.
Definition: ato.hh:22
unsigned state_t
Definition: types.hh:21
unsigned transition_t
Definition: types.hh:22