Metadata-Version: 2.1
Name: py-dagviz
Version: 0.1.0
Summary: CLI visualizer of directed acyclic graphs
Author-email: Tongfei Chen <tongfei@pm.me>
License: MIT License
        
        Copyright (c) 2022 Tongfei Chen
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/ctongfei/py-dagviz
Project-URL: Bug Tracker, https://github.com/ctongfei/py-dagviz/issues
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

# py-dagviz
This package creates a text rendering of a directed acyclic graph (DAG) for visualization purposes in a terminal.
It contains a single function `visualize_dag` that takes a [`networkx.DiGraph`](https://networkx.org/documentation/stable/reference/classes/digraph.html) object from the [networkx](https://networkx.org/) package.
```
• 0
├─• 1
├─┼─• 2
│ ├─┼─• 3
└─│─┴─• 4
  └─• 5
```

### Usage
```python
import networkx as nx
from dagviz import visualize_dag

g = nx.DiGraph()
# Creates the graph to visualize
# If the graph contains cycles (i.e., not a DAG), visualization fails
g.add_nodes_from([0, 1, 2, 3, 4, 5])
g.add_edges_from([(0, 1), (0, 2), (1, 2), (1, 3), (1, 5), (2, 4), (0, 4), (2, 3)])

print(visualize_dag(g, round_angle=False))
# • 0
# ├─• 1
# ├─┼─• 2
# │ ├─┼─• 3
# └─│─┴─• 4
#   └─• 5

print(visualize_dag(g, round_angle=True))  # display may be bad under some terminal fonts
# • 0
# ├─• 1
# ├─┼─• 2
# │ ├─┼─• 3
# ╰─│─┴─• 4
#   ╰─• 5
```
