From 42b95c530f1b81530fd3b49af3696c1ef3aa13d3 Mon Sep 17 00:00:00 2001 From: Paul Mercat Date: Tue, 19 Jul 2016 18:26:37 +0200 Subject: [PATCH] Add functions rec_word() and find_word() to FastAutomaton, and modify function is_empty(). --- src/sage/combinat/words/automataC.c | 48 +++++++++++++++++++++++++++ src/sage/combinat/words/automataC.h | 2 ++ src/sage/combinat/words/cautomata.pyx | 41 +++++++++++++++++++---- 3 files changed, 85 insertions(+), 6 deletions(-) diff --git a/src/sage/combinat/words/automataC.c b/src/sage/combinat/words/automataC.c index 7bb1b1982b3..93c7dfaba22 100644 --- a/src/sage/combinat/words/automataC.c +++ b/src/sage/combinat/words/automataC.c @@ -739,6 +739,54 @@ bool emptyLangage (Automaton a) return res; } +bool findWord_rec (Automaton a, int e, int n, Dict *w, bool verb) +{ + if (a.e[e].final) + { + if (verb) + printf("Alloue un mot de taille %d.\n", n); + *w = NewDict(n); + return true; + } + //indique que le sommet a été vu + a.e[e].final |= 2; + //parcours les fils + int i; + for (i=0;ie[n] = i; + return true; + } + } + } + return false; +} + +//rend un mot dans le langage de a +bool findWord (Automaton a, Dict *w, bool verb) +{ + if (a.i == -1) + return false; + bool res = findWord_rec(a, a.i, 0, w, verb); + //remet les états finaux + int i; + for (i=0;i