checkpoint
This commit is contained in:
10
README.md
10
README.md
@@ -7,12 +7,6 @@ Daggy is a work orchestration framework for running workflows modeled as
|
||||
directed, acyclic graphs (DAGs). These are quite useful when modeling
|
||||
data ingestion / processing pipelines.
|
||||
|
||||
|
||||
Requirements
|
||||
==
|
||||
|
||||
- rapidjson
|
||||
|
||||
Building
|
||||
==
|
||||
|
||||
@@ -24,3 +18,7 @@ cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
Architecture
|
||||
==
|
||||
|
||||
|
||||
@@ -8,67 +8,49 @@
|
||||
#include <iterator>
|
||||
#include <functional>
|
||||
|
||||
/*
|
||||
The DAG structure in daggy is just to ensure that tasks are run
|
||||
in the correct dependent order.
|
||||
*/
|
||||
|
||||
namespace daggy {
|
||||
template<typename T>
|
||||
class DAG {
|
||||
public:
|
||||
DAG() {}
|
||||
|
||||
void addVertex(T id);
|
||||
void dropVertex(const T & id);
|
||||
template<typename T>
|
||||
class DAG {
|
||||
public:
|
||||
DAG() {}
|
||||
|
||||
void addEdge(const T & src, const T & dst);
|
||||
void dropEdge(const T & src, const T & dst);
|
||||
// Vertices
|
||||
void addVertex(T id);
|
||||
void dropVertex(const T & id);
|
||||
void setVertexVisited(const T & id, bool visited);
|
||||
void setDAGVisited(bool visited);
|
||||
|
||||
// Returns the path from {from} to {to}
|
||||
std::deque<T> shortestPath(const T & from, const T & to);
|
||||
// Edges
|
||||
void addEdge(const T & src, const T & dst);
|
||||
void dropEdge(const T & src, const T & dst);
|
||||
|
||||
// Traversal
|
||||
// Returns the path from {from} to {to}
|
||||
std::deque<T> shortestPath(const T & from, const T & to);
|
||||
|
||||
// Traverse all nodes, calling f(id). If f() returns
|
||||
// false, stop traversing this branch.
|
||||
// Guarantees to only visit each vertex once.
|
||||
void traverse(std::function<bool> f);
|
||||
// Traversal
|
||||
void initTraversal(std::vector<const T&> ids = {});
|
||||
const T & visitNextVertex();
|
||||
|
||||
// Same as traverse, but starts the traversal at
|
||||
// the given id.
|
||||
void traverseFrom(T& id, std::function<bool> f);
|
||||
private:
|
||||
struct Vertex {
|
||||
// It's a bit redundant to preserve both, but
|
||||
// it makes it possible with and against the
|
||||
// directions possible
|
||||
std::unordered_set<T> parents;
|
||||
std::unordered_set<T> children;
|
||||
bool visited;
|
||||
};
|
||||
|
||||
|
||||
// Peek at the next node
|
||||
T & next() const;
|
||||
|
||||
// Get the next node and mark it visited
|
||||
T & visit_next();
|
||||
|
||||
// Clear the visited flag, optionally for downstream
|
||||
// vertices
|
||||
void unvisit(T &id, bool cascade = true);
|
||||
|
||||
// Breadth First Iterator
|
||||
struct Iterator {
|
||||
using iterator_category = std::random_access_iterator_tag;
|
||||
using difference_type = int;
|
||||
using value_type = T;
|
||||
using point = T*;
|
||||
using reference = T&;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
|
||||
struct Vertex {
|
||||
// It's a bit redundant to preserve both, but
|
||||
// it makes it possible with and against the
|
||||
// directions possible
|
||||
std::unordered_set<T> parents;
|
||||
std::unordered_set<T> children;
|
||||
bool visited;
|
||||
};
|
||||
|
||||
std::unordered_map<T, Vertex> vertices;
|
||||
std::unordered_set<T> roots;
|
||||
};
|
||||
std::unordered_map<T, Vertex> vertices;
|
||||
std::unordered_set<T> roots;
|
||||
std::unordered_set<T> active_nodes;
|
||||
};
|
||||
|
||||
#include "DAG.impl"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user