[−][src]Struct egg::Dot
A wrapper for an EGraph
that can output GraphViz for
visualization.
The EGraph::dot
method creates Dot
s.
Example
use egg::{*, rewrite as rw}; let rules = &[ rw!("mul-commutes"; "(* ?x ?y)" => "(* ?y ?x)"), rw!("mul-two"; "(* ?x 2)" => "(<< ?x 1)"), ]; let mut egraph: EGraph<StringLang, ()> = Default::default(); egraph.add_expr(&"(/ (* 2 a) 2)".parse().unwrap()); let egraph = Runner::default().with_egraph(egraph).run(rules).egraph; // 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("target/foo.svg").unwrap(); // egraph.dot().to_png("target/foo.png").unwrap(); // egraph.dot().to_pdf("target/foo.pdf").unwrap(); // egraph.dot().to_dot("target/foo.dot").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.
Implementations
impl<'a, L, N> Dot<'a, L, N> where
L: Language,
N: Analysis<L>,
[src]
L: Language,
N: Analysis<L>,
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]
S: AsRef<OsStr>,
I: IntoIterator<Item = S>,
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]
S1: AsRef<OsStr>,
S2: AsRef<OsStr>,
I: IntoIterator<Item = S2>,
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, N: Analysis<L>> Debug for Dot<'a, L, N>
[src]
impl<'a, L, N> Display for Dot<'a, L, N> where
L: Language,
N: Analysis<L>,
[src]
L: Language,
N: Analysis<L>,
Auto Trait Implementations
impl<'a, L, N> !RefUnwindSafe for Dot<'a, L, N>
impl<'a, L, N> !Send for Dot<'a, L, N>
impl<'a, L, N> !Sync for Dot<'a, L, N>
impl<'a, L, N> Unpin for Dot<'a, L, N>
impl<'a, L, N> !UnwindSafe for Dot<'a, L, N>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,