Up and running in ten lines
#include <task_graph/task_graph.hpp>
using namespace task_graph;
int main() {
DAG dag;
auto fetch = std::make_shared<Task>("fetch", [](TaskContext& ctx) {
return TaskResult{.status = TaskStatus::COMPLETED, .value = std::string("user_123")};
});
auto process = std::make_shared<Task>("process", [](TaskContext& ctx) {
auto data = ctx.input<std::string>("in");
return TaskResult{.status = TaskStatus::COMPLETED,
.value = std::string(*data + "_processed")};
});
dag.add_task(fetch);
dag.add_task(process);
dag.connect("fetch", "process"); // out -> in
DAGExecutor executor;
executor.execute(dag).wait();
}
Graphs as data
The same graph can be expressed as JSON, loaded by DAGSerializer::from_string and executed by DAGExecutor — exactly the format GraphStudio saves and loads:
{
"version": "2.0",
"tasks": [
{ "id": "src", "type": "opencv_image_read", "params": { "file_path": "test.png" } },
{ "id": "gaussian", "type": "opencv_gaussian_blur_filter" },
{ "id": "sobel", "type": "opencv_sobel_filter" }
],
"edges": [
{ "from": "src", "from_port": "out", "to": "gaussian", "to_port": "in" },
{ "from": "gaussian", "from_port": "out", "to": "sobel", "to_port": "in" }
]
}
Learn more
- 📖 Full documentation lives in the GitHub repository README (build options, plugin development, GPU backends)
- 🚀 To compose your first graph from scratch, read Quick Start with GraphStudio on the blog
- 📦 To produce installers yourself, see Building the three-platform installers from source
