Converts ASCII text to a graph (represented as a dictionary).
Project description
ascii2graph
Converts ASCII text to a graph (represented as a dictionary).
Installation
$ pip install ascii2graph
Example
from ascii2graph import graph
text = r'''
a--boo
| | x
| | /
c---d-e
| |
f-g'''
result = graph(text)
print(result)
This produces the following graph (dictionary):
result = {(1, 4, 'a'): [(4, 4, 'c'), (1, 7, 'boo')],
(4, 4, 'c'): [(1, 4, 'a'), (4, 8, 'd')],
(4, 8, 'd'): [(4, 4, 'c'), (4, 10, 'e'), (1, 7, 'boo'), (6, 8, 'f')],
(4, 10, 'e'): [(2, 12, 'x'), (4, 8, 'd'), (6, 10, 'g')],
(2, 12, 'x'): [(4, 10, 'e')],
(6, 8, 'f'): [(6, 10, 'g'), (4, 8, 'd')],
(6, 10, 'g'): [(6, 8, 'f'), (4, 10, 'e')],
(1, 7, 'boo'): [(4, 8, 'd'), (1, 4, 'a')]}
Nodes can be anything that is not one of these characters:
- | / \
Suggestions? Corrections? Pull requests?
Yes please!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ascii2graph-0.1.0.tar.gz
(3.8 kB
view details)
File details
Details for the file ascii2graph-0.1.0.tar.gz
.
File metadata
- Download URL: ascii2graph-0.1.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3960caf39aae5aead6400143ebc3446910d549107425454987ac447813544e1 |
|
MD5 | b174717fcd7d7389746de7a3155ebd05 |
|
BLAKE2b-256 | e68cf4dbbb5a0526b4b80e8a2e092345c3200c750361de74eb04687ed471d4e8 |