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


#if !defined(_FNW2FNW_H_)

#define _FNW2FNW_H_

#include <absdig.h>


class FNW2FNW : public abstractDiGraph
{                                        
friend class iFNW2FNW;
protected:              

    abstractDiGraph &G;     // The original network

    TNode           n0;         // Number of nodes in the original network
    TArc            m0;         // Number of arcs in the original network

    TNode           s1;         // Source node, s1 == Source()
    TNode           t1;         // Sink node, t1 == Target()
    TArc            ret1;       // Return arc with end nodes t1 and s1
    
    TFloat *        flow;       // Array of flow values on the artifical arcs
    TCap *          cap;        // Array of capacities of the artifical arcs
    TCap            sumLower;   // Sum of original lower capacity bounds

    TFloat *        pot;        // Pointer to the original node potentials

public:

    FNW2FNW(abstractDiGraph &PG,TFloat *pp= NULL) throw();
    ~FNW2FNW() throw();

    unsigned long   Size() throw();     
    unsigned long   Allocated() throw();     

    char            Perfect() throw();
 
    TNode           Source() throw() {return s1;};
    TNode           Target() throw() {return t1;};     

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

    TCap            Demand(TNode v) throw(ERRange);
    TCap            UCap(TArc a) throw(ERRange);
    char            CUCap() throw() {return 0;};
    TCap            LCap(TArc a) throw() {return 0;};
    TCap            MaxLCap() throw() {return 0;};
    char            CLCap() throw() {return 1;};
    TFloat          Length(TArc a) throw(ERRange);
    TFloat          MaxLength() throw() {return G.MaxLength();};     
    char            CLength() throw() {return G.CLength() & (G.MaxLength()==0);};
    char            Blocking(TArc a) throw() {return a&1;};

    TFloat          C(TNode v,char i) throw(ERRange);
    TFloat          CMax(char i) throw(ERRange);
    char            Dim() throw() {return G.Dim();};
    char            HiddenNode(TNode v) throw(ERRange);

    TFloat          Flow(TArc a) throw(ERRange);
    void            Push(TArc a,TFloat Lambda) throw(ERRange,ERRejected);
    
    TFloat          Sub(TArc a) throw(ERRange) {return Flow(a);};
    void            AddArc(TArc a,TFloat Lambda) throw() {};
    void            OmitArc(TArc a,TFloat Lambda) throw() {};
    
    void Write(char * fileName) throw(ERFile)
            {WriteDiGraph(fileName,OPT_INCIDENCES);};

};                             


#endif
