
/*
**  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,TOption = 0,goblinController& = goblinDefaultContext,
        bool = false) throw();
    graph(char*,goblinController& = goblinDefaultContext) throw(ERFile,ERParse);
    graph(abstractMixedGraph&,TOption = 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&,TOption) throw(ERRejected);

};


class lineGraph : public graph
{                                        
public:

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

};


class tiling : public graph
{                                        
public:

    tiling(abstractMixedGraph&,TOption,TNode,TNode) throw();
    
    TNode Index(TNode,TNode,TNode,TNode,TNode) throw();

};


class voronoiDiagram : public graph
{                                        
private:

    abstractMixedGraph& G;
    TArc*               revMap;
    
public:

    voronoiDiagram(abstractMixedGraph&) throw();
    ~voronoiDiagram() throw();
    
    TFloat UpdateSubgraph() throw();

};


class triangularGraph : public graph
{                                        
public:

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

};


#endif
