Package tulip :: Package transys :: Module labeled_graphs :: Class Transitions
[frames] | no frames]

Class Transitions


Methods for handling labeled transitions.

Note that a directed edge is an ordered set of nodes. Unlike an edge, a transition is a labeled edge.

Instance Methods
 
__init__(self, graph, deterministic=False)
Initialize Transitions.
 
__call__(self, **kwargs)
Return list of transitions.
 
__str__(self)
str(x)
 
__len__(self)
Count transitions.
 
add(self, from_state, to_state, attr_dict=None, check=True, **attr)
Wrapper of LabeledDiGraph.add_edge,
 
add_from(self, transitions, attr_dict=None, check=True, **attr)
Wrapper of LabeledDiGraph.add_edges_from,
 
add_comb(self, from_states, to_states, attr_dict=None, check=True, **attr)
Add an edge for each combination (u, v),
 
remove(self, from_state, to_state, attr_dict=None, **attr)
Remove single transition.
 
remove_from(self, transitions)
Remove list of transitions.
 
add_adj(self, adj, adj2states, attr_dict=None, check=True, **attr)
Add multiple labeled transitions from adjacency matrix.
list of transitions:
       = list of labeled edges
       = [(from_state, to_state, label),...]

where:

  • from_state in from_states
  • to_state in to_states
  • label: dict
find(self, from_states=None, to_states=None, with_attr_dict=None, typed_only=False, **with_attr)
Find all edges between given states with given labels.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, graph, deterministic=False)
(Constructor)

 

Initialize Transitions.

Parameters:
Overrides: object.__init__

__call__(self, **kwargs)
(Call operator)

 

Return list of transitions.

Wraps LabeledDiGraph.edges.

__str__(self)
(Informal representation operator)

 

str(x)

Overrides: object.__str__
(inherited documentation)

add(self, from_state, to_state, attr_dict=None, check=True, **attr)

 

Wrapper of LabeledDiGraph.add_edge,

which wraps networkx.MultiDiGraph.add_edge.

add_from(self, transitions, attr_dict=None, check=True, **attr)

 

Wrapper of LabeledDiGraph.add_edges_from,

which wraps networkx.MultiDiGraph.add_edges_from.

add_comb(self, from_states, to_states, attr_dict=None, check=True, **attr)

 

Add an edge for each combination (u, v),

for u in from_states for v in to_states.

remove(self, from_state, to_state, attr_dict=None, **attr)

 

Remove single transition.

If only the states are passed, then all transitions between them are removed.

If attr_dict, attr are also passed, then only transitions annotated with those labels are removed.

Wraps LabeledDiGraph.remove_labeled_edge.

remove_from(self, transitions)

 

Remove list of transitions.

Each transition is either a:

  • 2-tuple: (u, v), or a
  • 3-tuple: (u, v, data)

add_adj(self, adj, adj2states, attr_dict=None, check=True, **attr)

 

Add multiple labeled transitions from adjacency matrix.

The label can be empty. For more details see add.

Parameters:
  • adj (scipy.sparse.lil (list of lists)) - new transitions represented by adjacency matrix.
  • adj2states (either of:
    • dict from adjacency matrix indices to existing, or
    • list of existing states
    ) - map from adjacency matrix indices to states. If value not a state, raise Exception. Use States.add, States.add_from to add states first.

    For example the 1st state in adj2states corresponds to the first node in adj.

    States must have been added using:

    • sys.states.add, or
    • sys.states.add_from

    If adj2states includes a state not in sys.states, no transition is added and an exception raised.

find(self, from_states=None, to_states=None, with_attr_dict=None, typed_only=False, **with_attr)

 

Find all edges between given states with given labels.

Instead of having two separate methods to:

  • find all labels of edges between given states (s1, s2)
  • find all transitions (s1, s2, L) with given label L, possibly from some given state s1, i.e., the edges leading to the successor states Post(s1, a) = Post(s1) restricted by action a

this method provides both functionalities.

Preimage under edge labeling function L of given label, intersected with given subset of edges:

   L^{-1}(desired_label) \cap (from_states x to_states)

See Also

add, add_adj

Parameters:
  • from_states (
    • iterable of existing states, or
    • None (no constraint, default)
    ) - edges must start from this subset of states
  • to_states (
    • iterable of existing states, or
    • None (no constraint, default)
    ) - edges must end in this subset of states
  • with_attr_dict (
    • {label_type : desired_label_value, ...}, or
    • None (no constraint, default)
    ) - edges must be annotated with these labels
  • with_attr - label type-value pairs, take precedence over desired_label.
Returns: list of transitions:
       = list of labeled edges
       = [(from_state, to_state, label),...]

where:

  • from_state in from_states
  • to_state in to_states
  • label: dict
set of transitions = labeled edges:
       (from_state, to_state, label)

such that:

       (from_state, to_state )
       in from_states x to_states