package dagon
Collection of graph algorithms
- Alphabetic
- By Inheritance
- dagon
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
- type BoolT[T] = Boolean
-
sealed
class
Cache
[K, V] extends AnyRef
This is a useful cache for memoizing function.
This is a useful cache for memoizing function.
The cache is implemented using a mutable pointer to an immutable map value. In the worst-case, race conditions might cause us to lose cache values (i.e. compute some keys twice), but we will never produce incorrect values.
-
sealed abstract
class
Dag
[N[_]] extends AnyRef
Represents a directed acyclic graph (DAG).
Represents a directed acyclic graph (DAG).
The type N[_] represents the type of nodes in the graph.
-
sealed
trait
Expr
[N[_], T] extends AnyRef
Expr[N, T] is an expression of a graph of container nodes N[_] with result type N[T].
Expr[N, T] is an expression of a graph of container nodes N[_] with result type N[T]. These expressions are like the Literal[T, N] graphs except that functions always operate with an indirection of a Id[T] where N[T] is the type of the input node.
Nodes can be deleted from the graph by replacing an Expr at Id = idA with Var(idB) pointing to some upstream node.
To add nodes to the graph, add depth to the final node returned in a Unary or Binary expression.
TODO: see the approach here: https://gist.github.com/pchiusano/1369239 Which seems to show a way to do currying, so we can handle general arity
-
trait
FunctionK
[T[_], R[_]] extends AnyRef
This is a Natural transformation.
This is a Natural transformation.
For any type X, this type can produce a function from T[X] to R[X].
-
sealed
class
HCache
[K[_], V[_]] extends AnyRef
This is a useful cache for memoizing natural transformations.
This is a useful cache for memoizing natural transformations.
The cache is implemented using a mutable pointer to an immutable map value. In the worst-case, race conditions might cause us to lose cache values (i.e. compute some keys twice), but we will never produce incorrect values.
-
final
class
HMap
[K[_], V[_]] extends AnyRef
This is a weak heterogenous map.
This is a weak heterogenous map. It uses equals on the keys, so it is your responsibilty that if k: K[_] == k2: K[_] then the types are actually equal (either be careful or store a type identifier).
-
final
case class
Id
[T](id: Int) extends Product with Serializable
The Expressions are assigned Ids.
The Expressions are assigned Ids. Each Id is associated with an expression of inner type T.
This is done to put an indirection in the Dag that allows us to rewrite nodes by simply replacing the expressions associated with given Ids.
T is a phantom type used by the type system
-
sealed
trait
Literal
[N[_], T] extends AnyRef
This represents literal expressions (no variable redirection) of container nodes of type N[T]
- type NeighborFn[T] = (T) ⇒ Iterable[T]
-
trait
PartialRule
[N[_]] extends Rule[N]
Often a partial function is an easier way to express rules
-
case class
RefPair
[A <: AnyRef, B <: AnyRef](_1: A, _2: B) extends Product with Serializable
A tuple2 that uses reference equality on items to do equality useful for caching the results of pair-wise functions on DAGs.
A tuple2 that uses reference equality on items to do equality useful for caching the results of pair-wise functions on DAGs.
Without this, you can easily get exponential complexity on recursion on DAGs.
-
trait
Rule
[N[_]] extends AnyRef
This implements a simplification rule on Dags