spot 2.3.1

- Main Page
- Related Pages
- Modules
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
spot::digraph< State_Data, Edge_Data > Class Template Reference

A directed graph. More...

`#include <spot/graph/graph.hh>`

Inheritance diagram for spot::digraph< State_Data, Edge_Data >:
Collaboration diagram for spot::digraph< State_Data, Edge_Data >:

## Public Types
typedef internal::edge_iterator < digraph > | iterator
typedef internal::edge_iterator< const digraph > | const_iterator
typedef State_Data | state_data_t
typedef Edge_Data | edge_data_t
typedef unsigned | state
typedef unsigned | edge
typedef internal::distate_storage < edge, internal::boxed_label < State_Data > > | state_storage_t
typedef internal::edge_storage < state, state, edge, internal::boxed_label < Edge_Data > > | edge_storage_t
typedef std::vector < state_storage_t > | state_vector
typedef std::vector < edge_storage_t > | edge_vector_t
typedef std::vector< unsigned > | dests_vector_t

## Public Member Functions
| digraph (unsigned max_states=10, unsigned max_trans=0)
| Construct an empty graph. More...
unsigned | num_states () const
| The number of states in the automaton. More...
unsigned | num_edges () const
| The number of edges in the automaton. More...
bool | is_existential () const
| Whether the automaton uses only existential branching. More...
bool | is_alternating () const
| Whether the automaton has universal branching. More...
template<typename... Args>
state | new_state (Args &&...args)
| Create a new states. More...
template<typename... Args>
state | new_states (unsigned n, Args &&...args)
| Create n new states. More...
template<typename... Args>
edge | new_edge (state src, state dst, Args &&...args)
| Create a new edge. More...
template<typename I >
state | new_univ_dests (I dst_begin, I dst_end)
| Create a new universal destination group. More...
template<typename I , typename... Args>
edge | new_univ_edge (state src, I dst_begin, I dst_end, Args &&...args)
| Create a new universal edge. More...
template<typename... Args>
edge | new_univ_edge (state src, const std::initializer_list< state > &dsts, Args &&...args)
| Create a new universal edge. More...
internal::const_universal_dests | univ_dests (state src) const
internal::const_universal_dests | univ_dests (const edge_storage_t &e) const
state | index_of_state (const state_storage_t &ss) const
| Convert a storage reference into a state number. More...
edge | index_of_edge (const edge_storage_t &tt) const
| Conveart a storage reference into an edge number. More...
bool | is_valid_edge (edge t) const
| Test whether the given edge is valid. More...
void | dump_storage (std::ostream &o) const
| Dump the state and edge storage for debugging. More...
void | remove_dead_edges_ ()
| Remove all dead edges. More...
template<class Predicate = std::less<edge_storage_t>>
void | sort_edges_ (Predicate p=Predicate())
| Sort all edge according to a predicate. More...
void | chain_edges_ ()
| Reconstruct the chain of outgoing edges. More...
void | rename_states_ (const std::vector< unsigned > &newst)
| Rename all the states in the edge vector. More...
void | defrag_states (std::vector< unsigned > &&newst, unsigned used_states)
| Rename and remove states. More...
state_storage_t & | state_storage (state s)
| return a reference to the storage of a state More...
const state_storage_t & | state_storage (state s) const
| return a reference to the storage of a state More...
state_storage_t::data_t & | state_data (state s)
| return the State_Data associated to a state More...
const state_storage_t::data_t & | state_data (state s) const
| return the State_Data associated to a state More...
edge_storage_t & | edge_storage (edge s)
| return a reference to the storage of an edge More...
const edge_storage_t & | edge_storage (edge s) const
| return a reference to the storage of an edge More...
edge_storage_t::data_t & | edge_data (edge s)
| return the Edgeg_Data of an edge. More...
const edge_storage_t::data_t & | edge_data (edge s) const
| return the Edgeg_Data of an edge. More...
internal::state_out< digraph > | out (state src)
| Return a fake container with all edges leaving src. More...
internal::state_out< digraph > | out (state_storage_t &src)
| Return a fake container with all edges leaving src. More...
internal::state_out< const digraph > | out (state src) const
| Return a fake container with all edges leaving src. More...
internal::state_out< const digraph > | out (state_storage_t &src) const
| Return a fake container with all edges leaving src. More...
internal::killer_edge_iterator < digraph > | out_iteraser (state_storage_t &src)
| Return a fake container with all edges leaving src, allowing erasure. More...
internal::killer_edge_iterator < digraph > | out_iteraser (state src)
| Return a fake container with all edges leaving src, allowing erasure. More...
const state_vector & | states () const
| Return the vector of states. More...
state_vector & | states ()
| Return the vector of states. More...
internal::all_trans< const digraph > | edges () const
| Return a fake container with all edges (exluding erased edges) More...
internal::all_trans< digraph > | edges ()
| Return a fake container with all edges (exluding erased edges) More...
const edge_vector_t & | edge_vector () const
| Return the vector of all edges. More...
edge_vector_t & | edge_vector ()
| Return the vector of all edges. More...
bool | is_dead_edge (unsigned t) const
| Tests whether an edge has been erased. More...
bool | is_dead_edge (const edge_storage_t &t) const
| Tests whether an edge has been erased. More...
const dests_vector_t & | dests_vector () const
| The vector used to store universal destinations. More...
dests_vector_t & | dests_vector ()
| The vector used to store universal destinations. More...

## Protected Attributes
state_vector | states_
edge_vector_t | edges_
dests_vector_t | dests_
unsigned | killed_edge_

## Friends
class | internal::edge_iterator< digraph >
class | internal::edge_iterator< const digraph >
class | internal::killer_edge_iterator< digraph >

## Detailed Description

### template<typename State_Data, typename Edge_Data>
class spot::digraph< State_Data, Edge_Data >

A directed graph.

Template Parameters

  State_Data | data to attach to states
  Edge_Data | data to attach to edges

## Constructor & Destructor Documentation

template<typename State_Data, typename Edge_Data>

spot::digraph< State_Data, Edge_Data >::digraph | ( | unsigned | max_states = `10`,
|  | unsigned | max_trans = `0`
| ) |  |
| inline

Construct an empty graph.

Construct an empty graph, and reserve space for max_states states and max_trans edges. These are not hard limits, but just hints to pre-allocate a data structure that may hold that much items.

## Member Function Documentation

template<typename State_Data, typename Edge_Data>

void spot::digraph< State_Data, Edge_Data >::chain_edges_ | ( |  | ) |
| inline

Reconstruct the chain of outgoing edges.

Should be called only when it is known that all edges with the same destination are consecutive in the vector.

template<typename State_Data, typename Edge_Data>

void spot::digraph< State_Data, Edge_Data >::defrag_states | ( | std::vector< unsigned > && | newst,
|  | unsigned | used_states
| ) |  |
| inline

Rename and remove states.

Parameters

  newst | A vector indicating how each state should be renumbered. Use -1U to erase a state.
  used_states | the number of states used (after renumbering)

template<typename State_Data, typename Edge_Data>

const dests_vector_t& spot::digraph< State_Data, Edge_Data >::dests_vector | ( |  | ) | const
| inline

The vector used to store universal destinations.

The actual way those destinations are stored is an implementation detail you should not rely on.

template<typename State_Data, typename Edge_Data>

dests_vector_t& spot::digraph< State_Data, Edge_Data >::dests_vector | ( |  | ) |
| inline

The vector used to store universal destinations.

The actual way those destinations are stored is an implementation detail you should not rely on.

template<typename State_Data, typename Edge_Data>

void spot::digraph< State_Data, Edge_Data >::dump_storage | ( | std::ostream & | o | ) | const
| inline

Dump the state and edge storage for debugging.

template<typename State_Data, typename Edge_Data>

edge_storage_t::data_t& spot::digraph< State_Data, Edge_Data >::edge_data | ( | edge | s | ) |
| inline

return the Edgeg_Data of an edge.

This does not use Edge_Data& as return type, because Edge_Data might be void.

template<typename State_Data, typename Edge_Data>

const edge_storage_t::data_t& spot::digraph< State_Data, Edge_Data >::edge_data | ( | edge | s | ) | const
| inline

return the Edgeg_Data of an edge.

This does not use Edge_Data& as return type, because Edge_Data might be void.

template<typename State_Data, typename Edge_Data>

edge_storage_t& spot::digraph< State_Data, Edge_Data >::edge_storage | ( | edge | s | ) |
| inline

return a reference to the storage of an edge

The storage includes any of the user-supplied Edge_Data, plus some custom fields needed to find the next transitions.

template<typename State_Data, typename Edge_Data>

const edge_storage_t& spot::digraph< State_Data, Edge_Data >::edge_storage | ( | edge | s | ) | const
| inline

return a reference to the storage of an edge

The storage includes any of the user-supplied Edge_Data, plus some custom fields needed to find the next transitions.

template<typename State_Data, typename Edge_Data>

const edge_vector_t& spot::digraph< State_Data, Edge_Data >::edge_vector | ( |  | ) | const
| inline

Return the vector of all edges.

When using this method, beware that the first entry (edge #0) is not a real edge, and that any edge with next_succ pointing to itself is an erased edge.

You should probably use edges() instead.

template<typename State_Data, typename Edge_Data>

edge_vector_t& spot::digraph< State_Data, Edge_Data >::edge_vector | ( |  | ) |
| inline

Return the vector of all edges.

When using this method, beware that the first entry (edge #0) is not a real edge, and that any edge with next_succ pointing to itself is an erased edge.

You should probably use edges() instead.

template<typename State_Data, typename Edge_Data>

internal::all_trans<const digraph> spot::digraph< State_Data, Edge_Data >::edges | ( |  | ) | const
| inline

Return a fake container with all edges (exluding erased edges)

template<typename State_Data, typename Edge_Data>

internal::all_trans<digraph> spot::digraph< State_Data, Edge_Data >::edges | ( |  | ) |
| inline

Return a fake container with all edges (exluding erased edges)

template<typename State_Data, typename Edge_Data>

edge spot::digraph< State_Data, Edge_Data >::index_of_edge | ( | const edge_storage_t & | tt | ) | const
| inline

Conveart a storage reference into an edge number.

template<typename State_Data, typename Edge_Data>

state spot::digraph< State_Data, Edge_Data >::index_of_state | ( | const state_storage_t & | ss | ) | const
| inline

Convert a storage reference into a state number.

template<typename State_Data, typename Edge_Data>

bool spot::digraph< State_Data, Edge_Data >::is_alternating | ( |  | ) | const
| inline

Whether the automaton has universal branching.

The name of this function is confusing since non-deterministic automata should be a subclass of alternating automata.

template<typename State_Data, typename Edge_Data>

bool spot::digraph< State_Data, Edge_Data >::is_dead_edge | ( | unsigned | t | ) | const
| inline

Tests whether an edge has been erased.

See also
  is_valid_edge

template<typename State_Data, typename Edge_Data>

bool spot::digraph< State_Data, Edge_Data >::is_dead_edge | ( | const edge_storage_t & | t | ) | const
| inline

Tests whether an edge has been erased.

See also
  is_valid_edge

template<typename State_Data, typename Edge_Data>

bool spot::digraph< State_Data, Edge_Data >::is_existential | ( |  | ) | const
| inline

Whether the automaton uses only existential branching.

template<typename State_Data, typename Edge_Data>

bool spot::digraph< State_Data, Edge_Data >::is_valid_edge | ( | edge | t | ) | const
| inline

Test whether the given edge is valid.

An edge is valid if its number is less than the total number of edges, and it does not correspond to an erased (dead) edge.

See also
  is_dead_edge()

Referenced by spot::kripke_graph::succ_iter().

template<typename State_Data, typename Edge_Data>
template<typename... Args>

edge spot::digraph< State_Data, Edge_Data >::new_edge | ( | state | src,
|  | state | dst,
|  | Args &&... | args
| ) |  |
| inline

Create a new edge.

Parameters

  src | the source state
  dst | the destination state
  args | arguments to forward to the Edge_Data constructor

template<typename State_Data, typename Edge_Data>
template<typename... Args>

state spot::digraph< State_Data, Edge_Data >::new_state | ( | Args &&... | args | ) |
| inline

Create a new states.

All arguments are forwarded to the State_Data constructor.

Returns
  a state number

template<typename State_Data, typename Edge_Data>
template<typename... Args>

state spot::digraph< State_Data, Edge_Data >::new_states | ( | unsigned | n,
|  | Args &&... | args
| ) |  |
| inline

Create n new states.

All arguments are forwarded to the State_Data constructor of each of the n states.

Returns
  the first state number

template<typename State_Data, typename Edge_Data>
template<typename I >

state spot::digraph< State_Data, Edge_Data >::new_univ_dests | ( | I | dst_begin,
|  | I | dst_end
| ) |  |
| inline

Create a new universal destination group.

The resulting state number can be used as the destination of an edge.

Parameters

  dst_begin | start of a non-empty container of destination states
  dst_end | end of a non-empty container of destination states

template<typename State_Data, typename Edge_Data>
template<typename I , typename... Args>

edge spot::digraph< State_Data, Edge_Data >::new_univ_edge | ( | state | src,
|  | I | dst_begin,
|  | I | dst_end,
|  | Args &&... | args
| ) |  |
| inline

Create a new universal edge.

Parameters

  src | the source state
  dst_begin | start of a non-empty container of destination states
  dst_end | end of a non-empty container of destination states
  args | arguments to forward to the Edge_Data constructor

template<typename State_Data, typename Edge_Data>
template<typename... Args>

edge spot::digraph< State_Data, Edge_Data >::new_univ_edge | ( | state | src,
|  | const std::initializer_list< state > & | dsts,
|  | Args &&... | args
| ) |  |
| inline

Create a new universal edge.

Parameters

  src | the source state
  dsts | a non-empty list of destination states
  args | arguments to forward to the Edge_Data constructor

template<typename State_Data, typename Edge_Data>

unsigned spot::digraph< State_Data, Edge_Data >::num_edges | ( |  | ) | const
| inline

The number of edges in the automaton.

Killed edges are omitted.

template<typename State_Data, typename Edge_Data>

unsigned spot::digraph< State_Data, Edge_Data >::num_states | ( |  | ) | const
| inline

The number of states in the automaton.

template<typename State_Data, typename Edge_Data>

internal::state_out<digraph> spot::digraph< State_Data, Edge_Data >::out | ( | state | src | ) |
| inline

Return a fake container with all edges leaving src.

template<typename State_Data, typename Edge_Data>

internal::state_out<digraph> spot::digraph< State_Data, Edge_Data >::out | ( | state_storage_t & | src | ) |
| inline

Return a fake container with all edges leaving src.

template<typename State_Data, typename Edge_Data>

internal::state_out<const digraph> spot::digraph< State_Data, Edge_Data >::out | ( | state | src | ) | const
| inline

Return a fake container with all edges leaving src.

template<typename State_Data, typename Edge_Data>

internal::state_out<const digraph> spot::digraph< State_Data, Edge_Data >::out | ( | state_storage_t & | src | ) | const
| inline

Return a fake container with all edges leaving src.

template<typename State_Data, typename Edge_Data>

internal::killer_edge_iterator<digraph> spot::digraph< State_Data, Edge_Data >::out_iteraser | ( | state_storage_t & | src | ) |
| inline

Return a fake container with all edges leaving src, allowing erasure.

template<typename State_Data, typename Edge_Data>

internal::killer_edge_iterator<digraph> spot::digraph< State_Data, Edge_Data >::out_iteraser | ( | state | src | ) |
| inline

Return a fake container with all edges leaving src, allowing erasure.

template<typename State_Data, typename Edge_Data>

void spot::digraph< State_Data, Edge_Data >::remove_dead_edges_ | ( |  | ) |
| inline

Remove all dead edges.

The edges_ vector is left in a state that is incorrect and should eventually be fixed by a call to chain_edges_() before any iteration on the successor of a state is performed.

template<typename State_Data, typename Edge_Data>

void spot::digraph< State_Data, Edge_Data >::rename_states_ | ( | const std::vector< unsigned > & | newst | ) |
| inline

Rename all the states in the edge vector.

The edges_ vector is left in a state that is incorrect and should eventually be fixed by a call to chain_edges_() before any iteration on the successor of a state is performed.

template<typename State_Data, typename Edge_Data>
template<class Predicate = std::less<edge_storage_t>>

void spot::digraph< State_Data, Edge_Data >::sort_edges_ | ( | Predicate | p = `Predicate()` | ) |
| inline

Sort all edge according to a predicate.

This will invalidate all iterators, and also destroy edge chains. Call chain_edges_() immediately afterwards unless you know what you are doing.

template<typename State_Data, typename Edge_Data>

state_storage_t::data_t& spot::digraph< State_Data, Edge_Data >::state_data | ( | state | s | ) |
| inline

return the State_Data associated to a state

This does not use State_Data& as return type, because State_Data might be void.

template<typename State_Data, typename Edge_Data>

const state_storage_t::data_t& spot::digraph< State_Data, Edge_Data >::state_data | ( | state | s | ) | const
| inline

return the State_Data associated to a state

This does not use State_Data& as return type, because State_Data might be void.

template<typename State_Data, typename Edge_Data>

state_storage_t& spot::digraph< State_Data, Edge_Data >::state_storage | ( | state | s | ) |
| inline

return a reference to the storage of a state

The storage includes any of the user-supplied State_Data, plus some custom fields needed to find the outgoing transitions.

template<typename State_Data, typename Edge_Data>

const state_storage_t& spot::digraph< State_Data, Edge_Data >::state_storage | ( | state | s | ) | const
| inline

return a reference to the storage of a state

The storage includes any of the user-supplied State_Data, plus some custom fields needed to find the outgoing transitions.

template<typename State_Data, typename Edge_Data>

const state_vector& spot::digraph< State_Data, Edge_Data >::states | ( |  | ) | const
| inline

Return the vector of states.

template<typename State_Data, typename Edge_Data>

state_vector& spot::digraph< State_Data, Edge_Data >::states | ( |  | ) |
| inline

Return the vector of states.

The documentation for this class was generated from the following file:

- spot/graph/graph.hh

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.