OpenGM  2.3.x
Discrete Graphical Model Library
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
opengm::FactorGraph< S, I > Class Template Reference

Interface that makes an object of type S (the template parameter) look like a (non-editable) factor graph. More...

#include <factorgraph.hxx>

+ Inheritance diagram for opengm::FactorGraph< S, I >:
+ Collaboration diagram for opengm::FactorGraph< S, I >:

Public Types

typedef S SpecialType
 
typedef AccessorIterator< VariableAccessor, true > ConstVariableIterator
 
typedef AccessorIterator< FactorAccessor, true > ConstFactorIterator
 

Public Member Functions

size_t numberOfVariables () const
 total number of variable nodes in the factor graph More...
 
size_t numberOfVariables (const size_t) const
 number of variable nodes connected to a factor node More...
 
size_t numberOfFactors () const
 total number of factor nodes in the factor graph More...
 
size_t numberOfFactors (const size_t) const
 number of factor nodes connected to a variable node More...
 
size_t variableOfFactor (const size_t, const size_t) const
 j-th variable node connected to a factor node More...
 
size_t factorOfVariable (const size_t, const size_t) const
 j-th factor node connected to a variable node More...
 
ConstVariableIterator variablesOfFactorBegin (const size_t) const
 constant iterator to the beginning of the squence of variables connected to a factor More...
 
ConstVariableIterator variablesOfFactorEnd (const size_t) const
 constant iterator to the end of the squence of variables connected to a factor More...
 
ConstFactorIterator factorsOfVariableBegin (const size_t) const
 constant iterator to the beginning of the squence of factors connected to a variable More...
 
ConstFactorIterator factorsOfVariableEnd (const size_t) const
 constant iterator to the end of the squence of factors connected to a variable More...
 
bool variableFactorConnection (const size_t, const size_t) const
 return true if a factor is connected to a variable More...
 
bool factorVariableConnection (const size_t, const size_t) const
 return true if a variable is connected to a factor More...
 
bool variableVariableConnection (const size_t, const size_t) const
 return true if a variable is connected to a variable More...
 
bool factorFactorConnection (const size_t, const size_t) const
 return true if a factor is connected to a factor More...
 
bool isAcyclic () const
 return true if the factor graph (!) is acyclic More...
 
bool isConnected (marray::Vector< size_t > &representatives) const
 return true if the factor graph (!) is connected More...
 
bool isChain (marray::Vector< size_t > &) const
 return true if the factor graph (!) is a chain More...
 
bool isGrid (marray::Matrix< size_t > &) const
 return true if the factor graph (!) is a grid More...
 
size_t maxFactorOrder () const
 return maximum factor order More...
 
bool maxFactorOrder (const size_t maxOrder) const
 return true if the maximum factor order is less or equal to maxOrder More...
 
size_t numberOfNthOrderFactorsOfVariable (const size_t, const size_t) const
 return number of factors with order n which are connected to variable More...
 
size_t numberOfNthOrderFactorsOfVariable (const size_t, const size_t, marray::Vector< size_t > &) const
 return number of factors with order n which are connected to variable and stores the corresponding factorIDs More...
 
size_t secondVariableOfSecondOrderFactor (const size_t, const size_t) const
 return returns the id of the second variable which is connected to a given variable via a second order factor More...
 
void variableAdjacencyMatrix (marray::Matrix< bool > &) const
 outputs the factor graph as a variable adjacency matrix More...
 
void variableAdjacencyList (std::vector< std::set< IndexType > > &) const
 outputs the factor graph as variable adjacency lists More...
 
void variableAdjacencyList (std::vector< RandomAccessSet< IndexType > > &) const
 outputs the factor graph as variable adjacency lists More...
 
void factorAdjacencyList (std::vector< std::set< IndexType > > &) const
 
void factorAdjacencyList (std::vector< RandomAccessSet< IndexType > > &) const
 

Protected Member Functions

 operator S & ()
 
 operator S const & () const
 
template<class LIST >
bool shortestPath (const size_t, const size_t, LIST &, const LIST &=LIST()) const
 computes the shortest path from s to t using Dijkstra's algorithm with uniform distances More...
 
template<class LIST >
bool twoHopConnected (const size_t, const size_t, LIST &) const
 checks if variabel1 is connected to variable2 via two hops More...
 

Detailed Description

template<class S, class I>
class opengm::FactorGraph< S, I >

Interface that makes an object of type S (the template parameter) look like a (non-editable) factor graph.

Definition at line 18 of file factorgraph.hxx.

Member Typedef Documentation

template<class S, class I>
typedef AccessorIterator<FactorAccessor, true> opengm::FactorGraph< S, I >::ConstFactorIterator

Definition at line 26 of file factorgraph.hxx.

template<class S, class I>
typedef AccessorIterator<VariableAccessor, true> opengm::FactorGraph< S, I >::ConstVariableIterator

Definition at line 25 of file factorgraph.hxx.

template<class S, class I>
typedef S opengm::FactorGraph< S, I >::SpecialType

Definition at line 24 of file factorgraph.hxx.

Member Function Documentation

template<class S , class I >
void opengm::FactorGraph< S, I >::factorAdjacencyList ( std::vector< std::set< IndexType > > &  out) const
inline

Definition at line 901 of file factorgraph.hxx.

template<class S , class I >
void opengm::FactorGraph< S, I >::factorAdjacencyList ( std::vector< RandomAccessSet< IndexType > > &  out) const
inline

Definition at line 911 of file factorgraph.hxx.

template<class S , class I >
bool opengm::FactorGraph< S, I >::factorFactorConnection ( const size_t  factor1,
const size_t  factor2 
) const
inline

return true if a factor is connected to a factor

Parameters
factor1variable index
factor2variable index
Returns
result

Definition at line 803 of file factorgraph.hxx.

template<class S , class I >
size_t opengm::FactorGraph< S, I >::factorOfVariable ( const size_t  variable,
const size_t  j 
) const
inline

j-th factor node connected to a variable node

Parameters
variablevariable index
jnumber of the factor w.r.t. the variable
Returns
factor index

Definition at line 198 of file factorgraph.hxx.

template<class S , class I >
FactorGraph< S, I >::ConstFactorIterator opengm::FactorGraph< S, I >::factorsOfVariableBegin ( const size_t  variable) const
inline

constant iterator to the beginning of the squence of factors connected to a variable

Parameters
variablevariable index
Returns
iterator

Definition at line 240 of file factorgraph.hxx.

template<class S , class I >
FactorGraph< S, I >::ConstFactorIterator opengm::FactorGraph< S, I >::factorsOfVariableEnd ( const size_t  variable) const
inline

constant iterator to the end of the squence of factors connected to a variable

Parameters
variablevariable index
Returns
iterator

Definition at line 254 of file factorgraph.hxx.

template<class S , class I >
bool opengm::FactorGraph< S, I >::factorVariableConnection ( const size_t  factor,
const size_t  variable 
) const
inline

return true if a variable is connected to a factor

Parameters
factorfactor index
variablevariable index
Returns
result

Definition at line 293 of file factorgraph.hxx.

template<class S , class I >
bool opengm::FactorGraph< S, I >::isAcyclic ( ) const

return true if the factor graph (!) is acyclic

Returns
result

Definition at line 339 of file factorgraph.hxx.

template<class S , class I >
bool opengm::FactorGraph< S, I >::isChain ( marray::Vector< size_t > &  chainIDs) const
inline

return true if the factor graph (!) is a chain

Parameters
[out]chainIDsA vector representing the chain, where chain(i) contains the corresponding variable ID.
Returns
result

Definition at line 431 of file factorgraph.hxx.

+ Here is the call graph for this function:

template<class S , class I >
bool opengm::FactorGraph< S, I >::isConnected ( marray::Vector< size_t > &  representatives) const

return true if the factor graph (!) is connected

Parameters
[out]representativesA vector of variable id's where each id is a representative of a connected component.
Returns
result

Definition at line 392 of file factorgraph.hxx.

+ Here is the call graph for this function:

template<class S , class I >
bool opengm::FactorGraph< S, I >::isGrid ( marray::Matrix< size_t > &  gridIDs) const
inline

return true if the factor graph (!) is a grid

Parameters
[out]gridIDsA matrix representing the grid, where grid(i,j) contains the corresponding variable ID.
Returns
result

Definition at line 529 of file factorgraph.hxx.

+ Here is the call graph for this function:

template<class S , class I >
size_t opengm::FactorGraph< S, I >::maxFactorOrder ( ) const
inline

return maximum factor order

Returns
maximum factor order

Definition at line 714 of file factorgraph.hxx.

+ Here is the caller graph for this function:

template<class S , class I >
bool opengm::FactorGraph< S, I >::maxFactorOrder ( const size_t  maxOrder) const
inline

return true if the maximum factor order is less or equal to maxOrder

Parameters
maxOrdermaximum allowed factor order
Returns
result

Definition at line 729 of file factorgraph.hxx.

template<class S , class I >
size_t opengm::FactorGraph< S, I >::numberOfFactors ( ) const
inline

total number of factor nodes in the factor graph

Returns
number of factor nodes

Definition at line 158 of file factorgraph.hxx.

template<class S , class I >
size_t opengm::FactorGraph< S, I >::numberOfFactors ( const size_t  variable) const
inline

number of factor nodes connected to a variable node

Parameters
variablevariable index
Returns
number of factor nodes

Definition at line 169 of file factorgraph.hxx.

template<class S , class I >
size_t opengm::FactorGraph< S, I >::numberOfNthOrderFactorsOfVariable ( const size_t  variable,
const size_t  n 
) const
inline

return number of factors with order n which are connected to variable

Parameters
variablevariable index
ndesired order of factors
Returns
result

Definition at line 744 of file factorgraph.hxx.

template<class S , class I >
size_t opengm::FactorGraph< S, I >::numberOfNthOrderFactorsOfVariable ( const size_t  variable,
const size_t  n,
marray::Vector< size_t > &  factorIDs 
) const
inline

return number of factors with order n which are connected to variable and stores the corresponding factorIDs

Parameters
variablevariable index
ndesired order of factors
[out]factorIDsfactorIDs of all n'th order factors connected to a given variable
Returns
result

Definition at line 762 of file factorgraph.hxx.

+ Here is the call graph for this function:

template<class S , class I >
size_t opengm::FactorGraph< S, I >::numberOfVariables ( ) const
inline

total number of variable nodes in the factor graph

Returns
number of variable nodes

Definition at line 136 of file factorgraph.hxx.

template<class S , class I >
size_t opengm::FactorGraph< S, I >::numberOfVariables ( const size_t  factor) const
inline

number of variable nodes connected to a factor node

Parameters
factorfactor index
Returns
number of variable nodes

Definition at line 147 of file factorgraph.hxx.

template<class S, class I>
opengm::FactorGraph< S, I >::operator S & ( )
inlineprotected

Definition at line 65 of file factorgraph.hxx.

template<class S, class I>
opengm::FactorGraph< S, I >::operator S const & ( ) const
inlineprotected

Definition at line 67 of file factorgraph.hxx.

template<class S , class I >
size_t opengm::FactorGraph< S, I >::secondVariableOfSecondOrderFactor ( const size_t  variable,
const size_t  factor 
) const
inline

return returns the id of the second variable which is connected to a given variable via a second order factor

Parameters
variablevariable index
factorfactor index
Returns
result

Definition at line 783 of file factorgraph.hxx.

template<class S , class I >
template<class LIST >
bool opengm::FactorGraph< S, I >::shortestPath ( const size_t  s,
const size_t  t,
LIST &  path,
const LIST &  allowedVariables = LIST() 
) const
inlineprotected

computes the shortest path from s to t using Dijkstra's algorithm with uniform distances

Parameters
sID of the start variable
tID of the target variable
[out]pathreturns computed path from s to t
allowedVariablespath is only allowed to contain variables which are given here (if empty, all variables are allowed)

Definition at line 948 of file factorgraph.hxx.

template<class S , class I >
template<class LIST >
bool opengm::FactorGraph< S, I >::twoHopConnected ( const size_t  variable1,
const size_t  variable2,
LIST &  oneHopVariables 
) const
inlineprotected

checks if variabel1 is connected to variable2 via two hops

Parameters
variable1ID of the first variable
variable2ID of the second variable
[out]oneHopVariablesa List of all possible one hop variables in the two hop path from variable1 to variable2

Definition at line 1077 of file factorgraph.hxx.

template<class S , class I >
void opengm::FactorGraph< S, I >::variableAdjacencyList ( std::vector< std::set< IndexType > > &  out) const
inline

outputs the factor graph as variable adjacency lists

Parameters
outvariable adjacency lists (as a vector of sets)

Definition at line 867 of file factorgraph.hxx.

template<class S , class I >
void opengm::FactorGraph< S, I >::variableAdjacencyList ( std::vector< RandomAccessSet< IndexType > > &  out) const
inline

outputs the factor graph as variable adjacency lists

Parameters
outvariable adjacency lists (as a vector of RandomAccessSets)

Definition at line 855 of file factorgraph.hxx.

template<class S , class I >
void opengm::FactorGraph< S, I >::variableAdjacencyMatrix ( marray::Matrix< bool > &  out) const
inline

outputs the factor graph as a variable adjacency matrix

Parameters
outmatrix

Definition at line 833 of file factorgraph.hxx.

template<class S , class I >
bool opengm::FactorGraph< S, I >::variableFactorConnection ( const size_t  variable,
const size_t  factor 
) const
inline

return true if a factor is connected to a variable

Parameters
variablevariable index
factorfactor index
Returns
result

Definition at line 269 of file factorgraph.hxx.

template<class S , class I >
size_t opengm::FactorGraph< S, I >::variableOfFactor ( const size_t  factor,
const size_t  j 
) const
inline

j-th variable node connected to a factor node

Parameters
factorfactor index
jnumber of the variable w.r.t. the factor
Returns
variable index

Definition at line 183 of file factorgraph.hxx.

template<class S , class I >
FactorGraph< S, I >::ConstVariableIterator opengm::FactorGraph< S, I >::variablesOfFactorBegin ( const size_t  factor) const
inline

constant iterator to the beginning of the squence of variables connected to a factor

Parameters
factorfactor index
Returns
iterator

Definition at line 212 of file factorgraph.hxx.

template<class S , class I >
FactorGraph< S, I >::ConstVariableIterator opengm::FactorGraph< S, I >::variablesOfFactorEnd ( const size_t  factor) const
inline

constant iterator to the end of the squence of variables connected to a factor

Parameters
factorfactor index
Returns
iterator

Definition at line 226 of file factorgraph.hxx.

template<class S , class I >
bool opengm::FactorGraph< S, I >::variableVariableConnection ( const size_t  variable1,
const size_t  variable2 
) const
inline

return true if a variable is connected to a variable

Parameters
variable1variable index
variable2variable index
Returns
result

Definition at line 310 of file factorgraph.hxx.