Alpha Expansion Library
C++ library for the Alpha-Expansion graph-cut algorithm with Python bindings
Loading...
Searching...
No Matches
Public Member Functions | List of all members
BKSolver< T > Class Template Reference

MaxFlowSolver backed by the Boykov–Kolmogorov max-flow algorithm. More...

#include <BKSolver.hpp>

Inheritance diagram for BKSolver< T >:
[legend]
Collaboration diagram for BKSolver< T >:
[legend]

Public Member Functions

 BKSolver (int var_num_max, int edge_num_max)
 Constructs the solver with pre-allocated capacity.
 
 ~BKSolver () override
 
MaxFlowSolver< T >::Var add_variable () override
 Introduces a new binary variable and returns its handle.
 
void add_constant (T E) override
 Adds a constant term to the energy function.
 
void add_term1 (typename MaxFlowSolver< T >::Var x, T E0, T E1) override
 
void add_term2 (typename MaxFlowSolver< T >::Var x, typename MaxFlowSolver< T >::Var y, T E00, T E01, T E10, T E11) override
 
minimize () override
 Minimizes the energy and returns the minimum value.
 
int get_var (typename MaxFlowSolver< T >::Var x) override
 
- Public Member Functions inherited from MaxFlowSolver< T >
virtual ~MaxFlowSolver ()=default
 
virtual void add_term1 (Var x, T E0, T E1)=0
 Adds a unary term E(x) where x ∈ {0, 1}.
 
virtual void add_term2 (Var x, Var y, T E00, T E01, T E10, T E11)=0
 Adds a pairwise term E(x, y) where x, y ∈ {0, 1}.
 
virtual int get_var (Var x)=0
 Returns the optimal value of variable x (0 or 1) after minimize().
 

Additional Inherited Members

- Public Types inherited from MaxFlowSolver< T >
typedef int Var
 Integer handle identifying a binary variable.
 

Detailed Description

template<typename T>
class BKSolver< T >

MaxFlowSolver backed by the Boykov–Kolmogorov max-flow algorithm.

This solver wraps the original BK implementation by Yuri Boykov and Vladimir Kolmogorov. It is the default solver and is available in all builds.

License note: The underlying BK implementation is restricted to non-commercial, research use only. See the project README for details.

Template Parameters
TNumeric cost type (int32_t, float, or double).

Constructor & Destructor Documentation

◆ BKSolver()

template<typename T >
BKSolver< T >::BKSolver ( int  var_num_max,
int  edge_num_max 
)
inline

Constructs the solver with pre-allocated capacity.

Parameters
var_num_maxMaximum number of binary variables expected.
edge_num_maxMaximum number of edges expected (used for memory pre-allocation).

◆ ~BKSolver()

template<typename T >
BKSolver< T >::~BKSolver ( )
inlineoverride

Member Function Documentation

◆ add_constant()

template<typename T >
void BKSolver< T >::add_constant ( E)
inlineoverridevirtual

Adds a constant term to the energy function.

Parameters
EConstant to add.

Implements MaxFlowSolver< T >.

◆ add_term1()

template<typename T >
void BKSolver< T >::add_term1 ( typename MaxFlowSolver< T >::Var  x,
E0,
E1 
)
inlineoverride

◆ add_term2()

template<typename T >
void BKSolver< T >::add_term2 ( typename MaxFlowSolver< T >::Var  x,
typename MaxFlowSolver< T >::Var  y,
E00,
E01,
E10,
E11 
)
inlineoverride

◆ add_variable()

template<typename T >
MaxFlowSolver< T >::Var BKSolver< T >::add_variable ( )
inlineoverridevirtual

Introduces a new binary variable and returns its handle.

Implements MaxFlowSolver< T >.

◆ get_var()

template<typename T >
int BKSolver< T >::get_var ( typename MaxFlowSolver< T >::Var  x)
inlineoverride

◆ minimize()

template<typename T >
T BKSolver< T >::minimize ( )
inlineoverridevirtual

Minimizes the energy and returns the minimum value.

Implements MaxFlowSolver< T >.


The documentation for this class was generated from the following file: