Skip to main content

graph-easy

A Python port of Graph::Easy, the Perl tool that lays out directed/undirected graphs and renders them as ASCII art (box-and-wire diagrams rendered in the terminal).

This project faithfully translates the original Perl implementation to Python, in order to provide the same functionality to Python users / as a native Python library and command-line tool.

Provenance & License

  • Original: Graph::Easy, Copyright (C) 2004 - 2008 by Tels (http://bloodgate.com/).
  • Upstream repository: https://github.com/ironcamel/Graph-Easy
  • This port is licensed under the GNU General Public License, version 2 or (at your option) any later version — the same license as the original Graph::Easy, because a port is a derivative work.

See LICENSE for the full GPL text.

Third-party color schemes

This product includes color specifications and designs developed by Cynthia Brewer (http://colorbrewer.org/), used under the Apache-Style Software License for ColorBrewer Color Schemes v1.1, © 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania State University. See the header of the original Graph::Easy::Attributes for the full notice.

Status

Actively-developed port. Currently implemented:

  • DSL parser: [ label ]/bare nodes, --> <-- <--> -- arrows, labelled edges (-- label --> and -- { label: x; } -->), multiline labels (\n), node attribute blocks ({ shape: diamond; }), groups (( name [ A ] --> [ B ] )), comments
  • Layout engine: longest-path layering with barycenter reordering and orthogonal edge routing — chains, branches, merges, layer-spanning edges, back edges (cycles) and self-loops all render without clobbering boxes (long edges are routed through detour rows); independent components stack as separate diagrams
  • Edge line styles (faithful to upstream Parser::_edge_style): -- solid, .. dotted, == double, ~~ wave, ## bold, .-/..- dot-dash
  • Edge labels float in the box-free region next to the line (truncated to fit)
  • Two output charsets: Unicode box-drawing by default (┌──┐ ──▶ ══ ║ ·), plain ASCII via --ascii
  • Colours: fill/color attributes map to ANSI codes (on by default, --no-color / --color auto to control)

Limitations: labels are clipped to the free space beside an edge; very dense graphs may need manual attribute tuning. The heavier automatic layout engine (Graph::Easy::Layout grid solver) is a follow-up milestone.

Usage

$ printf '[ Bonn ] --> [ Berlin ] --> [ Hamburg ]\n' | graph-easy
┌──────┐     ┌────────┐     ┌─────────┐
│ Bonn │────▶│ Berlin │────▶│ Hamburg │
└──────┘     └────────┘     └─────────┘

Colours from fill/color attributes are on by default; use --no-color to disable, or --color auto to enable only on a TTY.

# plain-ASCII output
$ printf '[ A ] ..> [ B ]\n' | graph-easy --ascii
+---+     +---+
| A |....>| B |
+---+     +---+

Development

$ python -m venv .venv && source .venv/bin/activate
$ pip install -e '.[dev]'
$ ruff check .
$ mypy src
$ pytest

Acknowledgments

Thanks to Tels and the Graph::Easy contributors whose careful layout and rendering work this port builds upon.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graph_easy-0.0.9.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graph_easy-0.0.9-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file graph_easy-0.0.9.tar.gz.

File metadata

  • Download URL: graph_easy-0.0.9.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for graph_easy-0.0.9.tar.gz
Algorithm Hash digest
SHA256 cc3326d0b9405f746fc34ad9d7188ab6f6e11dfe5438d1064e95e7c5bb570b0a
MD5 1b07b3273a274e9f2665fd82080a08be
BLAKE2b-256 a2558c6e219f546e39dbf85eea9e24d66397ed9f6be498d67e004bbd891631d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for graph_easy-0.0.9.tar.gz:

Publisher: publish.yml on y9c/graph-easy-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file graph_easy-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: graph_easy-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 24.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for graph_easy-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 efcc287bd574bebcbd47f3e1b22467ec10564cc935091b70164ad0f0bbe1fd44
MD5 54919ecc21446e0ba448e82c6c16428b
BLAKE2b-256 5f4e28b8578072c6638d380cbdcf9a348b97e8364d3e108672518b319dbef935

See more details on using hashes here.

Provenance

The following attestation bundles were made for graph_easy-0.0.9-py3-none-any.whl:

Publisher: publish.yml on y9c/graph-easy-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page