2

Ask: Python way to visualize a DAG in terminal

I have a graph object with each node with the following structure:

class Node:
    id: int
    category: str

Multiple nodes together make a Directed Acyclic Graph (DAG) that I want to visualize in the terminal. This visualization would be very similar to how we can visualize git commit graph via git log --all --graph --decorate: Git commit visualization

martineau
  • 119,623
  • 25
  • 170
  • 301
aybidi
  • 21
  • 1
  • Try https://stackoverflow.com/a/3391213/748102 – Barak Itkin Jul 07 '22 at 15:41
  • Why just Python? See [Pretty Git branch graphs](https://stackoverflow.com/q/1057564/1256452), which has many methods. – torek Jul 08 '22 at 00:47
  • @torek I'm not necessarily visualizing git. I have my own DAG that I want users to be able to visualize in the CLI. – aybidi Jul 08 '22 at 13:39
  • @BarakItkin this is almost what I'm looking for. Thanks! My only concern is that it's an API that may not be maintained in the future. – aybidi Jul 08 '22 at 13:40
  • The "pretty Git branch graphs" shows LaTeX, graphviz, and other solutions, all of which work with arbitrary input, not just Git DAGs. – torek Jul 08 '22 at 16:15

0 Answers0