munkres

package module
v0.0.0-...-48b791b Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

munkres

an implementation of the Hungarian algorithm

This code is heavily based on Bob Pilgrim's work outlined here.

Example

m := NewMatrix(4)
m.A = []int64{94, 93, 20, 37,
        75, 18, 71, 43,
        20, 29, 32, 25,
        37, 72, 17, 73}
fmt.Println(ComputeMunkresMin(m)) // [{0 3} {1 1} {2 0} {3 2}]

The assignment set which minimizes the total utility is:

(0, 3) = 37
(1, 1) = 18
(2, 0) = 20
(3, 2) = 17
       = 92

License

see LICENSE file

Author(s)

Brian Fallik - bfallik at clypd.com

Dependencies

This packages uses stretchr/testify for help with unit test assertions.

Development

Pull requests welcome!

Other

Thanks to clypd for agreeing to release this code into the wild.

clypd

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Debugger func(Step, *Context) = func(Step, *Context) {}
)

Functions

This section is empty.

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

func (*Context) String

func (ctx *Context) String() string

type Mark

type Mark int
const (
	Unset Mark = iota
	Starred
	Primed
)

type Matrix

type Matrix struct {
	A []int64
	// contains filtered or unexported fields
}

func NewMatrix

func NewMatrix(n int) *Matrix

func (*Matrix) Print

func (m *Matrix) Print()

type RowCol

type RowCol struct {
	Row, Col int
}

func ComputeMunkresMax

func ComputeMunkresMax(m *Matrix) []RowCol

func ComputeMunkresMin

func ComputeMunkresMin(m *Matrix) []RowCol

type Step

type Step interface {
	Compute(*Context) (Step, bool)
}

type Step1

type Step1 struct{}

func (Step1) Compute

func (Step1) Compute(ctx *Context) (Step, bool)

type Step2

type Step2 struct{}

func (Step2) Compute

func (Step2) Compute(ctx *Context) (Step, bool)

type Step3

type Step3 struct{}

func (Step3) Compute

func (Step3) Compute(ctx *Context) (Step, bool)

type Step4

type Step4 struct{}

func (Step4) Compute

func (Step4) Compute(ctx *Context) (Step, bool)

type Step5

type Step5 struct{}

func (Step5) Compute

func (Step5) Compute(ctx *Context) (Step, bool)

type Step6

type Step6 struct{}

func (Step6) Compute

func (Step6) Compute(ctx *Context) (Step, bool)

Jump to

Keyboard shortcuts

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