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.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size ascii2graph-0.1.0.tar.gz (3.8 kB) | File type Source | Python version None | Upload date | Hashes View |