Asciidag

0.2.0 · active · verified Thu Apr 16

Asciidag is a Python library that draws Directed Acyclic Graphs (DAGs) as ASCII art, mimicking the output style of `git log --graph`. It is a direct, mechanical port of Git's log graphing code, currently at version 0.2.0. The project is explicitly stated as 'alpha quality' and subject to breaking API changes, with the last release in October 2020.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a `Graph` object, define `Node`s with parent-child relationships, and then render the DAG to the console using `graph.show_nodes(tips)`.

from asciidag.graph import Graph
from asciidag.node import Node

graph = Graph()

# Define nodes and their relationships (parents)
root = Node('root')
grandpa = Node('grandpa', parents=[root])
tips = [
    Node('child', parents=[
        Node('mom', parents=[
            Node('grandma', parents=[
                Node('greatgrandma', parents=[]),
            ]),
            grandpa,
        ]),
        Node('dad', parents=[
            Node('bill', parents=[
                Node('martin'),
                Node('james'),
                Node('paul'),
                Node('jon'),
            ])
        ]),
        Node('stepdad', parents=[grandpa]),
    ]),
    Node('foo', [Node('bar')]),
]

# Display the graph
graph.show_nodes(tips)

view raw JSON →