@@ -7,7 +7,6 @@ import { startDragTools } from "./dragTools.js";
77import { initGraph } from "./graph.js" ;
88import { CircleShape , FILL_NODE_FINAL } from "./shapes.js" ;
99import download from "./utils/download.js" ;
10- import { verifyAFND } from "./afnd.js" ;
1110
1211const { graph, paper } = initGraph ( ) ;
1312const inputString = document . querySelector ( "#input-string" ) ;
@@ -27,7 +26,7 @@ function run() {
2726 const alphabet = [ ] ;
2827 const string = inputString . value ;
2928 const statesArr = [ ] ;
30- const transitions = { } ;
29+ const transitions = [ ] ;
3130
3231 // clear errors
3332 renderError ( null ) ;
@@ -39,8 +38,6 @@ function run() {
3938 id : el . attributes . id ,
4039 } ;
4140
42- transitions [ el . attributes . attrs . label . text ] = { } ;
43-
4441 if ( el . attributes . attrs . body . fill === FILL_NODE_FINAL ) {
4542 finalStates . push ( el . attributes . attrs . label . text ) ;
4643 }
@@ -51,24 +48,11 @@ function run() {
5148 if ( el . type === "Link" ) {
5249 alphabet . push ( ...el . labels [ 0 ] . attrs . text . text . split ( "," ) ) ;
5350
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 ,
6555 } ) ;
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- // };
7256 }
7357 } ) ;
7458
@@ -90,14 +74,9 @@ function run() {
9074 automata . finalStates = finalStates ;
9175 automata . transitions = transitions ;
9276
93- console . log ( automata ) ;
94-
9577 renderOut ( "Loading ..." ) ;
9678 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 ) ;
10180}
10281
10382function changeLabelName ( ) {
0 commit comments