gorder

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 2 Imported by: 0

README

gorder

A golang implementation of topological sorting algorithms for fast ordering.

Installation:

$ go get -u github.com/amwolff/gorder

Usage:

Check cmd/example/example.go for example usage.

$ go run cmd/example/example.go
Solution (Kahn): [1 {3.141592653589793} 3 5 4]
Solution (DFS-based): [1 {3.141592653589793} 3 5 4]

Notes:

  • Maps are one of the common ways to store graphs in Go. The TopologicalSort function input supports map[interface{}][]interface{} maps.

  • Sub-package dagenerator was developed and used for generating random DAGs for performance tests (cmd/measurements should be rewritten as benchmarks).

  • Implementation of Kahn's algorithm does pre-computation in the beginning of its work in order to calculate indegree of every vertex in the graph. This may be split into two separate algorithms/functions in the future:

    • one that doesn't take any additional input but the graph (current implementation)
    • and one that takes additional input of indegrees

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TopologicalSort

func TopologicalSort(digraph map[interface{}][]interface{}, algorithm string) (solution []interface{}, err error)

Types

This section is empty.

Directories

Path Synopsis
cmd
Package dagenerator is based on C code from https://stackoverflow.com/questions/12790337/generating-a-random-dag
Package dagenerator is based on C code from https://stackoverflow.com/questions/12790337/generating-a-random-dag

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL