Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/philopon/go-toposort
deterministic topological sort implementation for golang
https://github.com/philopon/go-toposort
Last synced: 5 days ago
JSON representation
deterministic topological sort implementation for golang
- Host: GitHub
- URL: https://github.com/philopon/go-toposort
- Owner: philopon
- License: mit
- Created: 2017-01-04T04:04:17.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-20T08:54:49.000Z (over 7 years ago)
- Last Synced: 2024-08-02T18:40:58.816Z (3 months ago)
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 32
- Watchers: 2
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
go-toposort
==
[![Build Status](https://travis-ci.org/philopon/go-toposort.svg?branch=master)](https://travis-ci.org/philopon/go-toposort)
[![GoDoc](https://godoc.org/github.com/philopon/go-toposort?status.svg)](https://godoc.org/github.com/philopon/go-toposort)deterministic topological sort implementation for golang
Example
--```.go
package mainimport (
"fmt"toposort "github.com/philopon/go-toposort"
)func main() {
graph := toposort.NewGraph(8)
graph.AddNodes("2", "3", "5", "7", "8", "9", "10", "11")graph.AddEdge("7", "8")
graph.AddEdge("7", "11")graph.AddEdge("5", "11")
graph.AddEdge("3", "8")
graph.AddEdge("3", "10")graph.AddEdge("11", "2")
graph.AddEdge("11", "9")
graph.AddEdge("11", "10")graph.AddEdge("8", "9")
result, ok := graph.Toposort()
if !ok {
panic("cycle detected")
}fmt.Println(result)
}
``````
[3 5 7 8 11 2 9 10]
```License
--
MIT