Asciigraf should report the length of each branch
Closed this issue · 3 comments
AnjoMan commented
Currently, asciigraf
returns a networkx graph datastructure where every node has a position relative to the top-left corner of the string in which the network is drawn. It would be great if the graph also came with a length on each edge which indicated the number of characters in the edge. For example:
asciigraf.graph_from_ascii("""
(13) (10)
n0-------------n1----------n2
|
| (3)
|
n4
""").nodes(data=True)
>>> [('n0', {'position': Point(3, 8)}),
('n1', {'position': Point(3, 23)}),
('n2', {'position': Point(3, 35)}),
('n4', {'position': Point(7, 24)})]
If we did this, you could do something like
asciigraf.graph_from_ascii("""
(13) (10)
n0-------------n1----------n2
|
| (3)
|
n4
""").edges(data=True)
>>> [('n0', 'n1', {'length': 13}),
('n1', 'n2', {'length': 10}),
('n1', 'n4', {'length': 3})]
greatestape commented
What about defaulting the length to the number of characters long the line is?
AnjoMan commented
@greatestape yeah that is what I was thinking would be a good behaviour
AnjoMan commented
Implemented in 0.2.0