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


#if !defined(_GENSTRUC_H_)

#define _GENSTRUC_H_

#include <absmix.h>
#include <import.h>


class genericGraphStructure : public virtual goblinDataObject
{
protected:

    abstractMixedGraph &G;          // Related graph Object

    TNode           nMax;           // Number of allocated nodes
    TArc            mMax;           // Number of allocated arcs

    TNode           nAct;           // Number of actual nodes 
    TArc            mAct;           // Number of actual arcs
    
    TCap*           ucap;           // Arc capacities
    TCap            cucap;          // Constant arc capacities
    TCap*           lcap;           // Lower arc capacities
    TCap            clcap;          // Constant lower arc capacities
    TFloat*         length;         // Arc cost labels
    TFloat          clength;        // Constant arc cost labels
    char*           orientation;    // Arc Orientation labels
    bool            cOrientation;   // Constant Arc Orientation
    TCap*           demand;         // Node demands
    TCap            cDemand;        // Constant node demands

    char            dim;            // Dimension of the geometric embedding
    TFloat*         x;              // x-coordinates
    TFloat*         y;              // y-coordinates
    TFloat          maxX;           // Maximum x-coordinate
    TFloat          maxY;           // Maximum y-coordinate

public:

    genericGraphStructure(abstractMixedGraph &GC) throw();
    virtual ~genericGraphStructure() throw();
    
    void            ReDimension(TNode nn,TArc mm) throw(ERRejected);
        // Initialize the the final dimensions
    
    void            ReadUCap(goblinImport &F) throw(ERParse);
    void            ReadLCap(goblinImport &F) throw(ERParse);
    void            ReadDemand(goblinImport &F) throw(ERParse);
    void            ReadOrientation(goblinImport &F) throw(ERParse);
    void            ReadObjectives(goblinImport &F) throw(ERParse);
    void            ReadGeometry(goblinImport &F) throw(ERParse);
    virtual void    ReadLayout(goblinImport &F) throw(ERParse);
    
    TNode           N() throw()
                        {return nAct;};
    TArc            M() throw()
                        {return mAct;};
    
    TCap            UCap(TArc a) throw(ERRange);
    TCap            MaxUCap() throw()
                        {return cucap;};
    void            SetUCap(TArc a,TCap cc) throw(ERRange);
    bool            CUCap() throw()
                        {return ucap==NULL;};
    void            SetCUCap(TCap cc) throw(ERRange);
    
    TCap            LCap(TArc a) throw(ERRange);
    TCap            MaxLCap() throw()
                        {return clcap;};
    void            SetLCap(TArc a,TCap bb) throw(ERRange);
    bool            CLCap() throw()
                        {return lcap==NULL;};
    void            SetCLCap(TCap bb) throw(ERRange);
    
    TCap            Demand(TNode v) throw(ERRange);
    TCap            MaxDemand() throw()
                        {return cDemand;};
    void            SetDemand(TNode v,TCap bb) throw(ERRange);
    bool            CDemand() throw()
                        {return demand==NULL;};
    void            SetCDemand(TCap bb) throw();
    
    TFloat          Length(TArc a) throw(ERRange);
    TFloat          MaxLength() throw()
                        {return clength;};     
    void            SetLength(TArc a,TFloat ll) throw(ERRange);
    bool            CLength() throw()
                       {return length==NULL;};
    void            SetCLength(TFloat ll) throw();
    
    char            Orientation(TArc a) throw(ERRange);
    char            Orientation() throw()
                        {return cOrientation;};     
    void            SetOrientation(TArc a,char oo) throw(ERRange);
    bool            COrientation() throw()
                        {return orientation==NULL;};
    void            SetCOrientation(char oo) throw();
    bool            Blocking(TArc a) throw(ERRange);
    
    TFloat          C(TNode v,char i) throw(ERRange);
    void            SetC(TNode v,char i,TFloat xx) throw(ERRange);
    TFloat          CMax(char i) throw();
    char            Dim() throw()
                        {return dim;};

    unsigned long   Allocated() throw();
    unsigned long   Size() throw() {return 0;};

    
    // *************************************************************** //
    //           Subgraph Management                                   //
    // *************************************************************** //

    virtual void    NewSubgraph() throw(ERRejected) = 0;
    virtual void    ReleaseSubgraph() throw() = 0;

    virtual TFloat  Sub(TArc a) throw(ERRange) = 0;
    virtual void    AddArc(TArc a,TFloat Lambda) throw(ERRejected,ERRange) = 0;
    virtual void    OmitArc(TArc a,TFloat Lambda) throw(ERRejected,ERRange) = 0;

    
    // *************************************************************** //
    //           Management of Network Flows                           //
    // *************************************************************** //

    TFloat          Flow(TArc a) throw(ERRange);
    void            Push(TArc a,TFloat Lambda) throw(ERRange);
    
};


#endif

