1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
6 #ifndef __fpa__Base__DijkstraBase__hxx__
7 #define __fpa__Base__DijkstraBase__hxx__
12 // -------------------------------------------------------------------------
13 template< class _TAlgorithm >
14 itk::ModifiedTimeType fpa::Base::DijkstraBase< _TAlgorithm >::
17 itk::ModifiedTimeType t = this->Superclass::GetMTime( );
18 if( this->m_WeightFunction.IsNotNull( ) )
20 itk::ModifiedTimeType q = this->m_WeightFunction->GetMTime( );
27 // -------------------------------------------------------------------------
28 template< class _TAlgorithm >
29 fpa::Base::DijkstraBase< _TAlgorithm >::
33 this->SetInitValue( std::numeric_limits< TOutputValue >::max( ) );
36 // -------------------------------------------------------------------------
37 template< class _TAlgorithm >
38 fpa::Base::DijkstraBase< _TAlgorithm >::
43 // -------------------------------------------------------------------------
44 template< class _TAlgorithm >
45 typename fpa::Base::DijkstraBase< _TAlgorithm >::
46 TOutputValue fpa::Base::DijkstraBase< _TAlgorithm >::
47 _ComputeOutputValue( const TNode& n )
49 TOutputValue c = this->m_WeightFunction->Evaluate( n.Vertex, n.Parent );
50 return( c + this->_GetOutputValue( n.Parent ) );
53 // -------------------------------------------------------------------------
54 template< class _TAlgorithm >
55 void fpa::Base::DijkstraBase< _TAlgorithm >::
58 typedef typename Superclass::TSeedsInterface::TSeeds::iterator _TIt;
60 this->Superclass::_QueueInit( );
61 for( _TIt sIt = this->BeginSeeds( ); sIt != this->EndSeeds( ); ++sIt )
62 sIt->Value = TOutputValue( 0 );
65 // -------------------------------------------------------------------------
66 template< class _TAlgorithm >
67 void fpa::Base::DijkstraBase< _TAlgorithm >::
70 this->m_Queue.clear( );
73 // -------------------------------------------------------------------------
74 template< class _TAlgorithm >
75 typename fpa::Base::DijkstraBase< _TAlgorithm >::
76 TNode fpa::Base::DijkstraBase< _TAlgorithm >::
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 _TAlgorithm >
89 void fpa::Base::DijkstraBase< _TAlgorithm >::
90 _QueuePush( const TNode& node )
92 bool push_needed = ( node.Parent == node.Vertex );
93 push_needed |= !( node.Value < this->_GetOutputValue( node.Parent ) );
96 this->m_Queue.push_back( node );
98 this->m_Queue.begin( ), this->m_Queue.end( ), this->m_QueueOrder
104 // -------------------------------------------------------------------------
105 template< class _TAlgorithm >
106 unsigned long fpa::Base::DijkstraBase< _TAlgorithm >::
109 return( this->m_Queue.size( ) );
112 #endif // __fpa__Base__DijkstraBase__hxx__