Spin networks, quantum automata and link invariants