# How to draw directed acyclic graphs (DAGs) in ASCII code for terminal display in Julia?

**URL:** https://discourse.julialang.org/t/how-to-draw-directed-acyclic-graphs-dags-in-ascii-code-for-terminal-display-in-julia/101373
**Category:** Graphs
**Tags:** plotting, graphs, terminal
**Created:** [July 8, 2023, 11:29pm UTC](https://discourse.julialang.org/t/how-to-draw-directed-acyclic-graphs-dags-in-ascii-code-for-terminal-display-in-julia/101373 "2023-07-08T23:29:14Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![singularitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/singularitti/32/17678_2.png) [@singularitti](https://discourse.julialang.org/u/singularitti)
#### Post date: [July 8, 2023, 11:29pm UTC](https://discourse.julialang.org/t/how-to-draw-directed-acyclic-graphs-dags-in-ascii-code-for-terminal-display-in-julia/101373/1 "2023-07-08T23:29:15Z")

</div>

I’m working on a project in Julia where I need to visualize Directed Acyclic Graphs (DAG) directly in the terminal. I’m searching for a way to represent these graphs using ASCII characters.

The idea is to have nodes and edges of the graph represented in ASCII code. This would ideally work for any DAG, not just binary trees. My use case involves having nodes with potentially multiple outgoing edges, and nodes can be on various ‘levels’ of the graph.

Could anyone provide some guidance or point me towards any resources, algorithms, or existing packages that could aid in creating ASCII representations of DAGs? Any advice would be greatly appreciated!

---

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [July 9, 2023, 5:58am UTC](https://discourse.julialang.org/t/how-to-draw-directed-acyclic-graphs-dags-in-ascii-code-for-terminal-display-in-julia/101373/2 "2023-07-09T05:58:52Z")

</div>

Perhaps [UnicodePlots.jl](https://github.com/JuliaPlots/UnicodePlots.jl)? With a layout created by [GraphPlot.jl](https://github.com/JuliaGraphs/GraphPlot.jl)

---

<div class="post-metadata">

### Author: ![singularitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/singularitti/32/17678_2.png) [@singularitti](https://discourse.julialang.org/u/singularitti)
#### Post date: [July 9, 2023, 6:11am UTC](https://discourse.julialang.org/t/how-to-draw-directed-acyclic-graphs-dags-in-ascii-code-for-terminal-display-in-julia/101373/3 "2023-07-09T06:11:32Z")

</div>

Sorry, I still do not understand how this works. Which layout are we talking about?

---

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [July 9, 2023, 6:13am UTC](https://discourse.julialang.org/t/how-to-draw-directed-acyclic-graphs-dags-in-ascii-code-for-terminal-display-in-julia/101373/4 "2023-07-09T06:13:34Z")

</div>

The layout describes the coordinate of the nodes, which is one of the pain points when drawing a graph.  
GraphPlot.jl doesn’t interface with Plots.jl or UnicodePlots.jl, so you cannot use it directly for plotting in the terminal. However, you may be able to use it to define the layout, which you then feed to UnicodePlots.jl explicitly

---

<div class="post-metadata">

### Author: ![zgornel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zgornel/32/217487_2.png) [@zgornel](https://discourse.julialang.org/u/zgornel)
#### Post date: [July 10, 2023, 11:24am UTC](https://discourse.julialang.org/t/how-to-draw-directed-acyclic-graphs-dags-in-ascii-code-for-terminal-display-in-julia/101373/5 "2023-07-10T11:24:47Z")

</div>

I would also be looking forward for this. Perhaps worthwhile opening an issue in UnicodePlots…

---

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [July 10, 2023, 12:11pm UTC](https://discourse.julialang.org/t/how-to-draw-directed-acyclic-graphs-dags-in-ascii-code-for-terminal-display-in-julia/101373/6 "2023-07-10T12:11:34Z")

</div>

I think the more worthwhile approach would be a rewrite of GraphPlot.jl to use [plot recipes](https://docs.juliaplots.org/latest/recipes/), this making it compatible with the whole JuliaPlots ecosystem

---

<div class="post-metadata">

### Author: ![scheidan1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scheidan1/32/24771_2.png) [@scheidan1](https://discourse.julialang.org/u/scheidan1)
#### Post date: [July 10, 2023, 1:22pm UTC](https://discourse.julialang.org/t/how-to-draw-directed-acyclic-graphs-dags-in-ascii-code-for-terminal-display-in-julia/101373/7 "2023-07-10T13:22:46Z")

</div>

Would be great to have this compatible with `UnicodePlots`!

Another way could be to wrap [Graph::Easy](https://metacpan.org/pod/Graph::Easy) somehow (it’s a Perl package, I don’t know if this is possible as a jll binary). The results are very nice, you can try it here: [https://dot-to-ascii.ggerganov.com/](https://dot-to-ascii.ggerganov.com/)

There is also [this](https://github.com/sambrightman/asciidag) Python package that ported the DAG printing of git.

---

<div class="post-metadata">

### Author: ![singularitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/singularitti/32/17678_2.png) [@singularitti](https://discourse.julialang.org/u/singularitti)
#### Post date: [July 10, 2023, 2:52pm UTC](https://discourse.julialang.org/t/how-to-draw-directed-acyclic-graphs-dags-in-ascii-code-for-terminal-display-in-julia/101373/8 "2023-07-10T14:52:01Z")

</div>

Is this Python package only for plotting Git commit graphs?

---

<div class="post-metadata">

### Author: ![scheidan1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scheidan1/32/24771_2.png) [@scheidan1](https://discourse.julialang.org/u/scheidan1)
#### Post date: [July 11, 2023, 9:49am UTC](https://discourse.julialang.org/t/how-to-draw-directed-acyclic-graphs-dags-in-ascii-code-for-terminal-display-in-julia/101373/9 "2023-07-11T09:49:13Z")

</div>

I never tried the Python library, but it seems as if you can plot any DAG (see example in the readme). It is not very pretty though
