
/*
**  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(_SPSDIG_H_)

#define _SPSDIG_H_

#include <absdig.h>
#include <spsstruc.h>


class diGraph : public virtual abstractDiGraph
{                                 
    friend class sparseGraphStructure;
    
private:
    
    bool mode; 
    
protected:
        
    sparseGraphStructure X;    

public:

    diGraph(TNode nn,TOption options=0,
        goblinController &thisContext = goblinDefaultContext,
        bool mmode = false) throw();
    diGraph(char* impFileName,
        goblinController &thisContext = goblinDefaultContext)
        throw(ERFile,ERParse);
    diGraph(abstractMixedGraph &G,TOption options=0) throw();
    ~diGraph() throw();

    unsigned long   Size() throw();
    unsigned long   Allocated() throw();
    virtual objectType ClassID() throw() {return IDSparseDiGraph;};
    virtual void*   BackCast() {return (void*)this;};

    TArc            InsertArc(TNode u,TNode v) throw(ERRange,ERRejected)
                        {ReleaseAdjacencies(); m++; return X.InsertArc(u,v);};
    TArc            InsertArc(TNode u,TNode v,TCap uu,TFloat cc) throw(ERRange,ERRejected)
                        {ReleaseAdjacencies(); m++; return X.InsertArc(u,v,uu,0,cc);};
    TArc            InsertArc(TNode u,TNode v,TCap uu,TCap ll,TFloat cc) throw(ERRange,ERRejected)
                        {ReleaseAdjacencies(); m++; return X.InsertArc(u,v,uu,ll,cc);};
    void            DeleteArc(TArc a) throw(ERRange)
                        {ReleaseAll(); X.DeleteArc(a); ni = X.NI(); m = X.M();};
    
    void            ChinesePostman() throw();

    #include <spsincl.h>

    TFloat          Length(TArc a) throw(ERRange)
                        {if (a&1) return -X.Length(a); else return X.Length(a);};     

};                           


class completeOrientation : public diGraph
{
private:
    
    TArc*   origin;
    char    type;
    
public:

    completeOrientation(abstractMixedGraph &G,TOption options = 0) throw();
    ~completeOrientation() throw();

    unsigned long   Size() throw();
    unsigned long   Allocated() throw();
    
    TArc    OriginalArc(TArc) throw(ERRange);

};


class nodeSplitting : public diGraph
{                                        
public:

    nodeSplitting(abstractMixedGraph &G,TOption options = 0) throw();

};


#endif
