[][src]Struct egg::Dot

pub struct Dot<'a, L, M> { /* fields omitted */ }

A wrapper for an EGraph that can output GraphViz for visualization.

Example

use egg::{EGraph, enode as e};

let mut egraph = EGraph::<String, ()>::default();
let x = egraph.add(e!("x"));
let y = egraph.add(e!("0"));
let add = egraph.add(e!("+", x, y));
egraph.union(add, x);
egraph.rebuild();

// create a Dot and dump it to a file
let tmp = |f| { let mut p = std::env::temp_dir(); p.push(f); p };
egraph.dot().to_png(tmp("foo.dot")).unwrap();

// Dot implements std::fmt::Display
println!("My egraph dot file: {}", egraph.dot());

// create a Dot and then compile it assuming `dot` is on the system
// egraph.dot().to_svg(tmp("foo.svg")).unwrap();
// egraph.dot().to_png(tmp("foo.png")).unwrap();
// egraph.dot().to_pdf(tmp("foo.pdf")).unwrap();

Note that self-edges (from an enode to its containing eclass) will be rendered improperly due to a deficiency in GraphViz. So the example above will render with an from the "+" enode to itself instead of to its own eclass.

Methods

impl<'a, L, M> Dot<'a, L, M>[src]

pub fn new(egraph: &EGraph<L, M>) -> Dot<L, M>[src]

Given a reference to an EGraph, makes a Dot. See also the more convenient EGraph::dot.

impl<'a, L: Language + Display, M> Dot<'a, L, M>[src]

pub fn to_dot(&self, filename: impl AsRef<Path>) -> Result<()>[src]

Writes the Dot to a .dot file with the given filename. Does not require a dot binary.

pub fn to_png(&self, filename: impl AsRef<Path>) -> Result<()>[src]

Renders the Dot to a .png file with the given filename. Requires a dot binary to be on your $PATH.

pub fn to_svg(&self, filename: impl AsRef<Path>) -> Result<()>[src]

Renders the Dot to a .svg file with the given filename. Requires a dot binary to be on your $PATH.

pub fn to_pdf(&self, filename: impl AsRef<Path>) -> Result<()>[src]

Renders the Dot to a .pdf file with the given filename. Requires a dot binary to be on your $PATH.

pub fn run_dot<S, I>(&self, args: I) -> Result<()> where
    S: AsRef<OsStr>,
    I: IntoIterator<Item = S>, 
[src]

Invokes dot with the given arguments, piping this formatted Dot into stdin.

pub fn run<S1, S2, I>(&self, program: S1, args: I) -> Result<()> where
    S1: AsRef<OsStr>,
    S2: AsRef<OsStr>,
    I: IntoIterator<Item = S2>, 
[src]

Invokes some program with the given arguments, piping this formatted Dot into stdin.

Can be used to run a different binary than dot:

egraph.dot().run(
    "/path/to/my/dot",
    &["arg1", "-o", "outfile"]
).unwrap();

Trait Implementations

impl<'a, L: Language, M: Debug> Debug for Dot<'a, L, M>[src]

impl<'a, L: Language + Display, M> Display for Dot<'a, L, M>[src]

Auto Trait Implementations

impl<'a, L, M> !RefUnwindSafe for Dot<'a, L, M>

impl<'a, L, M> !Send for Dot<'a, L, M>

impl<'a, L, M> !Sync for Dot<'a, L, M>

impl<'a, L, M> Unpin for Dot<'a, L, M>

impl<'a, L, M> !UnwindSafe for Dot<'a, L, M>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.