*     H03ADF Example Program Text
*     Mark 20 Revised. NAG Copyright 2001.
*     .. Parameters ..
      INTEGER          NIN, NOUT
      PARAMETER        (NIN=5,NOUT=6)
      INTEGER          NMAX, NNZMAX
      PARAMETER        (NMAX=100,NNZMAX=1000)
      CHARACTER        DUP, ZERO
      PARAMETER        (DUP='F',ZERO='R')
*     .. Local Scalars ..
      DOUBLE PRECISION SPLEN
      INTEGER          IFAIL, J, LENC, N, NE, NNZ, NS
      LOGICAL          DIRECT
*     .. Local Arrays ..
      DOUBLE PRECISION D(NNZMAX), WORK(2*NMAX)
      INTEGER          ICOL(NNZMAX), IROW(NNZMAX), IWORK(3*NMAX+1),
     +                 PATH(NMAX)
*     .. External Subroutines ..
      EXTERNAL         F11ZAF, H03ADF
*     .. Executable Statements ..
      WRITE (NOUT,*) 'H03ADF Example Program Results'
*     Skip heading in data file
      READ (NIN,*)
      READ (NIN,*) N, NS, NE, NNZ, DIRECT
      IF (N.LE.NMAX .AND. NNZ.LE.NNZMAX) THEN
*
*        Read D, IROW and ICOL from data file.
*
         READ (NIN,*) (D(J),IROW(J),ICOL(J),J=1,NNZ)
*
*        Reorder the elements of D into the form required by H03ADF.
*
         IFAIL = 0
         CALL F11ZAF(N,NNZ,D,IROW,ICOL,DUP,ZERO,IWORK,IWORK(N+2),IFAIL)
*
*        Find the shortest path between vertices NS and NE.
*
         IFAIL = 0
         CALL H03ADF(N,NS,NE,DIRECT,NNZ,D,IROW,ICOL,SPLEN,PATH,IWORK,
     +               WORK,IFAIL)
*
         IF (IFAIL.EQ.0) THEN
*
*           Print details of shortest path.
*
            DO 20 J = 0, N - 1
               IF (PATH(J+1).EQ.0) THEN
                  LENC = J
                  GO TO 40
               END IF
   20       CONTINUE
            LENC = N
   40       CONTINUE
            WRITE (NOUT,99999) 'Shortest path = ', (PATH(J),J=1,LENC)
            WRITE (NOUT,99998) 'Length of shortest path = ', SPLEN
         END IF
      END IF
      STOP
*
99999 FORMAT (/1X,A,10(I2,:'  to '))
99998 FORMAT (/1X,A,G16.6)
      END
