{"id":20214959,"url":"https://github.com/nikolai2038/draw-io-automata-parser","last_synced_at":"2026-05-11T17:40:00.130Z","repository":{"id":241026795,"uuid":"695431971","full_name":"Nikolai2038/draw-io-automata-parser","owner":"Nikolai2038","description":"Scripts for working with automata represented by diagrams in files *.drawio.","archived":false,"fork":false,"pushed_at":"2024-09-29T20:50:26.000Z","size":244,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-13T21:44:41.209Z","etag":null,"topics":["automata","bash","draw-io","drawio","parser","xml-parser"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nikolai2038.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-23T06:51:39.000Z","updated_at":"2024-09-29T20:50:07.000Z","dependencies_parsed_at":"2024-05-22T02:29:47.874Z","dependency_job_id":"c324baa8-a1dd-4d2f-808d-9dbfe6dd3a59","html_url":"https://github.com/Nikolai2038/draw-io-automata-parser","commit_stats":null,"previous_names":["nikolai2038/draw-io-automata-parser"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikolai2038%2Fdraw-io-automata-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikolai2038%2Fdraw-io-automata-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikolai2038%2Fdraw-io-automata-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikolai2038%2Fdraw-io-automata-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nikolai2038","download_url":"https://codeload.github.com/Nikolai2038/draw-io-automata-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241652965,"owners_count":19997578,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automata","bash","draw-io","drawio","parser","xml-parser"],"created_at":"2024-11-14T06:18:59.455Z","updated_at":"2026-05-11T17:40:00.088Z","avatar_url":"https://github.com/Nikolai2038.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Draw IO Automata Parser\r\n\r\n**EN** | [RU](README_RU.md)\r\n\r\n## Description\r\n\r\nThis Bash-script allows you to find minimal automata for the represented one in diagram file `*.drawio`.\r\n\r\n## Requirements\r\n\r\n- Linux or WSL;\r\n- Bash;\r\n- `libxml-xpath-perl` apt-package installed (it will be installed automatically, if not already installed).\r\n\r\n## Usage\r\n\r\n1. Clone the repository inside Linux machine or WSL.\r\n\r\n2. Create and save Draw IO diagram (look to example below).\r\n   Rules:\r\n\r\n   - Use ellipses for automata nodes;\r\n   - You must create one and only one arrow without source;\r\n   - All other arrows must have source and target (connect them to ellipses);\r\n   - Add text to all arrows (except start arrow) with format `\u003cvariable name\u003e/\u003cvariable value\u003e`;\r\n\r\n3. Run script:\r\n\r\n    ```bash\r\n    ./01_find_minimal.sh \u003cfile path\u003e\r\n    ```\r\n   \r\n   or:\r\n\r\n    ```bash\r\n    ./02_find_deterministic.sh \u003cfile path\u003e\r\n    ```\r\n\r\nIf you're having trouble with diagram created by yourself, try copying example diagram and modifying it instead.\r\n\r\n## Example for script 1 - Find minimal automata\r\n\r\n1. Create diagram:\r\n\r\n   ![Input diagram](images_for_readme/script_01_example_01_input.svg)\r\n\r\n2. Save diagram as `XML file (.drawio)` (very important to save in XML because file will be parsed that way).\r\n   You can find this example in `./diagrams/examples` folder - file is called `script_01_example_01_input.drawio`.\r\n\r\n3. Move file into `./diagrams` folder.\r\n\r\n4. Run script:\r\n\r\n   ```bash\r\n   ./01_find_minimal.sh ./diagrams/examples/script_01_example_01_input.drawio\r\n   ```\r\n\r\n5. Wait for calculations and done! The result will be printed in the console:\r\n\r\n   ```log\r\n   Welcome to Automata Parser!\r\n   Loading file ./diagrams/01_example_input.drawio...\r\n   Found 21 elements!\r\n   Found 6 ellipses!\r\n   Found 13 arrows!\r\n   Found 0 label arrows!\r\n   Start arrow found!\r\n   No disconnected arrows found!\r\n   Found 12 connected arrows!\r\n   Loading file ./diagrams/01_example_input.drawio: done!\r\n   Parsing...\r\n   Calculate data for ellipse with value 1!\r\n   - Calculate data for arrow with value b/1!\r\n   - Calculate data for arrow with value a/0!\r\n   Calculate data for ellipse with value 2!\r\n   - Calculate data for arrow with value a/1!\r\n   - Calculate data for arrow with value b/1!\r\n   Calculate data for ellipse with value 3!\r\n   - Calculate data for arrow with value a/0!\r\n   - Calculate data for arrow with value b/1!\r\n   Calculate data for ellipse with value 4!\r\n   - Calculate data for arrow with value b/0!\r\n   - Calculate data for arrow with value a/1!\r\n   Calculate data for ellipse with value 5!\r\n   - Calculate data for arrow with value a/0!\r\n   - Calculate data for arrow with value b/1!\r\n   Calculate data for ellipse with value 6!\r\n   - Calculate data for arrow with value b/1!\r\n   - Calculate data for arrow with value a/1!\r\n   Calculate K0...\r\n   - K0 = { A0={1}, B0={2}, C0={3}, D0={4}, E0={5}, F0={6} }\r\n   Calculate K1...\r\n   - K1 = { A1={1,3,5}, B1={2,6}, C1={4} }\r\n   Calculate K2...\r\n   - K2 = { A2={1,5}, B2={2,6}, C2={3}, D2={4} }\r\n   Calculate K3...\r\n   - K3 = { A3={1,5}, B3={2,6}, C3={3}, D3={4} }\r\n   ================================================================================\r\n   Result:\r\n   ================================================================================\r\n   S = { 1, 2, 3, 4, 5, 6 }\r\n   u0 = 1\r\n\r\n   ----------------------------------------------------------------\r\n   |      | λ    | λ    | δ    | δ    | K1   | K1   | K2   | K2   |\r\n   |      | a    | b    | a    | b    | a    | b    | a    | b    |\r\n   ----------------------------------------------------------------\r\n   | 1    | 0    | 1    | 2    | 5    | B1   | A1   | B2   | A2   |\r\n   | 2    | 1    | 1    | 3    | 1    | A1   | A1   | C2   | A2   |\r\n   | 3    | 0    | 1    | 4    | 5    | C1   | A1   | D2   | A2   |\r\n   | 4    | 1    | 0    | 6    | 4    | B1   | C1   | B2   | D2   |\r\n   | 5    | 0    | 1    | 2    | 5    | B1   | A1   | B2   | A2   |\r\n   | 6    | 1    | 1    | 3    | 1    | A1   | A1   | C2   | A2   |\r\n   ----------------------------------------------------------------\r\n\r\n   K0 = { A0={1}, B0={2}, C0={3}, D0={4}, E0={5}, F0={6} }\r\n   K1 = { A1={1,3,5}, B1={2,6}, C1={4} }\r\n   K2 = { A2={1,5}, B2={2,6}, C2={3}, D2={4} }\r\n   K3 = { A3={1,5}, B3={2,6}, C3={3}, D3={4} }\r\n   K3 == K2 == K\r\n\r\n   Smin = { A, B, C, D }\r\n   u0min = A\r\n\r\n   ------------------------------------\r\n   |      | λmin | λmin | δmin | δmin |\r\n   |      | a    | b    | a    | b    |\r\n   ------------------------------------\r\n   | A    | 0    | 1    | B    | A    |\r\n   | B    | 1    | 1    | C    | A    |\r\n   | C    | 0    | 1    | D    | A    |\r\n   | D    | 1    | 0    | B    | D    |\r\n   ------------------------------------\r\n   ================================================================================\r\n   Parsing: done!\r\n   ```\r\n\r\n6. **[By hand]** Based on output, we can now draw minimal automata:\r\n\r\n   ![Result diagram](images_for_readme/script_01_example_01_result.svg)\r\n\r\n## Example for script 2 - Find DFA from NFA\r\n\r\nDFA - Deterministic Finite Automaton.\r\n\r\nNFA - Nondeterministic Finite Automaton.\r\n\r\n1. Create diagram:\r\n\r\n   ![Input diagram](images_for_readme/script_02_example_01_input.png)\r\n\r\n2. Save diagram as `XML file (.drawio)` (very important to save in XML because file will be parsed that way).\r\n   You can find this example in `./diagrams/examples` folder - file is called `script_02_example_01_input.drawio`.\r\n\r\n3. Move file into `./diagrams` folder.\r\n\r\n4. Run script:\r\n\r\n   ```bash\r\n   ./02_find_deterministic.sh ./diagrams/examples/script_02_example_01_input.drawio\r\n   ```\r\n\r\n5. Wait for calculations and done! The result will be printed in the console:\r\n\r\n   ```log\r\n   Welcome to Automata Parser!\r\n   Loading file diagrams/examples/11_example_input.drawio...\r\n   Found 31 elements!\r\n   Found 6 ellipses!\r\n   Found 12 arrows!\r\n   Found 11 label arrows!\r\n   Start arrow found!\r\n   No disconnected arrows found!\r\n   Found 11 connected arrows!\r\n   Loading file diagrams/examples/11_example_input.drawio: done!\r\n   Parsing...\r\n   Found last ellipse with value 6!\r\n   -----------------------------------\r\n   |         | a       | b       | l |\r\n   -----------------------------------\r\n   | {1}     | {2 5 6} | {2 5 6} | 0 |\r\n   | {2 5 6} | {3 6}   | {∅}     | 1 |\r\n   | {3 6}   | {3}     | {4}     | 1 |\r\n   | {3}     | {3}     | {4}     | 0 |\r\n   | {4}     | {5 6}   | {5 6}   | 0 |\r\n   | {5 6}   | {6}     | {∅}     | 1 |\r\n   | {6}     | {∅}     | {∅}     | 1 |\r\n   -----------------------------------\r\n\r\n   -----------------\r\n   |   | a | b | l |\r\n   -----------------\r\n   | 1 | 2 | 2 | 0 |\r\n   | 2 | 3 | - | 1 |\r\n   | 3 | 4 | 5 | 1 |\r\n   | 4 | 4 | 5 | 0 |\r\n   | 5 | 6 | 6 | 0 |\r\n   | 6 | 7 | - | 1 |\r\n   | 7 | - | - | 1 |\r\n   -----------------\r\n   Parsing: done!\r\n   ```\r\n\r\n6. **[By hand]** Based on output, we can now draw deterministic automata:\r\n\r\n   ![Result diagram](images_for_readme/script_02_example_01_result.png)\r\n\r\n## Contribution\r\n\r\nFeel free to contribute via [pull requests](https://github.com/Nikolai2038/draw-io-automata-parser/pulls) or [issues](https://github.com/Nikolai2038/draw-io-automata-parser/issues)!\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolai2038%2Fdraw-io-automata-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikolai2038%2Fdraw-io-automata-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolai2038%2Fdraw-io-automata-parser/lists"}