12#ifndef MCRL2_PBES_STRUCTURE_GRAPH_BUILDER_H
13#define MCRL2_PBES_STRUCTURE_GRAPH_BUILDER_H
15#include <mcrl2/atermpp/standard_containers/unordered_map.h>
16#include "mcrl2/pbes/pbessolve_vertex_set.h"
86 throw std::runtime_error(
"structure_graph_builder: encountered unsupported pbes_expression " + pp(x));
91 assert(m_vertex_map.find(x) == m_vertex_map.end());
93 vertices().emplace_back(x, decoration(x));
94 index_type index = vertices().size() - 1;
95 m_vertex_map.insert({ x, index });
102 auto i = m_vertex_map.find(x);
103 index_type ui = i == m_vertex_map.end() ? create_vertex(x) :
static_cast<
unsigned int>(i->second);
104 auto& u = vertex(ui);
113 auto i = m_vertex_map.find(x);
114 if (i != m_vertex_map.end())
127 auto i = m_vertex_map.find(x);
128 if (i != m_vertex_map.end())
140 auto& u = vertex(ui);
141 auto& v = vertex(vi);
142 if (!contains(u.successors, vi))
144 u.successors.push_back(vi);
145 v.predecessors.push_back(ui);
156 auto i = m_vertex_map.find(m_initial_state);
157 assert (i != m_vertex_map.end());
165 m_graph.m_exclude = boost::dynamic_bitset<>(m_graph.extent());
170 auto i = m_vertex_map.find(x);
171 if (i == m_vertex_map.end())
173 return undefined_vertex();
185 std::vector<index_type> index;
187 for (index_type u = 0; u != vertices().size(); u++)
189 index.push_back(U.contains(u) ? undefined_vertex() : count++);
193 auto update = [&](
const std::vector<index_type>& V) {
194 std::vector<index_type> result;
197 if (index[v] != undefined_vertex())
199 result.push_back(index[v]);
205 for (index_type u = 0; u != vertices().size(); u++)
207 if (index[u] != undefined_vertex())
209 structure_graph::vertex& u_ = vertex(u);
210 u_.predecessors = update(u_.predecessors);
211 u_.successors = update(u_.successors);
212 if (u_.strategy != undefined_vertex())
214 u_.strategy = index[u_.strategy];
218 std::swap(vertex(u), vertex(index[u]));
223 vertices().erase(vertices().begin() +
static_cast<std::ptrdiff_t>(vertices().size() - U.size()), vertices().end());
226 m_vertex_map.clear();
227 for (std::size_t i = 0; i < vertices().size(); i++)
229 m_vertex_map.insert({vertex(i).formula(), i});
249 m_vertices.emplace_back(pbes_expression(), is_conjunctive ? structure_graph::d_conjunction : structure_graph::d_disjunction, rank);
250 return m_vertices.size() - 1;
258 if (!contains(u.successors, vi))
260 u.successors.push_back(vi);
261 v.predecessors.push_back(ui);
282 m_graph.m_vertices = m_vertices;
285 std::size_t N = m_vertices.size();
286 m_graph.m_exclude = boost::dynamic_bitset<>(N);
pbes_expression & operator=(const pbes_expression &) noexcept=default
pbes_expression(const data::data_expression &x)
\brief Constructor Z6.
\brief A propositional variable instantiation
index_type m_initial_vertex
const data::data_expression & undefined_data_expression()
Returns a data expression that corresponds to 'undefined'.
bool is_or(const atermpp::aterm &x)
bool is_false(const pbes_expression &t)
Test for the value false.
bool is_propositional_variable_instantiation(const atermpp::aterm &x)
bool is_and(const atermpp::aterm &x)
bool is_true(const pbes_expression &t)
Test for the value true.
void finalize()
call at the end, to put the results into m_graph
index_type m_initial_state
void insert_edge(index_type ui, index_type vi)
structure_graph::vertex_vector m_vertices
void set_initial_state(const index_type i)
index_type insert_vertex(bool is_conjunctive, std::size_t rank)
Create a vertex, returns the index of the new vertex.
manual_structure_graph_builder(structure_graph &G)
void remove_edge(index_type ui, index_type vi)
structure_graph & m_graph
void erase_vertices(const vertex_set &U)
index_type insert_variable(const pbes_expression &x, const pbes_expression &psi, std::size_t k)
void insert_edge(index_type ui, index_type vi)
structure_graph::index_type initial_vertex() const
void set_initial_state(const propositional_variable_instantiation &x)
pbes_expression m_initial_state
index_type create_vertex(const pbes_expression &x)
structure_graph::decoration_type decoration(const pbes_expression &x) const
structure_graph & m_graph
structure_graph_builder(structure_graph &G)
const structure_graph::vertex_vector & vertices() const
index_type insert_vertex(const pbes_expression &x)
index_type find_vertex(const pbes_expression &x) const
std::size_t extent() const
structure_graph::vertex_vector & vertices()
index_type insert_variable(const pbes_expression &x)
void remove_predecessor(index_type u)
decoration_type decoration
void remove_successor(index_type u)