dotty.cc 1.22 KB
Newer Older
1
#include "tgba/tgba.hh"
2
3
#include "dotty.hh"
#include "tgba/bddprint.hh"
4
#include "reachiter.hh"
5
6
7

namespace spot
{
8

9
  class dotty_bfs : public tgba_reachable_iterator_breadth_first
10
  {
11
12
13
14
15
16
17
18
19
20
  public:
    dotty_bfs(const tgba* a, std::ostream& os)
      : tgba_reachable_iterator_breadth_first(a), os_(os)
    {
    }

    void
    start()
    {
      os_ << "digraph G {" << std::endl;
21
      os_ << "  0 [label=\"\", style=invis, height=0]" << std::endl;
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
      os_ << "  0 -> 1" << std::endl;
    }

    void
    end()
    {
      os_ << "}" << std::endl;
    }

    void
    process_state(const state* s, int n, tgba_succ_iterator*)
    {
      os_ << "  " << n << " [label=\""
	  << automata_->format_state(s) << "\"]" << std::endl;
    }

    void
    process_link(int in, int out, const tgba_succ_iterator* si)
    {
      os_ << "  " << in << " -> " << out << " [label=\"";
      bdd_print_set(os_, automata_->get_dict(),
		    si->current_condition()) << "\\n";
      bdd_print_set(os_, automata_->get_dict(),
		    si->current_accepting_conditions()) << "\"]" << std::endl;
    }

  private:
    std::ostream& os_;
  };
51
52

  std::ostream&
53
  dotty_reachable(std::ostream& os, const tgba* g)
54
  {
55
56
    dotty_bfs d(g, os);
    d.run();
57
58
59
60
61
    return os;
  }


}