graphviz-rs

Crates.iographviz-rs
lib.rsgraphviz-rs
version0.2.0
sourcesrc
created_at2023-03-10 09:10:35.770606
updated_at2023-10-11 05:51:13.891409
descriptionA parser for directed graph in dot format with FFI to Graphviz cgraph library
homepage
repositoryhttps://github.com/furiosa-ai/dot-graph
max_upload_size
id806302
size74,643
Boncheol Gu (boncheolgu)

documentation

README

dot-graph

dot parser in Rust implemented with FFI to Graphviz cgraph library.

Prerequisites

dot-graph parses a dot format file using C bindings to Graphviz (v7.0.6).

The system environment should be able to find and include the following header files.

#include <gvc.h>
#include <cgraph.h>

Option 1. Installing Graphviz from Package Manager

Coming from Linux,

$ sudo apt install graphviz-dev

And coming from vanilla Ubuntu, you may want to install these too.

$ sudo apt install build-essentials cmake
$ sudo apt install clang

Coming from Mac,

$ brew install graphviz

And coming from Apple Silicon Mac, and add an environment variable,

export CPATH=/opt/homebrew/include

Option 2. Building Graphviz from Source

Or, try building from the source code yourself following the guide.

Usage

use dot_graph::prelude::*;

fn main() -> Result<(), DotGraphError> {
  /* parse from file */
  let graph = parser::parse_from_file(/* path */)?;
  let mut stdout = std::io::stdout();
  graph.to_dot(&mut stdout)?;

  /* parse from memory */
  let graph = parser::parse_from_memory(/* dot file contents in memory */)?;
  let mut stdout = std::io::stdout();
  graph.to_dot(&mut stdout)?;
  
  Ok(())
}
Commit count: 134

cargo fmt