#graph #directed-graph #terminal #display #debugging #find

termgraph

A Crate to displays Graphs in the Terminal

4 releases (breaking)

0.4.0 Feb 12, 2023
0.3.0 Oct 4, 2022
0.2.0 Jun 7, 2022
0.1.0 May 17, 2022

#157 in Visualization

MIT/Apache

1MB
2K SLoC

Termgraph

Docs Crates.io

A utility to display Directed-Graphs in the Terminal, purely written in rust without external dependencies

Motivation

This crate was born to allow for easy visualization of Graphs in the Terminal, either for debugging purposes or for displaying it to the end user. This was started as I could not find anothe crate that really suited my use-case and this might also be useful for others when working with graphs in Rust, which can already be hard enough.

Usage

To see how you can use this, see the Documentation or the examples in the /examples/ folder.

Example

Example Graph


lib.rs:

A Crate to output graphs on the Terminal

Intended Use-Case

This is mostly intended to help in developing other Software that uses Graphs and needs a way to easily display them, either during Debugging or as Output to display to the User.

Example

use termgraph::{DirectedGraph, IDFormatter, Config};

let config = Config::new(IDFormatter::new(), 3);
let mut graph = DirectedGraph::new();
graph.add_nodes([(0, "first"), (1, "second"), (2, "third")]);
graph.add_edges([(0, 1), (0,2), (1, 2)]);

termgraph::display(&graph, &config);

No runtime deps