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 this->m_Queue.clear( );
61 // -------------------------------------------------------------------------
62 template< class _TAlgorithm >
63 typename fpa::Base::DijkstraBase< _TAlgorithm >::
64 TNode fpa::Base::DijkstraBase< _TAlgorithm >::
68 this->m_Queue.begin( ), this->m_Queue.end( ), this->m_QueueOrder
70 TNode n = this->m_Queue.back( );
71 this->m_Queue.pop_back( );
75 // -------------------------------------------------------------------------
76 template< class _TAlgorithm >
77 void fpa::Base::DijkstraBase< _TAlgorithm >::
78 _QueuePush( const TNode& node )
80 bool push_needed = ( node.Parent == node.Vertex );
81 push_needed |= !( node.Value < this->_GetOutputValue( node.Parent ) );
84 this->m_Queue.push_back( node );
86 this->m_Queue.begin( ), this->m_Queue.end( ), this->m_QueueOrder
92 // -------------------------------------------------------------------------
93 template< class _TAlgorithm >
94 unsigned long fpa::Base::DijkstraBase< _TAlgorithm >::
97 return( this->m_Queue.size( ) );
100 // -------------------------------------------------------------------------
101 template< class _TAlgorithm >
102 void fpa::Base::DijkstraBase< _TAlgorithm >::
103 _PrepareSeeds( TNodes& nodes )
105 typename TNodes::iterator nIt = nodes.begin( );
106 for( ; nIt != nodes.end( ); ++nIt )
107 nIt->Value = TOutputValue( 0 );
110 #endif // __fpa__Base__DijkstraBase__hxx__