Run this notebook

Use Livebook to open this notebook and explore new ideas.

It is easy to get started, on your machine or the cloud.

Click below to open and run it in your Livebook at .

(or change your Livebook location)

<!-- livebook:{"app_settings":{"access_type":"public","output_type":"rich","slug":"dot"}} --> # Convert DOT to SVG ```elixir Mix.install([ {:libgraph, "~> 0.16.0"}, {:kino, "~> 0.12.3"}, {:ex_dot, "~> 0.1.0"}, {:req, "~> 0.4.11"} ]) ``` ## Render a DOT graph This demo uses the https://crates.io/crates/layout-rs crate (src: https://github.com/nadavrot/layout), wraps it using Rustler, and allows to convert text in [DOT Language](https://graphviz.org/doc/info/lang.html) to SVG. ```elixir render = fn file -> %Req.Response{status: 200, body: dot_file} = Req.get!("https://raw.githubusercontent.com/nadavrot/layout/master/inputs/#{file}") dot_file |> Dot.to_svg() |> Kino.Image.new(:svg) end file_selector = Kino.Input.select( "Please select the file", [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "bk", "diamond", "ella", "expr", "heb", "noa", "prof", "sched0", "sched1", "self", "small" ] |> Enum.map(fn u -> {"#{u}.dot", u} end) ) ``` <!-- livebook:{"reevaluate_automatically":true} --> ```elixir render.(Kino.Input.read(file_selector)) ```
See source

Have you already installed Livebook?

If you already installed Livebook, you can configure the default Livebook location where you want to open notebooks.
Livebook up Checking status We can't reach this Livebook (but we saved your preference anyway)
Run notebook

Not yet? Install Livebook in just a minute

Livebook is open source, free, and ready to run anywhere.

Run on your machine

with Livebook Desktop

Run in the cloud

on select platforms

To run on Linux, Docker, embedded devices, or Elixir’s Mix, check our README.

PLATINUM SPONSORS
SPONSORS
Code navigation with go to definition of modules and functions Read More ×