Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/looplab/tarjan
Graph loop detection in Go using Tarjan's algorithm
https://github.com/looplab/tarjan
go graph tarjan tarjan-algorithm
Last synced: about 13 hours ago
JSON representation
Graph loop detection in Go using Tarjan's algorithm
- Host: GitHub
- URL: https://github.com/looplab/tarjan
- Owner: looplab
- License: apache-2.0
- Created: 2013-09-13T12:19:53.000Z (about 11 years ago)
- Default Branch: main
- Last Pushed: 2021-12-07T09:51:36.000Z (almost 3 years ago)
- Last Synced: 2024-08-03T23:30:43.038Z (3 months ago)
- Topics: go, graph, tarjan, tarjan-algorithm
- Language: Go
- Size: 18.6 KB
- Stars: 59
- Watchers: 3
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-golang-repositories - tarjan
README
[![PkgGoDev](https://pkg.go.dev/badge/github.com/looplab/tarjan)](https://pkg.go.dev/github.com/looplab/tarjan)
![Bulid Status](https://github.com/looplab/tarjan/actions/workflows/main.yml/badge.svg)
[![Coverage Status](https://img.shields.io/coveralls/looplab/tarjan.svg)](https://coveralls.io/r/looplab/tarjan)
[![Go Report Card](https://goreportcard.com/badge/looplab/tarjan)](https://goreportcard.com/report/looplab/tarjan)# Tarjan
Tarjan is a graph loop detection function using Tarjan's algorithm.
The algorithm takes a input graph and produces a slice where each item is a slice of strongly connected vertices. The input graph is in form of a map where the key is a graph vertex and the value is the edges in for of a slice of vertices.
Algorithm description:
http://en.wikipedia.org/wiki/Tarjan’s_strongly_connected_components_algorithmBased on an implementation by Gustavo Niemeyer (in mgo/txn):
http://bazaar.launchpad.net/+branch/mgo/v2/view/head:/txn/tarjan.goGustavo Niemeyer: http://labix.org
For API docs and examples see http://godoc.org/github.com/looplab/tarjan
# Example
```go
graph := make(map[interface{}][]interface{})
graph["1"] = []interface{}{"2"}
graph["2"] = []interface{}{"3"}
graph["3"] = []interface{}{"1"}
graph["4"] = []interface{}{"2", "3", "5"}
graph["5"] = []interface{}{"4", "6"}
graph["6"] = []interface{}{"3", "7"}
graph["7"] = []interface{}{"6"}
graph["8"] = []interface{}{"5", "7", "8"}output := Connections(graph)
fmt.Println(output)// Output:
// [[3 2 1] [7 6] [5 4] [8]]
```# License
Tarjan is licensed under Apache License 2.0
http://www.apache.org/licenses/LICENSE-2.0