https://github.com/wanderer/functional-trie
DEPRICATED - GO HEREThis is a Functional Directed Acyclic Graph implementation. generic-digraph is the imperative version.
USAGE
const Vertex = // to start with the graph is just a single vertexvar vertex = // now lets add an edge to the vertex named "bob" that points to another vertex with the value "alice"vertex = vertex // if paths have more than one name in them they can arraysvertex = vertex// now the graph looks like:// [vertex]---friend--->[alice]---brother-->[bob] // path names and vertex values can be anythingvertex = vertex // edges are stored in a Mapvertexedges // Map{} //you can iterate the graph to get all of its verticesvar vertices = ...vertex // you can also iterate a pathvertices = ...vertex // delete an edgevertex = vertex// now the vertex is emptyvertex
API
This has about same API as generic-digraph. With the execption that any operation that changes state returns a new copy with the changes instead of applying them directly. This affects all Set and Delete functions.
batch (operations)
The batch functions should be more effeciant then single operations for functional DAGs
params
- operations {array} - an array of operation to apply to the graph. Each entry should be in the form of [op, path, argument]. Where
op
can beset
,del
orsetValue
.
example
var graph = const pathA = 'a' 'b'const pathB = 'a^' 'b^'const commonVertex = 'common'const batch = 'set' pathA commonVertex 'set' pathB commonVertex graph = graph// the graph should now be// ,->o.// o o// `->o'