Skip to content

past-one/euler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

euler

euler tour trees in golang 👍

algorithm description

usage

trees := CreateEuler()

fmt.Println(trees.IsConnected(1, 2)) // false
fmt.Println(trees.Link(1, 2)) // true
fmt.Println(trees.Link(2, 3)) // true
fmt.Println(trees.IsConnected(1, 2)) // true
fmt.Println(trees.IsConnected(1, 3)) // true

fmt.Println(trees) // 1-2-3-2-1 - euler tour

fmt.Println(trees.Link(1, 2)) // false - already connected
fmt.Println(trees.Cut(1, 2)) // true
fmt.Println(trees.IsConnected(1, 2)) // false
fmt.Println(trees.IsConnected(1, 3)) // false
fmt.Println(trees.IsConnected(2, 3)) // true
fmt.Println(trees.Cut(1, 2)) // false - no edge
fmt.Println(trees.Cut(1, 3)) // false - no edge

fmt.Println(trees)
// 1
// 2-3-2

// order of link params affect euler tour
fmt.Println(trees.Link(2, 1)) // true

fmt.Println(trees) // 2-3-2-1-2

tests

go test

benchmarks

go test -bench=.

About

euler tour trees in golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages