/* ECP: FILEname=fig10_30.c */ /* 1*/ void /* 2*/ PrintPath( int DestNode, const Vertex Graph[ ] ) /* 3*/ { /* 4*/ Stack S = StMakeEmpty( NULL ); /* 5*/ int Intermediate; /* 6*/ if( Graph[ DestNode ].Distance == Infinity ) /* 7*/ printf( "%s unreachable\n", Graph[ DestNode ].NodeName ); /* 8*/ else /* 9*/ { /*10*/ Intermediate = Graph[ DestNode ].PreviousNode; /*11*/ while( Intermediate != -1 ) /*12*/ { /*13*/ Push( Intermediate, S ); /*14*/ Intermediate = Graph[ Intermediate ].PreviousNode; /*15*/ } /*16*/ while( !StIsEmpty( S ) ) /*17*/ { /*18*/ printf( "%s to ", Graph[ Top( S ) ].NodeName ); /*19*/ Pop( S ); /*20*/ } /*21*/ printf( "%s\n", Graph[ DestNode ].NodeName ); /*22*/ } /*23*/ StRecycle( S ); /*24*/ }