These have package visibility to test the law that for all Expr, the node they evaluate to is unique
These have package visibility to test the law that for all Expr, the node they evaluate to is unique
The set of roots that were added by addRoot.
The set of roots that were added by addRoot. These are Ids that will always evaluate such that roots.forall(evaluateOption(_).isDefined)
Convert a N[T] to a Literal[T, N].
Add a GC root, or tail in the DAG, that can never be deleted.
Find all the nodes currently in the graph
Apply the given rule to the given dag until the graph no longer changes.
Apply a rule at most cnt times.
apply the rule at the first place that satisfies it, and return from there.
Apply a sequence of rules, which you may think of as phases, in order First apply one rule until it does not apply, then the next, etc.
Apply a sequence of rules, which you may think of as phases, in order First apply one rule until it does not apply, then the next, etc..
Is this node in this DAG
What nodes do we depend directly on
list all the nodes that depend on the given node
ensure the given literal node is present in the Dag Note: it is important that at each moment, each node has at most one id in the graph.
ensure the given literal node is present in the Dag Note: it is important that at each moment, each node has at most one id in the graph. Put another way, for all Id[T] in the graph evaluate(id) is distinct.
After applying rules to your Dag, use this method to get the original node type.
After applying rules to your Dag, use this method to get the original node type. Only call this on an Id[T] that was generated by this dag or a parent.
Returns 0 if the node is absent, which is true use .
Returns 0 if the node is absent, which is true use .contains(n) to check for containment
Return the number of nodes that depend on the given Id, TODO we might want to cache these.
Return the number of nodes that depend on the given Id, TODO we might want to cache these. We need to garbage collect nodes that are no longer reachable from the root
This finds an Id[T] in the current graph that is equivalent to the given N[T]
Nodes can have multiple ids in the graph, this gives all of them
equivalent to (but maybe faster than) fanOut(n) <= 1
This throws if the node is missing, use find if this is not a logic error in your programming.
This throws if the node is missing, use find if this is not a logic error in your programming. With dependent types we could possibly get this to not compile if it could throw.
Is this node a root of this graph
Which ids are reachable from the roots?
String representation of this DAG.
String representation of this DAG.
Return the transitive dependencies of a given node
Return all dependents of a given node.
Return all dependents of a given node. Does not include itself
Represents a directed acyclic graph (DAG).
The type N[_] represents the type of nodes in the graph.