Live data from Hacker News

Show HN: Ascii_tree – A way to create beautiful ASCII trees

github.com

11–20 of 26 posts

Re: Show HN: Ascii_tree – A way to create beautiful ASCII trees

#11
post #4

I think that with all the unicodes lying around these days we can do a little nicer: ┌───┐ ┌─────┤ 1 ├─────┐ │ └───┘ │ ┌─┴─┐ ┌─┴─┐ ┌─┤ 2 ├─┐ ┌─┤ 3 ├─┐ │ └───┘ │ │ └───┘ │ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ │ 4 │ │ 5 │ │ 6 │ │ 7 │ └───┘ └───┘ └───┘ └───┘ (Better if the presentation doesn't lead beyond the font.)

  I think that I shall never see
  A graph more lovely than a tree.
  A tree whose crucial property
  Is loop-free connectivity.
  A tree that must be sure to span
  So packets can reach every LAN.
  First, the root must be selected.
  By ID, it is elected.
  Least-cost paths from root are traced.
  In the tree, these paths are placed.
  A mesh is made by folks like me,
  Then bridges find a spanning tree.
Radia Perlman, 'Algoryhme' https://web.archive.org/web/20110609192559/http://www.csua.b...

  I hope that we shall one day see
  A graph more lovely than a tree.
  A graph to boost efficiency
  While still configuration-free.
  A network where RBridges can
  Route packets to their target LAN.
  The paths they find, to our elation,
  Are least cost paths to destination!
  With packet hop counts we now see,
  The network need not be loop-free!
  RBridges work transparently,
  Without a common spanning tree.
Radia Perlman in apparent alias as Ray Perlner, 'Algorhyme V2' RFC6325 https://tools.ietf.org/html/rfc6325#section-1.1

Re: Show HN: Ascii_tree – A way to create beautiful ASCII trees

#12
Honestly, I was hoping for something like the `tree` command. I've implemented that algorithm before, but it was painful and not portable.

These trees are definitely cooler and more complex but maybe fewer use cases. Once you start dealing with more than a few layers, the output is going to line-wrap in a terminal. For larger trees, DOT [1] is probably more suitable.

[1]: https://en.wikipedia.org/wiki/DOT_(graph_description_languag...

Re: Show HN: Ascii_tree – A way to create beautiful ASCII trees

#13

Honestly, I was hoping for something like the `tree` command. I've implemented that algorithm before, but it was painful and not portable. These trees are definitely cooler and more complex but maybe fewer use cases. Once you start dealing with more than a few layers, the output is going to line-wrap in a terminal. For larger trees, DOT [1] is probably more suitable. [1]: https://en.wikipedia.org/wiki/DOT_(graph_desc…

DOT is fantastic, and trivial to output, highly recommend it

Re: Show HN: Ascii_tree – A way to create beautiful ASCII trees

#14
post #5
post #4

I think that with all the unicodes lying around these days we can do a little nicer: ┌───┐ ┌─────┤ 1 ├─────┐ │ └───┘ │ ┌─┴─┐ ┌─┴─┐ ┌─┤ 2 ├─┐ ┌─┤ 3 ├─┐ │ └───┘ │ │ └───┘ │ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ │ 4 │ │ 5 │ │ 6 │ │ 7 │ └───┘ └───┘ └───┘ └───┘ (Better if the presentation doesn't lead beyond the font.)

Here's a good collection https://en.wikipedia.org/wiki/Box-drawing_character

aaaah the ZX81 semigraphics <3

Re: Show HN: Ascii_tree – A way to create beautiful ASCII trees

#16

Honestly, I was hoping for something like the `tree` command. I've implemented that algorithm before, but it was painful and not portable. These trees are definitely cooler and more complex but maybe fewer use cases. Once you start dealing with more than a few layers, the output is going to line-wrap in a terminal. For larger trees, DOT [1] is probably more suitable. [1]: https://en.wikipedia.org/wiki/DOT_(graph_desc…

DOT is fantastic, and trivial to output, highly recommend it

dot/graphviz is great, but it can take a lot of tweaking and reading to get a good looking graph.

Re: Show HN: Ascii_tree – A way to create beautiful ASCII trees

#17
post #4

I think that with all the unicodes lying around these days we can do a little nicer: ┌───┐ ┌─────┤ 1 ├─────┐ │ └───┘ │ ┌─┴─┐ ┌─┴─┐ ┌─┤ 2 ├─┐ ┌─┤ 3 ├─┐ │ └───┘ │ │ └───┘ │ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ │ 4 │ │ 5 │ │ 6 │ │ 7 │ └───┘ └───┘ └───┘ └───┘ (Better if the presentation doesn't lead beyond the font.)

Add a pull request? :)

Re: Show HN: Ascii_tree – A way to create beautiful ASCII trees

#18
Cool! Maybe a useful feature request: make the output compatible with Markdeep? https://casual-effects.com/markdeep/

I tried Ascii_tree with this online Markdeep demo: https://tomberek.info/markdeep.html and I found that it can work with only minor changes, like using '+' at all the corners and junctions, and wrapping the output in a frame of asterisks '*'.

Re: Show HN: Ascii_tree – A way to create beautiful ASCII trees

#19
post #4

I think that with all the unicodes lying around these days we can do a little nicer: ┌───┐ ┌─────┤ 1 ├─────┐ │ └───┘ │ ┌─┴─┐ ┌─┴─┐ ┌─┤ 2 ├─┐ ┌─┤ 3 ├─┐ │ └───┘ │ │ └───┘ │ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ │ 4 │ │ 5 │ │ 6 │ │ 7 │ └───┘ └───┘ └───┘ └───┘ (Better if the presentation doesn't lead beyond the font.)

A variation, using stronger lines on the boxes than the lines between them, and curving the corners of the lines:

              ┏━━━┓
        ╭─────┨ 1 ┠─────╮
        │     ┗━━━┛     │
      ┏━┷━┓           ┏━┷━┓
    ╭─┨ 2 ┠─╮       ╭─┨ 3 ┠─╮
    │ ┗━━━┛ │       │ ┗━━━┛ │
  ┏━┷━┓   ┏━┷━┓   ┏━┷━┓   ┏━┷━┓
  ┃ 4 ┃   ┃ 5 ┃   ┃ 6 ┃   ┃ 7 ┃
  ┗━━━┛   ┗━━━┛   ┗━━━┛   ┗━━━┛
Subjectively superior, though the thick lines can be overbearing in some fonts.

Or with doubled lines on boxes:

              ╔═══╗
        ╭─────╢ 1 ╟─────╮
        │     ╚═══╝     │
      ╔═╧═╗           ╔═╧═╗
    ╭─╢ 2 ╟─╮       ╭─╢ 3 ╟─╮
    │ ╚═══╝ │       │ ╚═══╝ │
  ╔═╧═╗   ╔═╧═╗   ╔═╧═╗   ╔═╧═╗
  ║ 4 ║   ║ 5 ║   ║ 6 ║   ║ 7 ║
  ╚═══╝   ╚═══╝   ╚═══╝   ╚═══╝
There are indeed many possibilities!
Post reply on HN