mCRL2
Loading...
Searching...
No Matches
bdd2dot.h
Go to the documentation of this file.
1// Author(s): Luc Engelen
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
11
12#ifndef MCRL2_DATA_DETAIL_PROVER_BDD2DOT_H
13#define MCRL2_DATA_DETAIL_PROVER_BDD2DOT_H
14
16#include <fstream>
17
18namespace mcrl2
19{
20namespace data
21{
22namespace detail
23{
24
28
30{
31 private:
34
36 std::ofstream f_dot_file;
37
39 std::map < atermpp::aterm, atermpp::aterm_int> f_visited;
40
43
51 {
52 if (f_visited.count(a_bdd)>0) // a_bdd has already been visited.
53 {
54 return;
55 }
56
57 if (f_bdd_info.is_true(a_bdd))
58 {
59 f_dot_file << " " << f_node_number << " [shape=box, label=\"T\"];" << std::endl;
60 }
61 else if (f_bdd_info.is_false(a_bdd))
62 {
63 f_dot_file << " " << f_node_number << " [shape=box, label=\"F\"];" << std::endl;
64 }
65 else if (f_bdd_info.is_if_then_else(a_bdd))
66 {
67 const data_expression v_true_branch = f_bdd_info.get_true_branch(a_bdd);
68 const data_expression v_false_branch = f_bdd_info.get_false_branch(a_bdd);
69 aux_output_bdd(v_true_branch);
70 aux_output_bdd(v_false_branch);
71 std::size_t v_true_number = f_visited[v_true_branch].value();
72 std::size_t v_false_number = f_visited[v_false_branch].value();
73 const data_expression v_guard = f_bdd_info.get_guard(a_bdd);
74 f_dot_file << " " << f_node_number << " [label=\"" << mcrl2::data::pp(v_guard) << "\"];" << std::endl;
75 f_dot_file << " " << f_node_number << " -> " << v_true_number << ";" << std::endl;
76 f_dot_file << " " << f_node_number << " -> " << v_false_number << " [style=dashed];" << std::endl;
77 }
78 else
79 {
80 f_dot_file << " " << f_node_number << " [shape=box, label=\"" << mcrl2::data::pp(a_bdd) << "\"];" << std::endl;
81 }
83 }
84
85 public:
94 void output_bdd(const data_expression &a_bdd, const std::string& a_file_name)
95 {
96 f_node_number = 0;
97 f_dot_file.open(a_file_name);
98 f_dot_file << "digraph BDD {" << std::endl;
99 aux_output_bdd(a_bdd);
100 f_dot_file << "}" << std::endl;
101 f_dot_file.close();
102 }
103};
104
105} // namespace detail
106} // namespace data
107} // namespace mcrl2
108
109#endif
An integer term stores a single std::size_t value. It carries no arguments.
Definition aterm_int.h:26
The class BDD2Dot offers the ability to write binary decision diagrams to dot files....
Definition bdd2dot.h:30
std::ofstream f_dot_file
The file the output is written to.
Definition bdd2dot.h:36
void output_bdd(const data_expression &a_bdd, const std::string &a_file_name)
Writes the BDD it receives as input to a file.
Definition bdd2dot.h:94
std::map< atermpp::aterm, atermpp::aterm_int > f_visited
A table containing all the visited nodes. It maps these nodes to the corresponding node numbers.
Definition bdd2dot.h:39
void aux_output_bdd(const data_expression &a_bdd)
Writes the BDD it receives to BDD2Dot::f_dot_file.
Definition bdd2dot.h:50
BDD_Info f_bdd_info
A class that gives information about the structure of BDDs.
Definition bdd2dot.h:42
int f_node_number
The smallest unused node number.
Definition bdd2dot.h:33
The class BDD_Info provides information about the structure of binary decision diagrams.
Definition bdd_info.h:26
static const mcrl2::data::data_expression & get_true_branch(const mcrl2::data::data_expression &a_bdd)
Method that returns the true-branch of a BDD.
Definition bdd_info.h:50
static bool is_if_then_else(const data_expression &a_bdd)
Method that indicates wether or not the root of a BDD is a guard node.
Definition bdd_info.h:85
static bool is_false(const data_expression &a_bdd)
Method that indicates whether or not a BDD equals false.
Definition bdd_info.h:76
static const mcrl2::data::data_expression & get_guard(const mcrl2::data::data_expression &a_bdd)
Method that returns the guard of a BDD.
Definition bdd_info.h:42
static const mcrl2::data::data_expression & get_false_branch(const mcrl2::data::data_expression &a_bdd)
Method that returns the false-branch of a BDD.
Definition bdd_info.h:58
static bool is_true(const data_expression &a_bdd)
Method that indicates whether or not a BDD equals true.
Definition bdd_info.h:67
std::string pp(const abstraction &x)
Definition data.cpp:39
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72