# compgraph2txt
[![Testing](https://github.com/adamviola/compgraph2txt/actions/workflows/tests.yml/badge.svg)](https://github.com/adamviola/compgraph2txt/actions/workflows/testing.yml)
![Codecov](https://img.shields.io/codecov/c/github/adamviola/compgraph2txt)
A tiny library for visualizing computational graphs in the terminal.
```
│ │ │ ╭─────────╮
│ │ │ │ A │
│ │ │ ├─────────┤
│ ╰───┼→ a e ─┼─╮
│ │ │─ b f ─┼──→
├─────┼→ c g ─┼───╮
│ │ │─ d h ─│ │ │
│ │ │ i ─┼────→
│ │ ╰─────────╯ │ │
│ ╭───────────────╯ │
│ │ │ ╭─────────────╯
│ │ │ │ ╭─────────╮
│ │ │ │ │ Z │
│ │ │ │ ├─────────┤
│ ╰─────┼→ t x ─┼→
│ │ ╰─┼→ u y ─│
╰───────┼→ v z ─┼→
╰───┼→ w │
╰─────────╯
```
<details>
<summary>Source</summary>
```python
from compgraph2txt import compgraph2txt
from networkx import MultiDiGraph
graph = MultiDiGraph()
graph.add_node(
"A", inputs=["a", "b", "c", "d"], outputs=["e", "f", "g", "h", "i"]
)
graph.add_node("Z", inputs=["t", "u", "v", "w"], outputs=["x", "y", "z"])
# Add edges from external sources
graph.add_edge("ext1", "A", input="c")
graph.add_edge("ext1", "Z", input="v")
graph.add_edge("ext2", "A", input="a")
graph.add_edge("ext3", "Z", input="w")
# Add edges to external sinks
graph.add_edge("A", "ext", output="f")
graph.add_edge("A", "ext", output="i")
graph.add_edge("Z", "ext", output="x")
graph.add_edge("Z", "ext", output="z")
graph.add_edge("Z", "ext", output="x")
graph.add_edge("Z", "ext", output="z")
# Add edges between nodes
graph.add_edge("A", "Z", output="e", input="t")
graph.add_edge("A", "Z", output="g", input="u")
print(compgraph2txt(graph))
```
</details>
## Example: Image Background Blur Pipeline
### Source
```python
from compgraph2txt import compgraph2txt
from networkx import MultiDiGraph
graph = MultiDiGraph()
graph.add_node("Camera", inputs=[], outputs=["Image"])
graph.add_node("Foreground Detection", inputs=["Image"], outputs=["Foreground", "Background"])
graph.add_node("Blur", inputs=["Image"], outputs=["Blurred Image"])
graph.add_node("Image Overlay", inputs=["Foreground", "Background"], outputs=["Image"])
graph.add_node("Application", inputs=["Image"], outputs=[])
graph.add_edge("Camera", "Foreground Detection", output="Image", input="Image")
graph.add_edge("Foreground Detection", "Blur", output="Background", input="Image")
graph.add_edge("Blur", "Image Overlay", output="Blurred Image", input="Background")
graph.add_edge("Foreground Detection", "Image Overlay", output="Foreground", input="Foreground")
graph.add_edge("Image Overlay", "Application", output="Image", input="Image")
print(compgraph2txt(graph))
```
### Output
```
╭──────────╮
│ Camera │
├──────────┤
│ Image ─┼─╮
╰──────────╯ │
╭────────────╯
│ ╭────────────────────────╮
│ │ Foreground Detection │
│ ├────────────────────────┤
╰─┼→ Image Foreground ─┼─╮
│ Background ─┼───╮
╰────────────────────────╯ │ │
╭────────────────────────────╯ │
│ ╭────────────────────────────╯
│ │ ╭────────────────────────╮
│ │ │ Blur │
│ │ ├────────────────────────┤
│ ╰─┼→ Image Blurred Image ─┼─╮
│ ╰────────────────────────╯ │
│ ╭────────────────────────────╯
│ │ ╭─────────────────────╮
│ │ │ Image Overlay │
│ │ ├─────────────────────┤
╰───┼→ Foreground Image ─┼─╮
╰─┼→ Background │ │
╰─────────────────────╯ │
╭───────────────────────────╯
│ ╭───────────────╮
│ │ Application │
│ ├───────────────┤
╰─┼→ Image │
╰───────────────╯
```
Raw data
{
"_id": null,
"home_page": null,
"name": "compgraph2txt",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "computational graph, graph, visualization",
"author": null,
"author_email": "Adam Viola <adam@viola.dev>",
"download_url": "https://files.pythonhosted.org/packages/46/4a/c04644fe0fff140dc34fdee460d2218df6602f89c62fd786cb9628fb13d2/compgraph2txt-1.0.0.tar.gz",
"platform": null,
"description": "# compgraph2txt \n\n[![Testing](https://github.com/adamviola/compgraph2txt/actions/workflows/tests.yml/badge.svg)](https://github.com/adamviola/compgraph2txt/actions/workflows/testing.yml)\n![Codecov](https://img.shields.io/codecov/c/github/adamviola/compgraph2txt)\n\n\nA tiny library for visualizing computational graphs in the terminal.\n\n```\n\u2502 \u2502 \u2502 \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 \u2502 \u2502 \u2502 A \u2502\n\u2502 \u2502 \u2502 \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 \u2570\u2500\u2500\u2500\u253c\u2192 a e \u2500\u253c\u2500\u256e\n\u2502 \u2502 \u2502\u2500 b f \u2500\u253c\u2500\u2500\u2192\n\u251c\u2500\u2500\u2500\u2500\u2500\u253c\u2192 c g \u2500\u253c\u2500\u2500\u2500\u256e\n\u2502 \u2502 \u2502\u2500 d h \u2500\u2502 \u2502 \u2502\n\u2502 \u2502 \u2502 i \u2500\u253c\u2500\u2500\u2500\u2500\u2192\n\u2502 \u2502 \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f \u2502 \u2502 \n\u2502 \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f \u2502\n\u2502 \u2502 \u2502 \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\u2502 \u2502 \u2502 \u2502 \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 \u2502 \u2502 \u2502 \u2502 Z \u2502\n\u2502 \u2502 \u2502 \u2502 \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 \u2570\u2500\u2500\u2500\u2500\u2500\u253c\u2192 t x \u2500\u253c\u2192\n\u2502 \u2502 \u2570\u2500\u253c\u2192 u y \u2500\u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2192 v z \u2500\u253c\u2192\n \u2570\u2500\u2500\u2500\u253c\u2192 w \u2502\n \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n\n<details>\n<summary>Source</summary>\n\n```python\nfrom compgraph2txt import compgraph2txt\nfrom networkx import MultiDiGraph\n\ngraph = MultiDiGraph()\ngraph.add_node(\n \"A\", inputs=[\"a\", \"b\", \"c\", \"d\"], outputs=[\"e\", \"f\", \"g\", \"h\", \"i\"]\n)\ngraph.add_node(\"Z\", inputs=[\"t\", \"u\", \"v\", \"w\"], outputs=[\"x\", \"y\", \"z\"])\n\n# Add edges from external sources\ngraph.add_edge(\"ext1\", \"A\", input=\"c\")\ngraph.add_edge(\"ext1\", \"Z\", input=\"v\")\ngraph.add_edge(\"ext2\", \"A\", input=\"a\")\ngraph.add_edge(\"ext3\", \"Z\", input=\"w\")\n\n# Add edges to external sinks\ngraph.add_edge(\"A\", \"ext\", output=\"f\")\ngraph.add_edge(\"A\", \"ext\", output=\"i\")\ngraph.add_edge(\"Z\", \"ext\", output=\"x\")\ngraph.add_edge(\"Z\", \"ext\", output=\"z\")\ngraph.add_edge(\"Z\", \"ext\", output=\"x\")\ngraph.add_edge(\"Z\", \"ext\", output=\"z\")\n\n# Add edges between nodes\ngraph.add_edge(\"A\", \"Z\", output=\"e\", input=\"t\")\ngraph.add_edge(\"A\", \"Z\", output=\"g\", input=\"u\")\n\nprint(compgraph2txt(graph))\n```\n\n</details>\n\n## Example: Image Background Blur Pipeline\n\n### Source\n```python\nfrom compgraph2txt import compgraph2txt\nfrom networkx import MultiDiGraph\n\ngraph = MultiDiGraph()\ngraph.add_node(\"Camera\", inputs=[], outputs=[\"Image\"])\ngraph.add_node(\"Foreground Detection\", inputs=[\"Image\"], outputs=[\"Foreground\", \"Background\"])\ngraph.add_node(\"Blur\", inputs=[\"Image\"], outputs=[\"Blurred Image\"])\ngraph.add_node(\"Image Overlay\", inputs=[\"Foreground\", \"Background\"], outputs=[\"Image\"])\ngraph.add_node(\"Application\", inputs=[\"Image\"], outputs=[])\n\ngraph.add_edge(\"Camera\", \"Foreground Detection\", output=\"Image\", input=\"Image\")\ngraph.add_edge(\"Foreground Detection\", \"Blur\", output=\"Background\", input=\"Image\")\ngraph.add_edge(\"Blur\", \"Image Overlay\", output=\"Blurred Image\", input=\"Background\")\ngraph.add_edge(\"Foreground Detection\", \"Image Overlay\", output=\"Foreground\", input=\"Foreground\")\ngraph.add_edge(\"Image Overlay\", \"Application\", output=\"Image\", input=\"Image\")\n\nprint(compgraph2txt(graph))\n```\n\n### Output\n```\n\u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 Camera \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 Image \u2500\u253c\u2500\u256e\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f \u2502 \n\u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\u2502 \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 \u2502 Foreground Detection \u2502\n\u2502 \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2570\u2500\u253c\u2192 Image Foreground \u2500\u253c\u2500\u256e\n \u2502 Background \u2500\u253c\u2500\u2500\u2500\u256e\n \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f \u2502 \u2502 \n\u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f \u2502\n\u2502 \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\u2502 \u2502 \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 \u2502 \u2502 Blur \u2502\n\u2502 \u2502 \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 \u2570\u2500\u253c\u2192 Image Blurred Image \u2500\u253c\u2500\u256e\n\u2502 \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f \u2502 \n\u2502 \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\u2502 \u2502 \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 \u2502 \u2502 Image Overlay \u2502\n\u2502 \u2502 \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2570\u2500\u2500\u2500\u253c\u2192 Foreground Image \u2500\u253c\u2500\u256e\n \u2570\u2500\u253c\u2192 Background \u2502 \u2502\n \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f \u2502 \n\u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\u2502 \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 \u2502 Application \u2502\n\u2502 \u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2570\u2500\u253c\u2192 Image \u2502\n \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Visualize computational graphs in the terminal.",
"version": "1.0.0",
"project_urls": null,
"split_keywords": [
"computational graph",
" graph",
" visualization"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "03c22f93d53312e8b1428ea0a6f72de3b215b0218c79e4a1fcfb7dd3e4ac7a0d",
"md5": "5a972ad118e5ab7d7604c069482a9378",
"sha256": "ff62a16c930df4a612813a45a8c4ccc4432159059b2b5132b07b7652e42fac3d"
},
"downloads": -1,
"filename": "compgraph2txt-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5a972ad118e5ab7d7604c069482a9378",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 8438,
"upload_time": "2024-08-21T03:11:47",
"upload_time_iso_8601": "2024-08-21T03:11:47.980398Z",
"url": "https://files.pythonhosted.org/packages/03/c2/2f93d53312e8b1428ea0a6f72de3b215b0218c79e4a1fcfb7dd3e4ac7a0d/compgraph2txt-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "464ac04644fe0fff140dc34fdee460d2218df6602f89c62fd786cb9628fb13d2",
"md5": "a40c7b0c0529db9a579eef4b408b921f",
"sha256": "6ddc615f68f7dbe1c23ffa9fd57e98b264118409f732a32da715f69fa9884514"
},
"downloads": -1,
"filename": "compgraph2txt-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "a40c7b0c0529db9a579eef4b408b921f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 10256,
"upload_time": "2024-08-21T03:11:46",
"upload_time_iso_8601": "2024-08-21T03:11:46.492669Z",
"url": "https://files.pythonhosted.org/packages/46/4a/c04644fe0fff140dc34fdee460d2218df6602f89c62fd786cb9628fb13d2/compgraph2txt-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-21 03:11:46",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "compgraph2txt"
}