# Triple Arena Rendering A crate enabling trait-based visualization of graphs in `triple_arena::Arena
`s.
There is still work to do with better compactness of large graphs, but the SVG rendering is mostly
complete.
In the future, we could have more rendering styles and backends.
```rust
use triple_arena::{ptr_struct, Arena, Ptr};
use triple_arena_render::{render_to_svg_file, DebugNode, DebugNodeTrait};
// Suppose we are storing an equation evaluation tree in an arena
// with this type of node
enum MyNode ),
}
use MyNode::*;
impl for MyNode {
fn debug_node(_p_this: P, this: &Self) -> DebugNode {
// Here we manually write out the fields of the `DebugNode`,
// but you can also use its `Default` implementation or
// new` constructor
match this {
Literal(x) => DebugNode {
sources: vec![],
// We choose in this example to display the
// literal value by itself
center: vec![format!("{}", x)],
// We choose source-to-sink convention for our
// tree, so `sink` will always be empty
sinks: vec![],
},
Negation(p) => DebugNode {
// Have a debug edge corresponding to the real
// edge, but leave the source description empty
sources: vec![(*p, String::new())],
// Display a negative sign
center: vec!["-".to_owned()],
sinks: vec![],
},
Summation(v) => DebugNode {
// List all the inputs and number them
sources: v
.iter()
.enumerate()
.map(|(i, p)| (*p, format!("in{}", i)))
.collect(),
center: vec!["+".to_owned()],
sinks: vec![],
},
}
}
}
ptr_struct!(P0);
fn main() {
let mut a: Arena