more documentation for twa_graph internals
* spot/graph/graph.hh, spot/twa/twagraph.hh, spot/twa/twagraph.cc: Implement a dump_storage_as_dot() method. * python/spot/__init__.py (twa_graph.show_storage): New method, above dump_storage_as_dot(). * tests/python/twagraph-internals.ipynb: New file, with documentation about the twa_graph internals, using show_storage() to illustrate everything. * tests/Makefile.am, doc/org/tut.org: Add it. * python/spot/impl.i: Add bindings for out_iterasor, demonstrated in the Python notebook. * spot/twa/twa.hh: Add prop_reset(). Used in the notebook. * NEWS: Mention the new notebook and function. * doc/org/tut50.org: Link to the notebook. * tests/python/ipnbdoctest.py: Adjust for twa_graph_ptr being redefined in the spot namespace.
This commit is contained in:
parent
d8bc50dcb7
commit
46590af693
12 changed files with 5880 additions and 6 deletions
|
|
@ -175,6 +175,13 @@ class twa:
|
|||
f.write('\n')
|
||||
return a
|
||||
|
||||
@_extend(twa_graph)
|
||||
class twa_graph:
|
||||
def show_storage(self, opt=None):
|
||||
ostr = ostringstream()
|
||||
self.dump_storage_as_dot(ostr, opt)
|
||||
from IPython.display import SVG
|
||||
return SVG(_ostream_to_svg(ostr))
|
||||
|
||||
@_extend(formula)
|
||||
class formula:
|
||||
|
|
@ -761,6 +768,7 @@ def postprocess(automaton, *args, formula=None):
|
|||
|
||||
twa.postprocess = postprocess
|
||||
|
||||
|
||||
# Wrap C++-functions into lambdas so that they get converted into
|
||||
# instance methods (i.e., self passed as first argument
|
||||
# automatically), because only user-defined functions are converted as
|
||||
|
|
|
|||
|
|
@ -509,6 +509,7 @@ namespace std {
|
|||
%include <spot/graph/graph.hh>
|
||||
%nodefaultctor spot::digraph;
|
||||
%nodefaultctor spot::internal::state_out;
|
||||
%nodefaultctor spot::internal::killer_edge_iterator;
|
||||
%nodefaultctor spot::internal::all_trans;
|
||||
%nodefaultctor spot::internal::universal_dests;
|
||||
%traits_swigtype(spot::internal::edge_storage<unsigned int, unsigned int, unsigned int, spot::internal::boxed_label<spot::twa_graph_edge_data, false> >);
|
||||
|
|
@ -556,6 +557,7 @@ def state_is_accepting(self, src) -> "bool":
|
|||
|
||||
%include <spot/twa/twagraph.hh>
|
||||
%template(twa_graph_state_out) spot::internal::state_out<spot::digraph<spot::twa_graph_state, spot::twa_graph_edge_data>>;
|
||||
%template(twa_graph_killer_edge_iterator) spot::internal::killer_edge_iterator<spot::digraph<spot::twa_graph_state, spot::twa_graph_edge_data>>;
|
||||
%template(twa_graph_all_trans) spot::internal::all_trans<spot::digraph<spot::twa_graph_state, spot::twa_graph_edge_data>>;
|
||||
%template(twa_graph_edge_boxed_data) spot::internal::boxed_label<spot::twa_graph_edge_data, false>;
|
||||
%template(twa_graph_edge_storage) spot::internal::edge_storage<unsigned int, unsigned int, unsigned int, spot::internal::boxed_label<spot::twa_graph_edge_data, false> >;
|
||||
|
|
@ -799,6 +801,23 @@ def state_is_accepting(self, src) -> "bool":
|
|||
}
|
||||
}
|
||||
|
||||
%extend spot::internal::killer_edge_iterator<spot::digraph<spot::twa_graph_state, spot::twa_graph_edge_data>> {
|
||||
|
||||
spot::internal::edge_storage<unsigned int, unsigned int, unsigned int, spot::internal::boxed_label<spot::twa_graph_edge_data, false> >& current()
|
||||
{
|
||||
return **self;
|
||||
}
|
||||
|
||||
void advance()
|
||||
{
|
||||
++*self;
|
||||
}
|
||||
bool __bool__()
|
||||
{
|
||||
return *self;
|
||||
}
|
||||
}
|
||||
|
||||
%extend spot::internal::all_trans<spot::digraph<spot::twa_graph_state, spot::twa_graph_edge_data>> {
|
||||
swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue