Yoorkin/egg/graph does not have a README file

    ENode

    pub struct ENode[Op] {
    op : Op
    children : ReadOnlyArray[Id]
    } derive(Eq, Hash,
    Debug
    )

    An operator applied to e-classes.

    Graph

    type Graph[Op, Data]

    Graph::Graph

    #alias(new)
    fn[Op : Hash + Eq, Data] Graph::Graph(make~ : (Op, ReadOnlyArray[Data]) -> Data, join~ : (Data, Data) -> Data, modify? : (Graph[Op, Data], Data) -> Id?) -> Graph[Op, Data]

    Create a graph with functions for e-class analysis. Modify may add an equivalent term and return its class for merging during rebuild.

    Graph::add_node

    fn[Op : Hash + Eq, Data] Graph::add_node(self : Graph[Op, Data], op : Op, children? : ArrayView[Id]) -> Id

    Add an operator applied to existing classes and return its class.

    Graph::allocated_node_count

    fn[Op, Data] Graph::allocated_node_count(self : Graph[Op, Data]) -> Int

    Count node slots ever allocated, including entries removed by rebuild.

    Graph::class_count

    fn[Op, Data] Graph::class_count(self : Graph[Op, Data]) -> Int

    Graph::data

    fn[Op, Data] Graph::data(self : Graph[Op, Data], id : Id) -> Data

    Read the class's analysis fact. Call rebuild to finish propagating updates.

    Graph::extract

    fn[Op : Hash + Eq, Data : Eq, Tree] Graph::extract(self : Graph[Op, Data], root : Id, weight : (Op) -> UInt64, build : (Op, ArrayView[Tree]) -> Tree) -> (UInt64, Tree)?

    Rebuild the graph and extract a cheapest finite tree.

    Graph::extract_with_cost

    fn[Op : Hash + Eq, Data : Eq, Tree] Graph::extract_with_cost(self : Graph[Op, Data], root : Id, local_cost : (Op, ArrayView[UInt64]) -> UInt64?, build : (Op, ArrayView[Tree]) -> Tree) -> (UInt64, Tree)?

    Rebuild the graph and extract a cheapest finite tree under a local cost.

    Graph::find

    fn[Op, Data] Graph::find(self : Graph[Op, Data], id : Id) -> Id

    Find the canonical identifier using path halving.

    Graph::merge

    fn[Op, Data : Eq] Graph::merge(self : Graph[Op, Data], left : Id, right : Id) -> Bool

    Assert that two classes are equivalent. Return whether the classes merged. Rebuild after a batch of merges to propagate congruence and analysis facts.

    Graph::node_count

    fn[Op, Data] Graph::node_count(self : Graph[Op, Data]) -> Int

    Return the number of e-nodes. Rebuild removes any pending duplicates.

    Graph::nodes

    fn[Op, Data] Graph::nodes(self : Graph[Op, Data], id : Id) -> ReadOnlyArray[ENode[Op]]

    View the nodes of a class. Call rebuild to canonicalize every child.

    Graph::rebuild

    fn[Op : Hash + Eq, Data : Eq] Graph::rebuild(self : Graph[Op, Data]) -> Unit

    Restore congruence and propagate analysis facts to a fixed point.

    An e-class identifier issued by one graph. Use it only with that graph.

    Pattern

    pub(all) enum Pattern[Op] {
    Variable(String)
    Node(Op, ReadOnlyArray[Pattern[Op]])
    }

    A pattern matches operators and binds variables to e-classes.

    Pattern::visit_matches

    fn[Op : Eq, Data] Pattern::visit_matches(self : Pattern[Op], graph : Graph[Op, Data], visit : (Id, Map[String, Id]) -> Unit) -> Unit

    Visit matches on a rebuilt graph.