Mail Archives: djgpp/1998/06/06/16:46:05
On Sun, 07 Jun 1998 00:08:18 +1000, Dominique Louis
<Dominique_Louis AT BigPond DOT com> wrote:
>Hi all,
>I've spent the last few hours looking at the following code and can't
>work out why it's looping.
>Basically the function returns a list of all Nodes that are reachable
>from a particular Node.
>I don't think the fact that I'm using templates has anything to do with
>it, but maybe it has ( that's why I'm posting this message, I'm not sure
>of anything right now ).
>If you've got a spare 5 minutes please check it for me.
>The code is as follows....
>
>list< Node > reachable( Node reachVertice )
> {
> list< Node > x, x1;
> list< Edge > :: iterator i;
>
> cout << "reachable";
> for( i = EdgeList.begin( ); i != EdgeList.end( ); i++ )
> {
> if( ( i->getFrom( ) == reachVertice ) );
> {
> x.push_back( i->getTo( ) );
> x1 = reachable( i->getTo( ) );
> if( !x1.empty( ) )
> {
> x.splice( x.end( ), x1 );
> x.sort( );
> x.unique( );
> }
> }
> }
> return x;
> }
>
>
>thanks in advance,
>
>
>Dominique Louis.
>===========================================================
>To Do Nothing is to Collaborate with the oppressor!
>===========================================================
>
>
Did you want the semicolon after the line
if( ( i->getFrom( ) == reachVertice ) ); ?
Kev
- Raw text -