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

#define _SPSGRA_H_

#include <absgra.h>
#include <spsstruc.h>


class graph : public virtual abstractGraph
{
    friend class sparseGraphStructure;
    
private:
    
    bool mode; 
    
protected:
        
    sparseGraphStructure X;    

public:

    graph(TNode nn,TOption options=0,
        goblinController &thisContext = goblinDefaultContext,bool mmode = false)
        throw();
    graph(char* impFileName,
        goblinController &thisContext = goblinDefaultContext)
        throw(ERFile,ERParse);
    graph(abstractMixedGraph &G,TOption options=0) throw();
    ~graph() throw();
                    
    unsigned long   Size() throw();
    unsigned long   Allocated() throw();
    virtual objectType ClassID() throw() {return IDSparseGraph;};
    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)
                        {return X.Length(a);};     

};                           


class complementaryGraph : public graph
{                                        
public:

    complementaryGraph(abstractMixedGraph &G,TOption options) throw(ERRejected);

};


class lineGraph : public graph
{                                        
public:

    lineGraph(abstractMixedGraph &G,TOption options) throw(ERRejected);

};


class tiling : public graph
{                                        
public:

    tiling(abstractMixedGraph &G,TOption options,TNode x,TNode y) throw();
    
    TNode Index(TNode i,TNode j,TNode x,TNode offset,TNode w) throw();

};


class triangularGraph : public graph
{                                        
public:

    triangularGraph(TNode,TOption,goblinController & = goblinDefaultContext) throw();

};


#endif
