*     *************************************************************************

      subroutine fapbep( k, kdis, ftstem, pr, fr, to, ba, nba, bep )

*     *************************************************************************

*     Purpose :
*     ---------

*     Given the indice K of a superbasic variable, it builds the
*     flow augmenting path of this arc and stores it in BEP.

*     Parameters :
*     ------------

*     k       ( int )

*       input  : the indice of the superbasic arc for which we
*                want to build its flow augmenting path.
*       output : unmodified.

*     kdis    ( int )

*       input  : meaningless.
*       output : the number of basic arcs composing the flow
*                augmenting path of the superbasic variable K.

*     ftstem  ( int )

*       input  : vector containing for each superbasic variable
*                the length from its origine node to the stem node
*                and the total length of its flow augmenting path.
*       output : unmodified.

*     pr      ( int )

*       input  : the predecessor vector.
*       output : unmodified.

*     fr      ( int )

*       input  : the vector containing the origine nodes of the arcs.
*       output : unmodified.

*     to      ( int )

*       input  : the vector containing the end nodes of the arcs.
*       output : unmodified.

*     ba      ( int )

*       input  : vector containing the indices of the basic variables.
*       output : unmodified.

*     nba     ( int )

*       input  : the number of basic variables.
*       output : unmodified.

*     bep     ( int )

*       input  : meaningless.
*       output : it contains the indices and the orientation of the 
*                basic arcs composing the flow augmenting path of the
*                superbasic arc K.

*     Routines used :
*     ---------------

*     getdbl.

*     Programming :
*     -------------

*     D. Tuyttens

*     ========================================================================

*     Routine parameters

      integer  k, kdis, ftstem(*), pr(*), fr(*), to(*), ba(*), nba, 
     +         bep(*)

*     Internal variables

      integer  i, n, fstem, kk

*
*     Get informations about arc K.
*
      call getdbl( ftstem(k), fstem, kdis )
      n = fr(k)
*
*     Build the flow augmenting path of arc K.
*     We begin from the origine node of arc K.
*
      do 10 i = 1 , kdis
*
*       If all the basic arcs from the origine node
*       of arc K to the stem node have been obtained 
*       and their indices are stored in BEP with their 
*       orientation, then we start from the end node 
*       of arc K.
*
        if( i.eq.fstem+1 ) n = to(k)
*
*       Obtain the ith basic arc indice.
*
        kk     = ba(n)
        bep(i) = kk
*
*       Define the orientation of basic arc KK
*       in the flow augmenting path.
*
        if( n.eq. fr(kk) ) then
          if( i.le.fstem ) bep(i) = -bep(i)
        else
          if( i.gt.fstem ) bep(i) = -bep(i)
        endif
*
*       Go to predecessor node in the maximal
*       basis spanning tree.
*
        n = pr(n)
*
 10   continue
*
      return
      end