# 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 ->$

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 ->$

In [5]:
b.weight_series()

Out[5]:
$13$