1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __fpa__Filters__DijkstraBase__hxx__
6 #define __fpa__Filters__DijkstraBase__hxx__
11 // -------------------------------------------------------------------------
12 template< class _TTraits >
13 void fpa::Filters::DijkstraBase< _TTraits >::
14 SetWeightFunction( TScalarWeight* w )
16 if( this->m_ScalarWeight.GetPointer( ) != w )
18 this->_Deassociate( this->m_ScalarWeight );
19 this->m_ScalarWeight = w;
20 this->_Associate( this->m_ScalarWeight );
26 // -------------------------------------------------------------------------
27 template< class _TTraits >
28 void fpa::Filters::DijkstraBase< _TTraits >::
29 SetWeightFunction( TVertexWeight* w )
31 if( this->m_VertexWeight.GetPointer( ) != w )
33 this->_Deassociate( this->m_VertexWeight );
34 this->m_VertexWeight = w;
35 this->_Associate( this->m_VertexWeight );
41 // -------------------------------------------------------------------------
42 template< class _TTraits >
43 fpa::Filters::DijkstraBase< _TTraits >::
47 this->SetInitValue( TOutputValue( 0 ) );
50 // -------------------------------------------------------------------------
51 template< class _TTraits >
52 fpa::Filters::DijkstraBase< _TTraits >::
57 // -------------------------------------------------------------------------
58 template< class _TTraits >
59 void fpa::Filters::DijkstraBase< _TTraits >::
60 _UpdateOutputValue( TNode& n )
65 // -------------------------------------------------------------------------
66 template< class _TTraits >
67 void fpa::Filters::DijkstraBase< _TTraits >::
70 this->m_Queue.clear( );
73 // -------------------------------------------------------------------------
74 template< class _TTraits >
75 typename fpa::Filters::DijkstraBase< _TTraits >::
76 TNode fpa::Filters::DijkstraBase< _TTraits >::
80 this->m_Queue.begin( ), this->m_Queue.end( ), this->m_QueueOrder
82 TNode n = this->m_Queue.back( );
83 this->m_Queue.pop_back( );
87 // -------------------------------------------------------------------------
88 template< class _TTraits >
89 void fpa::Filters::DijkstraBase< _TTraits >::
90 _QueuePush( const TNode& n )
92 bool push_needed = ( n.Parent == n.Vertex );
93 push_needed |= !( n.Value < this->_GetOutputValue( n.Parent ) );
96 this->m_Queue.push_back( n );
98 this->m_Queue.begin( ), this->m_Queue.end( ), this->m_QueueOrder
104 // -------------------------------------------------------------------------
105 template< class _TTraits >
106 unsigned long fpa::Filters::DijkstraBase< _TTraits >::
109 return( this->m_Queue.size( ) );
112 // -------------------------------------------------------------------------
113 template< class _TTraits >
114 void fpa::Filters::DijkstraBase< _TTraits >::
115 _ComputeOutputValue( TNode& n )
117 if( this->m_VertexWeight.IsNotNull( ) )
119 TOutputValue c = this->m_VertexWeight->Evaluate( n.Vertex, n.Parent );
120 if( this->m_ScalarWeight.IsNotNull( ) )
121 c = this->m_ScalarWeight->Evaluate( c );
122 n.Value = c + this->_GetOutputValue( n.Parent );
125 n.Value = TOutputValue( -1 );
128 #endif // __fpa__Filters__DijkstraBase__hxx__