It can be embedded as a macro or parsed from a string or file.

let g1 = rust_dot! {
   graph {
       A -- B -- C; /* semicolon is optional */
       "B" -- D // quotes not needed here
   }
};
println!("{} {} \"{}\" {:?} {:?}", g1.strict, g1.directed, g1.name, g1.nodes, g1.edges);
// false false "" ["A", "B", "C", "D"] [(0, 1), (1, 2), (1, 3)]

let g2 = parse_string("digraph Didi { -1 -> 2 -> 3  2 -> 4.2 }");
println!("{} {} \"{}\" {:?} {:?}", g2.strict, g2.directed, g2.name, g2.nodes, g2.edges);
// false true "Didi" ["-1", "2", "3", "4.2"] [(0, 1), (1, 2), (1, 3)]

The return values can be fed to crates petgraph (or graph/graph_builder):

let mut petgraph = petgraph::graph::Graph::new();
let nodes: Vec<_> = rust_dot_graph.nodes
   .iter()
   .map(|node| petgraph
       .add_node(node))
   .collect();
for edge in rust_dot_graph.edges {
   petgraph
       .add_edge(nodes[edge.0], nodes[edge.1], ());
};

Features

  • graph
  • rust
  • graphviz
  • dot
  • dsl
  • macro

Project Activity

See All Activity >

License

Apache License V2.0, MIT License

Follow rust_dot

rust_dot Web Site

Other Useful Business Software
Create and run cloud-based virtual machines. Icon
Create and run cloud-based virtual machines.

Secure and customizable compute service that lets you create and run virtual machines.

Computing infrastructure in predefined or custom machine sizes to accelerate your cloud transformation. General purpose (E2, N1, N2, N2D) machines provide a good balance of price and performance. Compute optimized (C2) machines offer high-end vCPU performance for compute-intensive workloads. Memory optimized (M2) machines offer the highest memory and are great for in-memory databases. Accelerator optimized (A2) machines are based on the A100 GPU, for very demanding applications.
Try for free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of rust_dot!

Additional Project Details

Registered

2024-02-18