#irox #graph #dot #graphviz #compatible #writer #description

irox-dot

DOT Graph Description Language writer, compatible with GraphViz

1 unstable release

0.1.0 Jun 27, 2024

#131 in Data formats


Used in irox

MIT/Apache

69KB
1K SLoC

IROX-DOT

DOT Graph Description Language writer, compatible with GraphViz

No-STD support:

  • Requires std

Features:

  • None

Example:


use irox_dot::*;

fn main() -> Result<(), irox_bits::Error> {
    let mut graph = Graph::named("TestGraph");
    graph.graph_type = GraphType::Digraph;

    // add a top-level graph attribute
    graph.add_graph_attr("landscape", "true");

    // add a basic node with no attributes
    graph.add_node(Node::new("Node 1"));

    // add an edge
    graph.add_edge(Edge::new(&graph, "Node 1", "Node 2"));

    let mut out = String::with_capacity(256);
    graph.write_to(&mut out)?;
    println!("{out}");

    Ok(())
}

produces:

digraph TestGraph {
    landscape=true
    "Node 1" 
    "Node 1" -> "Node 2"
}

lib.rs:

DOT Graph Description Language writer, compatible with GraphViz

Example:

#
    let mut graph = Graph::named("TestGraph");
    graph.graph_type = GraphType::Digraph;

    // add a top-level graph attribute
    graph.add_graph_attr("landscape", "true");

    // add a basic node with no attributes
    graph.add_node(Node::new("Node 1"));

    // add an edge
    graph.add_edge(Edge::new(&graph, "Node 1", "Node 2"));

    let mut out = String::with_capacity(256);
    graph.write_to(&mut out)?;
    println!("{out}");
    assert_eq!(out, "\
digraph TestGraph {\n\
\tlandscape=true\n\
\t\"Node 1\" \n\
\t\"Node 1\" -> \"Node 2\" \n\
}\n"
);

Dependencies