Documentation ¶
Overview ¶
Maxflow package implements the max-flow(min-cuts, graph-cuts) algorithm that is used to solve the labeling problem in computer vision or graphics area.
The algorithm is described in
An Experimental Comparison of Min-Cut/Max-Flow Algorithms for Energy Minimization in Computer Vision. Yuri Boykov and Vladimir Kolmogorov. In IEEE Transactions on Pattern Analysis and Machine Intelligence, September 2004.
Reference the document of Graph struct for usage information.
Index ¶
Constants ¶
const INFINITE_D int = 1000000000
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph is a data structure representing a graph for maxflow algorithm.
Usage:
g := NewGraph() nodes := make([]*Node, 2) for i := range(nodes) { nodes[i] = g.AddNode() } // for i g.SetTweights(nodes[0], 1, 5) g.SetTweights(nodes[1], 2, 6) g.AddEdge(nodes[0], nodes[1], 3, 4) g.Run(); flow := g.Flow() if g.IsSource(nodes[0]) { fmt.Println("nodes 0 is SOURCE") } else { fmt.Println("nodes 0 is SINK") } // else
func (*Graph) AddNode ¶
AddNode creates a node in the graph and returns a pointer to the node.
Fields of the Node struct is not(and need not be) accessible.
func (*Graph) IsSource ¶
IsSource checks whether a node is a source in the minimum cuts.
Call this method after calling to Run
func (*Graph) Run ¶
func (g *Graph) Run()
Run executes the maxflow algorithm to find the maxflow of the current graph.
func (*Graph) SetTweights ¶
SetTweights sets the capacities of a node to the souce and sink node
Do not call this method twice for a node