batchtoposort

package module
v0.0.0-202004070822-89... Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: MIT Imports: 2 Imported by: 0

README

Go implementation of batch toposort

GoDoc

package main

import (
	"fmt"

	"github.com/mollerdaniel/go-batchtoposort"
)

func main() {
	x := make(map[string][]string)
	x["a"] = []string{"c", "f"}
	x["b"] = []string{"d", "e"}
	x["c"] = []string{"f"}
	x["d"] = []string{"f", "g"}
	x["e"] = []string{"h"}
	x["f"] = []string{"i"}
	x["g"] = []string{"j"}
	x["h"] = []string{"j"}
	x["i"] = []string{}
	x["j"] = []string{}

	res, err := batchtoposort.FromMap(x)
	if err != nil {
		fmt.Printf("Error: %v", err)
	}
	for _, r := range res {
		fmt.Println(r)
	}
}
Output:
[a b]
[c d e]
[f g h]
[i j]

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromMap

func FromMap(m map[string][]string) ([][]string, error)

FromMap calculates the batched toposort for given map.

Example
x := make(map[string][]string)
x["a"] = []string{"b"}
x["b"] = []string{"c"}
x["c"] = []string{}
x["d"] = []string{"b"}
x["e"] = []string{"b"}

r, _ := FromMap(x)
fmt.Println(r)
Output:

[[a d e] [b] [c]]

Types

This section is empty.

Jump to

Keyboard shortcuts

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