[][src]Struct egg::egraph::EGraph

pub struct EGraph<L: Language, M> { /* fields omitted */ }

Data structure to keep track of equalities between expressions

Methods

impl<L: Language, M> EGraph<L, M>[src]

pub fn classes(&self) -> impl Iterator<Item = &EClass<L, M>>[src]

pub fn is_empty(&self) -> bool[src]

pub fn total_size(&self) -> usize[src]

Returns the number of nodes in the EGraph.

Actually returns the size of the hash cons index.

let mut egraph = EGraph::<TestLang, ()>::default();
let x = egraph.add(var("x"));
let y = egraph.add(var("y"));
// only one eclass
egraph.union(x.id, y.id);

assert_eq!(egraph.total_size(), 2);

pub fn number_of_classes(&self) -> usize[src]

pub fn get_eclass(&self, eclass_id: Id) -> &EClass<L, M>[src]

pub fn just_find(&self, id: Id) -> Id[src]

impl<L: Language, M: Metadata<L>> EGraph<L, M>[src]

pub fn from_expr(expr: &RecExpr<L>) -> (Self, Id)[src]

pub fn add_expr(&mut self, expr: &RecExpr<L>) -> Id[src]

pub fn add(&mut self, enode: Expr<L, Id>) -> AddResult[src]

pub fn equivs(&self, expr1: &RecExpr<L>, expr2: &RecExpr<L>) -> Vec<Id>[src]

pub fn prune(&mut self) -> usize[src]

Trims down eclasses that have variables or constants in them.

If an eclass has a variable or consant in it, this will remove everything else from that eclass except those variables/constants.

let expr = TestLang.parse_expr("(+ x y)").unwrap();
let (mut egraph, root) = EGraph::<TestLang, ()>::from_expr(&expr);
let z = egraph.add(var("z"));
let eclass = egraph.union(root, z.id);
// eclass has z and + in it
assert_eq!(egraph.get_eclass(eclass).len(), 2);
// pruning will remove the +, returning how many nodes were removed
assert_eq!(egraph.prune(), 1);
// eclass is now smaller
assert_eq!(egraph.get_eclass(eclass).len(), 1);
// for now, its not actually removed from the egraph
assert_eq!(egraph.total_size(), 4);

pub fn fold_constants(&mut self) -> usize[src]

pub fn rebuild(&mut self)[src]

pub fn union(&mut self, id1: Id, id2: Id) -> Id[src]

pub fn dump_dot(&self, filename: &str) where
    L::Constant: Display,
    L::Variable: Display,
    L::Operator: Display
[src]

Trait Implementations

impl<L: Language, M> Default for EGraph<L, M>[src]

impl<L: Debug + Language, M: Debug> Debug for EGraph<L, M>[src]

Auto Trait Implementations

impl<L, M> Send for EGraph<L, M> where
    M: Send,
    <L as Language>::Constant: Send,
    <L as Language>::Operator: Send,
    <L as Language>::Variable: Send

impl<L, M> Sync for EGraph<L, M> where
    M: Sync,
    <L as Language>::Constant: Sync,
    <L as Language>::Operator: Sync,
    <L as Language>::Variable: Sync

Blanket Implementations

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[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.

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

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

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