Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/silas/dag
Golang DAG
https://github.com/silas/dag
dag golang
Last synced: 21 days ago
JSON representation
Golang DAG
- Host: GitHub
- URL: https://github.com/silas/dag
- Owner: silas
- License: mpl-2.0
- Created: 2019-02-27T05:16:02.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-10-21T14:20:38.000Z (about 1 year ago)
- Last Synced: 2024-10-10T14:23:18.585Z (about 1 month ago)
- Topics: dag, golang
- Language: Go
- Homepage: https://pkg.go.dev/github.com/silas/dag
- Size: 43.9 KB
- Stars: 9
- Watchers: 2
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dag
This is a slightly modified version of the Terraform [dag][dag] code with the Terraform dependencies removed.
## Example
``` go
package mainimport (
"fmt"
"time""github.com/silas/dag"
)func main() {
g := &dag.AcyclicGraph{}p := ""
g.Add(p)
g.Add("a")
g.Connect(dag.BasicEdge(p, "a"))g.Add("b")
g.Connect(dag.BasicEdge(p, "b"))
g.Connect(dag.BasicEdge("b", "a"))g.Add("c")
g.Connect(dag.BasicEdge(p, "c"))
g.Connect(dag.BasicEdge("c", "a"))if err := g.Validate(); err != nil {
panic(err)
}g.Walk(func(v dag.Vertex) (d dag.Diagnostics) {
key := v.(string)fmt.Println(key)
time.Sleep(2 * time.Second)return
})
}
```[dag]: https://github.com/hashicorp/terraform/tree/main/internal/dag