horse/doc/graphviz.md

4.4 KiB

GRAPHVIZ

sketchviz is a handy tool:

https://sketchviz.com/new

Here is the dot notation for the locations in horses on the brink:

graph {
  rankdir = LR

  s [ label = "Stables" ]
  t [ label = "Racetrack" ]
  p [ label = "Pasture" ]
  v [ label = "Vet" ]
  w [ label = "The Old Watering Hole" ]

  w -- p -- s -- t
  s -- v
}

in vim you can visually select the lines and

:w !neato -Tsvg > graph.svg`

to create the image.

(neato is a good "spring loaded" layout engine for non directional graphs)

or if you want to replace the lines with svg, visually select the lines and

:!neato -Tsvg

I'll do this, copy the resulting svg to a buffer, and then u to undo so I can paste the svg somewhere in the document while retaining the original dot info.

Stables Racetrack Vet Pasture The Old Watering Hole

if you install graph-easy from CPAN then you can use a limited subset of dot to make unicode box art!

[ The Old Watering Hole ] -- [ Pasture ] -- [ Stables ] -- [ Racetrack ], [ Vet ]

visually select and:

:!graph-easy --as=boxart
┌───────────────────────┐     ┌─────────┐     ┌─────────┐     ┌───────────┐
│ The Old Watering Hole │ ─── │ Pasture │ ─── │ Stables │ ─── │ Racetrack │
└───────────────────────┘     └─────────┘     └─────────┘     └───────────┘
                                                │
                                                │
                                                │
                                              ┌─────────┐
                                              │   Vet   │
                                              └─────────┘