Kevin Burke
Kevin Burke

Reputation: 64854

Tool to create ASCII graph from a set of vertices and edges?

Is there a tool that takes as input a series of vertices and edges, and outputs a graph in ASCII/Unicode format?

Thanks, Kevin

Upvotes: 13

Views: 4771

Answers (6)

Bian
Bian

Reputation: 43

Another option: https://www.npmjs.com/package/ascii-seq

input.txt

From -- message -> To .. response -> From
-- line --
Another -- msg -> Dest
Self -- abc -> Self

npx ascii-seq input.txt or cat input.txt | npx ascii-seq

┌──────┐        ┌────┐┌─────────┐┌──────┐┌──────┐  
│ From │        │ To ││ Another ││ Dest ││ Self │  
└───┬──┘        └──┬─┘└────┬────┘└───┬──┘└───┬──┘  
    │              │       │         │       │     
    ├── message ──>│       │         │       │     
    │              │       │         │       │     
    │<∙ response ∙∙┤       │         │       │     
    │              │       │         │       │     
    │              │       │         │       │     
────────────────────── line ───────────────────────
    │              │       │         │       │     
    │              │       │         │       │     
    │              │       ├─ msg ──>│       │     
    │              │       │         │       │     
    │              │       │         │       ├──┐  
    │              │       │         │       │  abc
    │              │       │         │       │<─┘  
    │              │       │         │       │     
    │              │       │         │       │     
    │              │       │         │       │     

Upvotes: 0

LuoLeKe
LuoLeKe

Reputation: 155

For whoever reading this post in 2022, check out Diagon.
There are both a command line tool diagon and a website.

you can create multiple ASCII visualization from text such as :

  • DAG
  • flowchart
  • sequence diagram
  • mathematical expression (without Latex)

DAG Example :

┌─────┐┌─────────┐┌─────┐     
│socks││underwear││shirt│     
└┬────┘└┬─┬──────┘└┬─┬──┘     
 │      │┌▽─────┐  │┌▽───────┐
 │      ││pants │  ││tie     │
 │      │└┬──┬──┘  │└┬───────┘
┌▽──────▽─▽┐┌▽─────▽┐│        
│shoes     ││belt   ││        
└──────────┘└┬──────┘│        
┌────────────▽───────▽┐       
│jacket               │       
└─────────────────────┘       

Also worth looking : https://www.plantuml.com/

Upvotes: 8

coderofsalvation
coderofsalvation

Reputation: 1803

yes, Its called unix directories and the 'tree' cmd.

Output example:

db
├── colors
│   ├── green
│   └── nongreen
└── person
    └── type
        ├── alien
        │   └── colors -> db/colors
        ├── female
        │   └── colors -> db/colors
        └── male
            └── colors -> db/colors

Upvotes: -6

Matt R
Matt R

Reputation: 10503

In addition to Graph::Easy mentioned by @nibot, there are a couple of other tools around for this:

(Disclaimer: I'm the developer of the latter).

Upvotes: 7

nibot
nibot

Reputation: 14928

Yes! Perl has Graph::Easy, as described in this Hacker News comment.

Here's some output from the online demo:

........     +---------+     +-----+
: Bonn : --> | Berlin  | ..> | Ulm |
:......:     +---------+     +-----+
               H
               H train
               v
             +---------+
             | Koblenz |
             +---------+

Upvotes: 7

Kerrek SB
Kerrek SB

Reputation: 477100

I might recommend graphviz -- I don't know if it has an ascii-art output, but it does support a heap of other useful formats, and perhaps you can find a converter to ascii art from one of those formats.

Upvotes: 1

Related Questions