
/*
**  This file forms part of the GOBLIN C++ Class Library.
**
**  Written by Christian Fremuth-Paeger, January 1999.
**  
**  Copying, compiling, distribution and modification
**  of this source code is permitted only in accordance
**  with the GOBLIN general licence information.
*/             


#if !defined(_AUXNET_H_)

#define _AUXNET_H_

#include <absdig.h>
#include <statq.h>


class layeredAuxNetwork : public abstractDiGraph
{
friend class iLayeredAuxNetwork;

protected:

    abstractDiGraph&        G;
    TNode                   s;
    TArc*                   P;

    goblinIterator*         I;
    char                    Phase;
    char*                   align;

    TArc*                   outDegree;
    TArc**                  successor;
    TArc*                   inDegree;
    TArc*                   currentDegree;
    TArc**                  prop;

    staticQueue<TNode,TFloat>* blocked;

public:

    layeredAuxNetwork(abstractDiGraph &GC,TArc *PP,TNode ss) throw();
    ~layeredAuxNetwork() throw();
    
    unsigned long   Size() throw();
    unsigned long   Allocated() throw();
    goblinIterator *NewIterator() throw();
     

    TNode           StartNode(TArc a) throw(ERRange);
    TNode           EndNode(TArc a) throw(ERRange);
   
    TArc            First(TNode v) throw(ERRange,ERRejected);
    TArc            Right(TArc a,TNode u) throw(ERRange,ERRejected);

    TCap            UCap(TArc a) throw(ERRange);
    bool            CUCap() throw() {return G.CUCap();};
    bool            Blocking(TArc a) throw(ERRange);
    char            Orientation(TArc a) throw(ERRange);
    bool            COrientation() throw() {return false;};
    void            WriteIncidences(goblinExport* F) throw()
                        {G.WriteIncidences(F);};
    TFloat          Dist(TNode v) throw(ERRange);

    TFloat          Length(TArc a) throw() {return 1;};
    bool            CLength() throw() {return true;};

    TFloat          C(TNode v,char i) throw(ERRange) {return G.C(v,i);};
    TFloat          CMax(char i) throw(ERRange) {return G.CMax(i);};
    char            Dim() throw() {return G.Dim();};
    bool            HiddenNode(TNode v) throw(ERRange) {return G.HiddenNode(v);};
    void            ConfigDisplay(goblinController &CFG) throw();
    
    
    void            Phase1() throw(ERRejected);
    void            Init() throw();
    void            InsertProp(TArc a) throw(ERRange,ERRejected);

    void            Phase2() throw(ERRejected);
    bool            Blocked(TNode v) throw(ERRange);
    TFloat          FindPath(TNode t) throw(ERRange,ERRejected);
    void            TopErasure(TArc a) throw(ERRange,ERRejected);

    void            AddArc(TArc a,TFloat Lambda) throw() {};
    void            OmitArc(TArc a,TFloat Lambda) throw() {};
    TFloat          Sub(TArc a) throw() {return 0;};

    void Write(char* fileName) throw(ERFile)
            {WriteMixedGraph(fileName);};

};                           


class iLayeredAuxNetwork : public virtual goblinIterator
{
private:

    layeredAuxNetwork &     G;
    TNode                   n;

    TArc*                   currentIndex;

public:

    iLayeredAuxNetwork(layeredAuxNetwork &GC) throw();
    ~iLayeredAuxNetwork() throw();
    
    unsigned long   Size() throw();
    unsigned long   Allocated() throw();

    void            Reset() throw();
    void            Reset(TNode v) throw(ERRange);
    TArc            Read(TNode v) throw(ERRange,ERRejected);
    TArc            Peek(TNode v) throw(ERRange,ERRejected);
    bool            Active(TNode v) throw(ERRange);
    void            Skip(TNode v) throw(ERRange,ERRejected);
    
};                           


#endif

