statex v0.1.0 Statex.StateGraph View Source

module containing utility functions for dealing with stategraphs.

Stategraphs are a data structure based on elixir's keyword lists. The entire stategraph is a keyword list of all of the atoms representing state; the values are themselves keyword lists of transitions mapping back to state.

For example:

  [state1: [flipflop: :state2],
   state2: [flipflop: :state1]]

is a simple flip-flop state machine.

Link to this section Summary

Functions

returns the states from the state graph structure

returns all states from which there are no outward transitions

returns all of the transitions from the state graph structure

returns the successful state after transition, or an error tuple

Link to this section Types

Link to this section Functions

Link to this function

first_state(list) View Source
first_state(t()) :: atom()

Link to this function

states(stategraph) View Source
states(t()) :: [atom()]

returns the states from the state graph structure

Link to this function

terminal_states(stategraph) View Source
terminal_states(t()) :: [atom()]

returns all states from which there are no outward transitions.

Link to this function

transitions(stategraph) View Source
transitions(t() | {atom(), keyword(atom())}) :: [atom()]

returns all of the transitions from the state graph structure

Link to this function

validate_graph_structure!(state_graph) View Source
validate_graph_structure!(any()) :: :ok | no_return()

Link to this function

validate_node_transitions!(list, full_graph) View Source
validate_node_transitions!(list(), list()) :: :ok | no_return()

Link to this function

validate_nodes!(list, full_graph) View Source
validate_nodes!(list(), list()) :: :ok | no_return()

Link to this function

validate_transition(stategraph, start, transition) View Source
validate_transition(t(), atom(), atom()) :: atom() | {:error, String.t()}

returns the successful state after transition, or an error tuple.