Coder Social home page Coder Social logo

layout's Introduction

Layout

Layout is a rust library and a stand alone utility that draws graphs. Layout can parse Graphviz dot files and render them.

Library Usage

Add the following to Cargo.toml:

layout-rs = "0.1.1" # or
layout-rs = { version = "0.1.1", features = ["log"] }

Load, parse and print the AST:

use layout::gv;

let contents = "digraph { a -> b [label=\"foo\"]; }";
let mut parser = gv::DotParser::new(&contents);

match parser.process() {
    Ok(g) => gv::dump_ast(&g),
    Err(err) => {
        parser.print_error();
        # #[cfg(feature = "log")]
        log::error!("Error: {}", err);
    }
}

The example above would print the program AST, or a readable error message, such as:

digraph {

node [fillcolor="purple"] A B;
node [fillcolor="orange"] Z;
node [fillcolor="green"] G; a = ;
                                ^
Error: Expected an identifier.

Command Line Usage

Build the crate and render some dot files with the command

cargo run --bin run ./inputs/bk.dot -o output.svg

Gallery

This section presents a few graphs that were rendered from dot files:

A simple graph.

A simple graph with multiple shapes and labels.

A graph with a few style properties.

A large graph that demonstrates the edge crossing elimination optimization.

Unicode, emoji and right-to-left languages:

Support for Records (nested structures):

Debug-mode rendering that helps to visualize the layout decisions:

layout's People

Contributors

azriel91 avatar nadavrot avatar nilslice avatar mizardx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.