|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object IDFA
This class implements incomplete deterministic automata.
The edges going out of a state are implemented in a Queue
(class PairIntQueue
). The automaton itself
is an array of Queues. The space used by this implementation
is O(n + k + e)
for a deterministic automaton
on k
letters, n
states and e
edges,
instead of O(k n)
for the class DFA
. This representation
is preferable when k
is large.
Field Summary | |
Alphabet |
alphabet
The alphabet. |
PairIntQueue[] |
edges
The set of edges going out of a state. |
int |
initial
The initial state. |
int |
nbStates
The number of states. |
java.util.Set |
terminal
The array of terminal states. |
Constructor Summary | |
IDFA()
|
|
IDFA(IDFA b)
|
|
IDFA(int nn)
|
|
IDFA(int nn,
Alphabet a)
|
|
IDFA(int nn,
int q)
|
Method Summary | |
void |
addEdge(int p,
char a,
int q)
Adds to the automaton an edge from p to q
labeled a if it does not exist already. |
void |
addEdge(int p,
int a,
int q)
Adds to the automaton an edge from p to q
labeled alphabet.toChar(a) if it does not exist already. |
void |
addEdgeFast(int p,
char a,
int q)
Adds to the automaton an edge from p to q
labeled a . |
void |
addEdgeFast(int p,
int a,
int q)
Adds to the automaton an edge from p to q
labeled alphabet.toChar(a) . |
void |
addTerminal(int p)
|
IDFA |
addWord(java.lang.String s)
Adds a word to the set recognized by an IDFA. |
IDFA |
ecoMinimize()
Minimization in linear time using Revuz algorithm. |
void |
ecoQuotient(int[] c)
|
int |
enumerate(boolean[] b)
A call to enumerate(isOn) returns the number
of states of the trimmed automaton. |
static IDFA |
ex()
|
boolean |
explore(int p,
int[] mark)
A classical depth-first search. |
static IDFA |
fromFile(java.lang.String name)
|
int[] |
heigths()
Returns the array of heigths. |
int |
heigthsRecursive(int p,
int[] rgs)
A recursive method to compute the array of heigths from a state p . |
boolean |
isAcyclic()
True if the automaton is a DAWG, i.e. if the graph of the automaton is acyclic. |
void |
isOnPath(int p,
boolean[] isOn)
Tests wheter the states are on a successful path of the automaton. |
boolean |
isTerminal(int p)
|
static void |
main(java.lang.String[] args)
|
IDFA |
mergeLeaves()
|
IDFA |
minimize(Minimizer m)
|
IDFA |
mixMinimize()
|
int[] |
nbByHeigth(int[] h)
Returns the array of numbers of states by heigth. |
int |
next(int p,
char c)
Returns the state next(p,c) . |
void |
orderEdges()
Sorts the outgoing edges in alphabetic order. |
static IDFA |
product(IDFA a,
IDFA b)
Computes the direct product of the IDFA a
and b . |
IDFA |
quotient(int[] c)
|
IDFA |
quotient(Partition part)
|
IDFA |
randomFMinimize()
|
void |
removeEdge(int p,
char c)
|
int[] |
renumber(boolean[] b)
Gives the new names of the states after eliminating those such that b[i] = false |
ICFA |
reverse()
Computes the codeterministic automaton (ICFA) obtained by reversing the edges of a deterministic automaton (IDFA). |
void |
show(java.lang.String nom)
|
java.lang.String |
toString()
|
IDFA |
trim()
Computes the trimmed automaton equivalent to a given acyclic automaton. |
int[] |
width()
Computes the width (or outdegree) of each state. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public int nbStates
public PairIntQueue[] edges
public int initial
public java.util.Set terminal
p
is terminal if terminal[p] = 1
.
public Alphabet alphabet
Constructor Detail |
public IDFA()
public IDFA(int nn)
public IDFA(int nn, Alphabet a)
public IDFA(int nn, int q)
public IDFA(IDFA b)
Method Detail |
public static IDFA product(IDFA a, IDFA b)
a
and b
. Both IDFA share the same alphabet.
public boolean isAcyclic()
public boolean explore(int p, int[] mark)
O(m)
where m
is the number of edges.
p
- the starting state.mark
- an array of marks interpreted as
0 = unmarked 1 = active 2 = terminated.
p>/code> is
acyclic.
public void isOnPath(int p, boolean[] isOn)
p
to fill the boolean
array isOn
.
p
- a stateisOn
- A boolean array with isOn[p] = true
if
there is a path to a terminal state from state p
.public int[] renumber(boolean[] b)
b[i] = false
index
where
index[i] = n
if i
is the nth
index such that b[i] = true
.public int enumerate(boolean[] b)
enumerate(isOn)
returns the number
of states of the trimmed automaton.
b
- a boolean array
i
such that
b[i] = true
.public IDFA trim()
public void addEdge(int p, char a, int q)
p
to q
labeled a
if it does not exist already. Complexity
O(k n)
for an IDFA
with k
letters and n
states.
public void addEdge(int p, int a, int q)
p
to q
labeled alphabet.toChar(a)
if it does not exist already. Complexity
O(k n)
for an IDFA
with k
letters and n
states.
public void addEdgeFast(int p, char a, int q)
p
to q
labeled a
. Complexity
O(1)
.
public void addEdgeFast(int p, int a, int q)
p
to q
labeled alphabet.toChar(a)
. Complexity
O(1)
.
public void orderEdges()
O(u+n+e)
public int[] width()
O(n + e)
.
wid
of widths. The value of
wid[p]
is the number of edges going out of p
.public int heigthsRecursive(int p, int[] rgs)
p
.
p
- the start state.public int[] heigths()
p
is the maximal
length of a path starting at p
.
heigth
of heigths.public int[] nbByHeigth(int[] h)
h
- the array of heigths
hh
of numbers of states by heigth.
One has hh[p]=k
if there are k
states at heigth k
.public IDFA mergeLeaves()
public IDFA randomFMinimize()
public IDFA mixMinimize() throws java.lang.Exception
java.lang.Exception
public IDFA ecoMinimize() throws java.lang.Exception
java.lang.Exception
public IDFA minimize(Minimizer m) throws java.lang.Exception
java.lang.Exception
public void removeEdge(int p, char c)
public int next(int p, char c)
next(p,c)
.
public IDFA addWord(java.lang.String s)
public ICFA reverse()
O(e)
on an IDFA
with e
edges.
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public void ecoQuotient(int[] c)
public boolean isTerminal(int p)
public void addTerminal(int p)
public IDFA quotient(int[] c)
public IDFA quotient(Partition part)
public java.lang.String toString()
public void show(java.lang.String nom)
public static IDFA ex()
public static IDFA fromFile(java.lang.String name) throws java.io.IOException, java.lang.Exception
java.io.IOException
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |