Skip to content
Prev Previous commit
Next Next commit
doc-link fixes
  • Loading branch information
dewert99 committed Feb 8, 2024
commit 8370122f9efcf1e8f0ba7a3ce0d159c343a3654b
10 changes: 5 additions & 5 deletions src/dot.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
EGraph visualization with [GraphViz]
Use the [`Dot`] struct to visualize an [`EGraph`]
Use the [`Dot`] struct to visualize an [`EGraph`](crate::EGraph)
[GraphViz]: https://graphviz.gitlab.io/
!*/
@@ -11,13 +11,13 @@ use std::fmt::{self, Debug, Display, Formatter};
use std::io::{Error, ErrorKind, Result, Write};
use std::path::Path;

use crate::{raw, Language};
use crate::{raw::EGraphResidual, Language};

/**
A wrapper for an [`EGraph`] that can output [GraphViz] for
A wrapper for an [`EGraphResidual`] that can output [GraphViz] for
visualization.
The [`EGraph::dot`](EGraph::dot()) method creates `Dot`s.
The [`EGraphResidual::dot`] method creates `Dot`s.
# Example
@@ -51,7 +51,7 @@ instead of to its own eclass.
[GraphViz]: https://graphviz.gitlab.io/
**/
pub struct Dot<'a, L: Language> {
pub(crate) egraph: &'a raw::EGraphResidual<L>,
pub(crate) egraph: &'a EGraphResidual<L>,
/// A list of strings to be output top part of the dot file.
pub config: Vec<String>,
/// Whether or not to anchor the edges in the output.
22 changes: 11 additions & 11 deletions src/egraph.rs
Original file line number Diff line number Diff line change
@@ -316,10 +316,10 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {
}
}

/// Like [`id_to_expr`](EGraph::id_to_expr), but creates a pattern instead of a term.
/// Like [`id_to_expr`](EGraphResidual::id_to_expr), but creates a pattern instead of a term.
/// When an eclass listed in the given substitutions is found, it creates a variable.
/// It also adds this variable and the corresponding Id value to the resulting [`Subst`]
/// Otherwise it behaves like [`id_to_expr`](EGraph::id_to_expr).
/// Otherwise it behaves like [`id_to_expr`](EGraphResidual::id_to_expr).
pub fn id_to_pattern(&self, id: Id, substitutions: &HashMap<Id, Id>) -> (Pattern<L>, Subst) {
let mut res = Default::default();
let mut subst = Default::default();
@@ -405,10 +405,10 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {
self.explain_id_equivalence(left, right)
}

/// Equivalent to calling [`explain_equivalence`](EGraph::explain_equivalence)`(`[`id_to_expr`](EGraph::id_to_expr)`(left),`
/// [`id_to_expr`](EGraph::id_to_expr)`(right))` but more efficient
/// Equivalent to calling [`explain_equivalence`](EGraph::explain_equivalence)`(`[`id_to_expr`](EGraphResidual::id_to_expr)`(left),`
/// [`id_to_expr`](EGraphResidual::id_to_expr)`(right))` but more efficient
///
/// This function picks representatives using [`id_to_expr`](EGraph::id_to_expr) so choosing
/// This function picks representatives using [`id_to_expr`](EGraphResidual::id_to_expr) so choosing
/// `Id`s returned by functions like [`add_uncanonical`](EGraph::add_uncanonical) is important
/// to control explanations
pub fn explain_id_equivalence(&mut self, left: Id, right: Id) -> Explanation<L> {
@@ -441,7 +441,7 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {
self.explain_existance_id(id)
}

/// Equivalent to calling [`explain_existance`](EGraph::explain_existance)`(`[`id_to_expr`](EGraph::id_to_expr)`(id))`
/// Equivalent to calling [`explain_existance`](EGraph::explain_existance)`(`[`id_to_expr`](EGraphResidual::id_to_expr)`(id))`
/// but more efficient
fn explain_existance_id(&mut self, id: Id) -> Explanation<L> {
if let Some(explain) = &mut self.explain {
@@ -529,7 +529,7 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {

/// Similar to [`add_expr`](EGraph::add_expr) but the `Id` returned may not be canonical
///
/// Calling [`id_to_expr`](EGraph::id_to_expr) on this `Id` return a copy of `expr` when explanations are enabled
/// Calling [`id_to_expr`](EGraphResidual::id_to_expr) on this `Id` return a copy of `expr` when explanations are enabled
pub fn add_expr_uncanonical(&mut self, expr: &RecExpr<L>) -> Id {
let nodes = expr.as_ref();
let mut new_ids = Vec::with_capacity(nodes.len());
@@ -567,7 +567,7 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {
/// canonical
///
/// Like [`add_uncanonical`](EGraph::add_uncanonical), when explanations are enabled calling
/// Calling [`id_to_expr`](EGraph::id_to_expr) on this `Id` return an correspond to the
/// Calling [`id_to_expr`](EGraphResidual::id_to_expr) on this `Id` return an correspond to the
/// instantiation of the pattern
fn add_instantiation_noncanonical(&mut self, pat: &PatternAst<L>, subst: &Subst) -> Id {
let nodes = pat.as_ref();
@@ -623,7 +623,7 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {

/// Similar to [`add`](EGraph::add) but the `Id` returned may not be canonical
///
/// When explanations are enabled calling [`id_to_expr`](EGraph::id_to_expr) on this `Id` will
/// When explanations are enabled calling [`id_to_expr`](EGraphResidual::id_to_expr) on this `Id` will
/// correspond to the parameter `enode`
///
/// ## Example
@@ -642,7 +642,7 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {
/// assert_eq!(egraph.id_to_expr(fb), "(f b)".parse().unwrap());
/// ```
///
/// When explanations are not enabled calling [`id_to_expr`](EGraph::id_to_expr) on this `Id` will
/// When explanations are not enabled calling [`id_to_expr`](EGraphResidual::id_to_expr) on this `Id` will
/// produce an expression with equivalent but not necessarily identical children
///
/// # Example
@@ -762,7 +762,7 @@ impl<L: Language, N: Analysis<L>> EGraph<L, N> {

/// Unions two e-classes, using a given reason to justify it.
///
/// This function picks representatives using [`id_to_expr`](EGraph::id_to_expr) so choosing
/// This function picks representatives using [`id_to_expr`](EGraphResidual::id_to_expr) so choosing
/// `Id`s returned by functions like [`add_uncanonical`](EGraph::add_uncanonical) is important
/// to control explanations
pub fn union_trusted(&mut self, from: Id, to: Id, reason: impl Into<Symbol>) -> bool {
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ pub(crate) use {explain::Explain, unionfind::UnionFind};

pub use {
dot::Dot,
eclass::EClass,
eclass::{EClass, EClassData},
egraph::EGraph,
explain::{
Explanation, FlatExplanation, FlatTerm, Justification, TreeExplanation, TreeTerm,
6 changes: 3 additions & 3 deletions src/raw/egraph.rs
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ impl<L: Language> EGraphResidual<L> {
res_id
}

/// Like [`id_to_expr`](EGraph::id_to_expr) but only goes one layer deep
/// Like [`id_to_expr`](EGraphResidual::id_to_expr) but only goes one layer deep
pub fn id_to_node(&self, id: Id) -> &L {
&self.nodes[usize::from(id)]
}
@@ -237,7 +237,7 @@ impl<L: Language> EGraphResidual<L> {

/// Returns a more debug-able representation of the egraph focusing on its uncanonical ids and nodes.
///
/// [`EGraph`]s implement [`Debug`], but it ain't pretty. It
/// [`RawEGraph`]s implement [`Debug`], but it's not pretty. It
/// prints a lot of stuff you probably don't care about.
/// This method returns a wrapper that implements [`Debug`] in a
/// slightly nicer way, just dumping enodes in each eclass.
@@ -586,7 +586,7 @@ impl<L: Language, D> RawEGraph<L, D> {

/// Returns a more debug-able representation of the egraph focusing on its classes.
///
/// [`EGraph`]s implement [`Debug`], but it ain't pretty. It
/// [`RawEGraph`]s implement [`Debug`], but it's not pretty. It
/// prints a lot of stuff you probably don't care about.
/// This method returns a wrapper that implements [`Debug`] in a
/// slightly nicer way, just dumping enodes in each eclass.