gocgraphlite
September 9, 2025 ยท View on GitHub
A lightweight DAG (Directed Acyclic Graph) execution framework for Go, ported from C++ CGraph-lite library.
Features
- ๐ Lightweight DAG execution framework
- ๐ Thread-safe parameter sharing between nodes
- โก Concurrent execution with worker pool
- ๐๏ธ Easy-to-use builder pattern for pipeline construction
- ๐ง Compatible with original C++ CGraph-lite interface
Quick Start
Basic Example
package main
import "fmt"
// Define your custom node
type MyNode struct {
BaseGElement
}
func (n *MyNode) Run() *CStatus {
fmt.Printf("%s: Hello World!\n", n.GetName())
return NewCStatus()
}
func main() {
// Create pipeline
pipeline := Factory.Create()
// Register nodes
node := &MyNode{}
pipeline.RegisterGElement(node, []GElement{}, "MyNode")
// Execute
pipeline.Process(1)
// Cleanup
Factory.Remove(pipeline)
}
Parameter Sharing Example
See T02_Param.go for a complete example of sharing parameters between nodes.
Examples
T01_Simple.go- Basic node execution exampleT02_Param.go- Parameter sharing between nodes example
Installation
go get github.com/AsunaU2/GoCGraph
Building
go build .
Running Examples
# Run simple example
go run T01_Simple.go go_cgraph_lite.go
# Run parameter example
go run T02_Param.go go_cgraph_lite.go
Core Concepts
GElement (Node)
Basic execution unit in the DAG. Implement the Run() method to define your logic.
GPipeline
Manages the entire DAG execution flow, handles dependencies and concurrent execution.
GParam
Thread-safe parameter sharing mechanism between nodes.
Acknowledgments
This project is inspired by and ported from the excellent CGraph-lite C++ library by ChunelFeng. We extend our heartfelt gratitude to the original author for creating such an elegant and efficient DAG execution framework.
License
MIT License
Contributing
Pull requests are welcome! For major changes, please open an issue first.