The path 1 > 7 > 8 > 9 > 11 doesn't exist in your input but does in the graph, is it on purpose, or an issue?
If it's on purpose, you can drop most of the input and only keep unique pairs, for example there's no need for 1 > 2 to appear twice and 8 > 9 thrice. In that case, by just keeping those unique pairs your graph is already defined. I don't know about ASCII graphs, but your input is really easy to turn into dot, and then into a graph (maybe there is a tool that turns dot data into ASCII graphs...)
If having 1 > 7 > 8 > 9 > 11 in your output graph is a mistake, what you have is a DFA which you want to minimize. There might be a module that does that on graphs in perl.
This is kind of OT but your input can be turned into a regular expression (using A and B for 10 and 11, to have only one char per transition):
1256789B|125678AB|1456789B|145678AB|1356789B|135678AB|178AB.
This can be optimized by a module like Regexp::Optimizer: (?:(?:1(?:[234]5678[9A]|78A)B)) (I cheated on that one, I manually turned the perl regexp into a javascript one)
And then plotted by one of the online tools that turn regexp into graphs: like this (notice the separate branch for 1 > 7 > 8 > 10 > 11 / 178AB).
This is just taking advantage of the fact regular expressions (in the first sense of the name, not the extended stuff allowed by perl) can be turned to a DFA and back. I don't know the implementation of Regexp::Optimizer but it might just do a DFA minization in some form or other.
Edit: oh and that's the result you get by adding 1789B as a possible path in the regex, which is the graph you asked for.
Edit2: How to convert dot graph to ASCII. So if you're in the first case (1 > 7 > 8 > 9 > 11 allowed), your problem becomes really easy to solve.
In reply to Re: Graph in a terminal (ASCII - art)
by Eily
in thread Graph in a terminal (ASCII - art)
by baxy77bax
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |