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 void fpa::Base::DijkstraBase< _TAlgorithm >::
46 _ComputeOutputValue( TNode& n )
48 TOutputValue c = this->m_WeightFunction->Evaluate( n.Vertex, n.Parent );
49 n.Value = c + this->_GetOutputValue( n.Parent );
52 // -------------------------------------------------------------------------
53 template< class _TAlgorithm >
54 void fpa::Base::DijkstraBase< _TAlgorithm >::
57 this->m_Queue.clear( );
60 // -------------------------------------------------------------------------
61 template< class _TAlgorithm >
62 typename fpa::Base::DijkstraBase< _TAlgorithm >::
63 TNode fpa::Base::DijkstraBase< _TAlgorithm >::
67 this->m_Queue.begin( ), this->m_Queue.end( ), this->m_QueueOrder
69 TNode n = this->m_Queue.back( );
70 this->m_Queue.pop_back( );
74 // -------------------------------------------------------------------------
75 template< class _TAlgorithm >
76 void fpa::Base::DijkstraBase< _TAlgorithm >::
77 _QueuePush( const TNode& node )
79 bool push_needed = ( node.Parent == node.Vertex );
80 push_needed |= !( node.Value < this->_GetOutputValue( node.Parent ) );
83 this->m_Queue.push_back( node );
85 this->m_Queue.begin( ), this->m_Queue.end( ), this->m_QueueOrder
91 // -------------------------------------------------------------------------
92 template< class _TAlgorithm >
93 unsigned long fpa::Base::DijkstraBase< _TAlgorithm >::
96 return( this->m_Queue.size( ) );
99 // -------------------------------------------------------------------------
100 template< class _TAlgorithm >
101 void fpa::Base::DijkstraBase< _TAlgorithm >::
102 _PrepareSeeds( TNodes& nodes )
104 typename TNodes::iterator nIt = nodes.begin( );
105 for( ; nIt != nodes.end( ); ++nIt )
106 nIt->Value = TOutputValue( 0 );
109 #endif // __fpa__Base__DijkstraBase__hxx__