automaton.weight_series

Compute the sum of all the weights of the behavior. Find weighted distance between initial and final states.

Implementations:

  • With a tropical weightset: Shortest path algorithm.
  • Otherwise: Proper applied to the spontaneous version of the automaton, i.e., as if all the labels were replaced by the empty word.

Examples

In [1]:
import vcsn

In a Tropical Semiring

In [2]:
%%automaton a
context = "lal_char, zmin"
$ -> 0
0 -> 1 <6>a
0 -> 2 <1>a
2 -> 3 <1>b
3 -> 4 <1>c
4 -> 1 <1>d
0 -> 5 <2>a
5 -> 1 <3>b
1 -> $
%3 I0 0 0 I0->0 ⟨0⟩ F1 1 1 0->1 ⟨6⟩a 2 2 0->2 ⟨1⟩a 5 5 0->5 ⟨2⟩a 1->F1 ⟨0⟩ 3 3 2->3 ⟨1⟩b 4 4 3->4 ⟨1⟩c 4->1 ⟨1⟩d 5->1 ⟨3⟩b
In [3]:
a.weight_series()
Out[3]:
$4$

In $\mathbb{Q}$

In [4]:
%%automaton b
context = "lal_char, q"
$ -> 0
0 -> 1 <6>a
0 -> 2 <1>a
2 -> 3 <1>b
3 -> 4 <1>c
4 -> 1 <1>d
0 -> 5 <2>a
5 -> 1 <3>b
1 -> $
%3 I0 0 0 I0->0 F1 1 1 0->1 ⟨6⟩a 2 2 0->2 a 5 5 0->5 ⟨2⟩a 1->F1 3 3 2->3 b 4 4 3->4 c 4->1 d 5->1 ⟨3⟩b
In [5]:
b.weight_series()
Out[5]:
$13$