@@ -7,7 +7,6 @@ import { startDragTools } from "./dragTools.js";
7
7
import { initGraph } from "./graph.js" ;
8
8
import { CircleShape , FILL_NODE_FINAL } from "./shapes.js" ;
9
9
import download from "./utils/download.js" ;
10
- import { verifyAFND } from "./afnd.js" ;
11
10
12
11
const { graph, paper } = initGraph ( ) ;
13
12
const inputString = document . querySelector ( "#input-string" ) ;
@@ -27,7 +26,7 @@ function run() {
27
26
const alphabet = [ ] ;
28
27
const string = inputString . value ;
29
28
const statesArr = [ ] ;
30
- const transitions = { } ;
29
+ const transitions = [ ] ;
31
30
32
31
// clear errors
33
32
renderError ( null ) ;
@@ -39,8 +38,6 @@ function run() {
39
38
id : el . attributes . id ,
40
39
} ;
41
40
42
- transitions [ el . attributes . attrs . label . text ] = { } ;
43
-
44
41
if ( el . attributes . attrs . body . fill === FILL_NODE_FINAL ) {
45
42
finalStates . push ( el . attributes . attrs . label . text ) ;
46
43
}
@@ -51,24 +48,11 @@ function run() {
51
48
if ( el . type === "Link" ) {
52
49
alphabet . push ( ...el . labels [ 0 ] . attrs . text . text . split ( "," ) ) ;
53
50
54
- el . labels [ 0 ] . attrs . text . text . split ( "," ) . forEach ( ( symbol ) => {
55
- if ( transitions [ states [ el . source . id ] . text ] [ symbol ] ) {
56
- transitions [ states [ el . source . id ] . text ] [ symbol ] = [
57
- ...transitions [ states [ el . source . id ] . text ] [ symbol ] ,
58
- states [ el . target . id ] . text ,
59
- ] ;
60
- } else {
61
- transitions [ states [ el . source . id ] . text ] [ symbol ] = [
62
- states [ el . target . id ] . text ,
63
- ] ;
64
- }
51
+ transitions . push ( {
52
+ state : states [ el . source . id ] . text ,
53
+ symbol : el . labels [ 0 ] . attrs . text . text . split ( "," ) || "transition" ,
54
+ nextState : states [ el . target . id ] . text ,
65
55
} ) ;
66
-
67
- // transitions[state] = {
68
- // state: states[el.source.id].text,
69
- // symbol: el.labels[0].attrs.text.text.split(",") || "transition",
70
- // nextState: states[el.target.id].text,
71
- // };
72
56
}
73
57
} ) ;
74
58
@@ -90,14 +74,9 @@ function run() {
90
74
automata . finalStates = finalStates ;
91
75
automata . transitions = transitions ;
92
76
93
- console . log ( automata ) ;
94
-
95
77
renderOut ( "Loading ..." ) ;
96
78
renderOutString ( string ) ;
97
- // verifyAFD(paper, graph, automata, string);
98
-
99
- const res = verifyAFND ( paper , graph , automata , string ) ;
100
- console . log ( res ) ;
79
+ verifyAFD ( paper , graph , automata , string ) ;
101
80
}
102
81
103
82
function changeLabelName ( ) {
0 commit comments