Awesome Go

graphlib

CategoryData Structures and Algorithms
SubcategoryTrees
Stars0

Topological sort lib,Sorting and pruning of DAG graphs

About graphlib

graphlib

Go Report Card Codecov GitHub Actions Workflow Status Minimum Go Version

A Topological sort lib.

Sorting and pruning of DAG graphs.

Ideas borrowed from python graphlib

How to install

go get -u github.com/aio-arch/graphlib

How to use

    import "github.com/aio-arch/graphlib"

    // New A graph

	// for string type
	g1 := graphlib.NewGraph[string]()

	// for int type
	g2 := graphlib.NewGraph[int]()

	// for add node and add edge
	g1.AddNode("A1")
	g1.AddNode("B2")
	g1.AddEdge("A1", "B2") // edge: A1 -> B2

	// for add mulit edge,add node inline
	g2.Add(10, 1, 9)    // edge: 1 -> 10 and 9 -> 10
	g2.Add(100, 10, 90) // edge: 10 -> 100 and 90 -> 100

	// topological order
	topo, err := graphlib.TopologicalOrder(g1)
	if err != nil {
		fmt.Println(err.Error())
	}
	fmt.Printf("Topological Order:%v\n", topo)

	// topological prune
	g3, err := graphlib.TopologicalPrune(g2, []int{10, 90})
	if err != nil {
		fmt.Println(err.Error())
	}
	_ = g3

Frequently Asked Questions

What is graphlib?

graphlib is a Data Structures and Algorithms library for the Go programming language. Topological sort lib,Sorting and pruning of DAG graphs

How do I install graphlib?

Install graphlib with the Go module system using `go get aio-arch/graphlib`. Check the repository for the current installation instructions.

What category does graphlib belong to?

graphlib is listed under Data Structures and Algorithms, specifically Trees.

← Back to Trees