| 
marci@174
 | 
     1  | 
// -*- c++ -*-
  | 
| 
marci@174
 | 
     2  | 
#ifndef EMPTYGRAPH_H
  | 
| 
marci@174
 | 
     3  | 
#define EMPTYGRAPH_H
  | 
| 
alpar@52
 | 
     4  | 
  | 
| 
alpar@163
 | 
     5  | 
#include <invalid.h>
  | 
| 
alpar@145
 | 
     6  | 
  | 
| 
alpar@163
 | 
     7  | 
/// The namespace of HugoLib
  | 
| 
alpar@163
 | 
     8  | 
namespace hugo {
 | 
| 
alpar@163
 | 
     9  | 
  | 
| 
alpar@163
 | 
    10  | 
  // @defgroup empty_graph The EmptyGraph class
  | 
| 
alpar@163
 | 
    11  | 
  // @{
 | 
| 
alpar@163
 | 
    12  | 
  | 
| 
alpar@163
 | 
    13  | 
  /// An empty graph class.
  | 
| 
alpar@163
 | 
    14  | 
  
  | 
| 
alpar@163
 | 
    15  | 
  /// This class provides all the common features of a grapf structure,
  | 
| 
alpar@163
 | 
    16  | 
  /// however completely without implementations or real data structures
  | 
| 
alpar@163
 | 
    17  | 
  /// behind the interface.
  | 
| 
alpar@163
 | 
    18  | 
  /// All graph algorithms should compile with this class, but it will not
  | 
| 
alpar@163
 | 
    19  | 
  /// run properly, of course.
  | 
| 
alpar@163
 | 
    20  | 
  ///
  | 
| 
alpar@163
 | 
    21  | 
  /// It can be used for checking the interface compatibility,
  | 
| 
alpar@163
 | 
    22  | 
  /// or it can serve as a skeleton of a new graph structure.
  | 
| 
alpar@165
 | 
    23  | 
  /// 
  | 
| 
alpar@165
 | 
    24  | 
  /// Also, you will find here the full documentation of a certain graph
  | 
| 
alpar@165
 | 
    25  | 
  /// feature, the documentation of a real graph imlementation
  | 
| 
alpar@165
 | 
    26  | 
  /// like @ref ListGraph or
  | 
| 
alpar@165
 | 
    27  | 
  /// @ref SmartGraph will just refer to this structure.
  | 
| 
alpar@163
 | 
    28  | 
  class EmptyGraph
  | 
| 
alpar@163
 | 
    29  | 
  {
 | 
| 
alpar@147
 | 
    30  | 
  public:
  | 
| 
alpar@147
 | 
    31  | 
    
  | 
| 
alpar@163
 | 
    32  | 
    /// The base type of the node iterators.
  | 
| 
alpar@163
 | 
    33  | 
    class Node {
 | 
| 
alpar@163
 | 
    34  | 
    public:
  | 
| 
alpar@163
 | 
    35  | 
      /// @warning The default constructor sets the iterator
  | 
| 
alpar@163
 | 
    36  | 
      /// to an undefined value.
  | 
| 
alpar@163
 | 
    37  | 
      Node() {}   //FIXME
 | 
| 
alpar@163
 | 
    38  | 
      /// Initialize the iterator to be invalid
  | 
| 
marci@174
 | 
    39  | 
      Node(Invalid) {}
 | 
| 
alpar@163
 | 
    40  | 
      //Node(const Node &) {} 
 | 
| 
alpar@163
 | 
    41  | 
      bool operator==(Node n) const { return true; } //FIXME
 | 
| 
alpar@163
 | 
    42  | 
      bool operator!=(Node n) const { return true; } //FIXME
 | 
| 
alpar@163
 | 
    43  | 
    };
  | 
| 
alpar@147
 | 
    44  | 
    
  | 
| 
alpar@163
 | 
    45  | 
    /// This iterator goes through each node.
  | 
| 
alpar@163
 | 
    46  | 
    class NodeIt : public Node {
 | 
| 
alpar@163
 | 
    47  | 
    public:
  | 
| 
alpar@163
 | 
    48  | 
      /// @warning The default constructor sets the iterator
  | 
| 
alpar@163
 | 
    49  | 
      /// to an undefined value.
  | 
| 
alpar@163
 | 
    50  | 
      NodeIt() {} //FIXME
 | 
| 
alpar@163
 | 
    51  | 
      /// Initialize the iterator to be invalid
  | 
| 
marci@174
 | 
    52  | 
      NodeIt(Invalid) {}
 | 
| 
alpar@163
 | 
    53  | 
      /// Sets the iterator to the first node of \c G.
  | 
| 
alpar@163
 | 
    54  | 
      NodeIt(const EmptyGraph &G) {}
 | 
| 
alpar@163
 | 
    55  | 
      NodeIt(const NodeIt &) {} //FIXME
 | 
| 
alpar@163
 | 
    56  | 
    };
  | 
| 
alpar@163
 | 
    57  | 
    
  | 
| 
alpar@163
 | 
    58  | 
    
  | 
| 
alpar@163
 | 
    59  | 
    /// The base type of the edge iterators.
  | 
| 
alpar@163
 | 
    60  | 
    class Edge {
 | 
| 
alpar@163
 | 
    61  | 
    public:
  | 
| 
alpar@163
 | 
    62  | 
      /// @warning The default constructor sets the iterator
  | 
| 
alpar@163
 | 
    63  | 
      /// to an undefined value.
  | 
| 
alpar@163
 | 
    64  | 
      Edge() {}   //FIXME
 | 
| 
alpar@163
 | 
    65  | 
      /// Initialize the iterator to be invalid
  | 
| 
marci@174
 | 
    66  | 
      Edge(Invalid) {}
 | 
| 
alpar@163
 | 
    67  | 
      //Edge(const Edge &) {} 
 | 
| 
alpar@163
 | 
    68  | 
      bool operator==(Edge n) const { return true; } //FIXME
 | 
| 
alpar@163
 | 
    69  | 
      bool operator!=(Edge n) const { return true; } //FIXME    
 | 
| 
alpar@163
 | 
    70  | 
    };
  | 
| 
alpar@163
 | 
    71  | 
    
  | 
| 
alpar@163
 | 
    72  | 
    /// This iterator goes trought the outgoing edges of a certain graph.
  | 
| 
alpar@163
 | 
    73  | 
    
  | 
| 
alpar@163
 | 
    74  | 
    class OutEdgeIt : public Edge {
 | 
| 
alpar@163
 | 
    75  | 
    public:
  | 
| 
alpar@163
 | 
    76  | 
      /// @warning The default constructor sets the iterator
  | 
| 
alpar@163
 | 
    77  | 
      /// to an undefined value.
  | 
| 
alpar@163
 | 
    78  | 
      OutEdgeIt() {}
 | 
| 
alpar@163
 | 
    79  | 
      /// Initialize the iterator to be invalid
  | 
| 
marci@174
 | 
    80  | 
      OutEdgeIt(Invalid) {}
 | 
| 
alpar@163
 | 
    81  | 
      /// This constructor sets the iterator to first outgoing edge.
  | 
| 
alpar@163
 | 
    82  | 
    
  | 
| 
alpar@163
 | 
    83  | 
      /// This constructor set the iterator to the first outgoing edge of
  | 
| 
alpar@163
 | 
    84  | 
      /// node
  | 
| 
alpar@163
 | 
    85  | 
      ///@param n the node
  | 
| 
alpar@163
 | 
    86  | 
      ///@param G the graph
  | 
| 
alpar@163
 | 
    87  | 
      OutEdgeIt(const EmptyGraph & G, Node n) {}
 | 
| 
alpar@163
 | 
    88  | 
    };
  | 
| 
alpar@163
 | 
    89  | 
  | 
| 
alpar@163
 | 
    90  | 
    class InEdgeIt : public Edge {
 | 
| 
alpar@163
 | 
    91  | 
    public:
  | 
| 
alpar@163
 | 
    92  | 
      /// @warning The default constructor sets the iterator
  | 
| 
alpar@163
 | 
    93  | 
      /// to an undefined value.
  | 
| 
alpar@163
 | 
    94  | 
      InEdgeIt() {}
 | 
| 
alpar@163
 | 
    95  | 
      /// Initialize the iterator to be invalid
  | 
| 
marci@174
 | 
    96  | 
      InEdgeIt(Invalid) {}
 | 
| 
alpar@163
 | 
    97  | 
      InEdgeIt(const EmptyGraph &, Node) {}    
 | 
| 
alpar@163
 | 
    98  | 
    };
  | 
| 
alpar@163
 | 
    99  | 
    //  class SymEdgeIt : public Edge {};
 | 
| 
alpar@163
 | 
   100  | 
    class EdgeIt : public Edge {
 | 
| 
alpar@163
 | 
   101  | 
    public:
  | 
| 
alpar@163
 | 
   102  | 
      /// @warning The default constructor sets the iterator
  | 
| 
alpar@163
 | 
   103  | 
      /// to an undefined value.
  | 
| 
alpar@163
 | 
   104  | 
      EdgeIt() {}
 | 
| 
alpar@163
 | 
   105  | 
      /// Initialize the iterator to be invalid
  | 
| 
marci@174
 | 
   106  | 
      EdgeIt(Invalid) {}
 | 
| 
alpar@163
 | 
   107  | 
      EdgeIt(const EmptyGraph &) {}
 | 
| 
alpar@163
 | 
   108  | 
    };
  | 
| 
alpar@163
 | 
   109  | 
  | 
| 
alpar@163
 | 
   110  | 
    /// First node of the graph.
  | 
| 
alpar@163
 | 
   111  | 
  | 
| 
alpar@163
 | 
   112  | 
    /// \post \c i and the return value will be the first node.
  | 
| 
alpar@163
 | 
   113  | 
    ///
  | 
| 
alpar@163
 | 
   114  | 
    NodeIt &first(NodeIt &i) const { return i;}
 | 
| 
alpar@163
 | 
   115  | 
  | 
| 
alpar@163
 | 
   116  | 
    /// The first outgoing edge.
  | 
| 
alpar@163
 | 
   117  | 
    InEdgeIt &first(InEdgeIt &i, Node n) const { return i;}
 | 
| 
alpar@163
 | 
   118  | 
    /// The first incoming edge.
  | 
| 
alpar@163
 | 
   119  | 
    OutEdgeIt &first(OutEdgeIt &i, Node n) const { return i;}
 | 
| 
alpar@163
 | 
   120  | 
    //  SymEdgeIt &first(SymEdgeIt &, Node) const { return i;}
 | 
| 
alpar@163
 | 
   121  | 
    /// The first edge of the Graph.
  | 
| 
alpar@163
 | 
   122  | 
    EdgeIt &first(EdgeIt &i) const { return i;}
 | 
| 
alpar@163
 | 
   123  | 
  | 
| 
alpar@163
 | 
   124  | 
//     Node getNext(Node) const {}
 | 
| 
alpar@163
 | 
   125  | 
//     InEdgeIt getNext(InEdgeIt) const {}
 | 
| 
alpar@163
 | 
   126  | 
//     OutEdgeIt getNext(OutEdgeIt) const {}
 | 
| 
alpar@163
 | 
   127  | 
//     //SymEdgeIt getNext(SymEdgeIt) const {}
 | 
| 
alpar@163
 | 
   128  | 
//     EdgeIt getNext(EdgeIt) const {}
 | 
| 
alpar@163
 | 
   129  | 
  | 
| 
alpar@163
 | 
   130  | 
    /// Go to the next node.
  | 
| 
alpar@163
 | 
   131  | 
    Node &next(Node &i) const { return i;}
 | 
| 
alpar@163
 | 
   132  | 
    /// Go to the next incoming edge.
  | 
| 
alpar@163
 | 
   133  | 
    InEdgeIt &next(InEdgeIt &i) const { return i;}
 | 
| 
alpar@163
 | 
   134  | 
    /// Go to the next outgoing edge.
  | 
| 
alpar@163
 | 
   135  | 
    OutEdgeIt &next(OutEdgeIt &i) const { return i;}
 | 
| 
alpar@163
 | 
   136  | 
    //SymEdgeIt &next(SymEdgeIt &) const {}
 | 
| 
alpar@163
 | 
   137  | 
    /// Go to the next edge.
  | 
| 
alpar@163
 | 
   138  | 
    EdgeIt &next(EdgeIt &i) const { return i;}
 | 
| 
alpar@163
 | 
   139  | 
  | 
| 
alpar@163
 | 
   140  | 
    ///Gives back the head node of an edge.
  | 
| 
alpar@163
 | 
   141  | 
    Node head(Edge) const { return INVALID; }
 | 
| 
alpar@163
 | 
   142  | 
    ///Gives back the tail node of an edge.
  | 
| 
alpar@163
 | 
   143  | 
    Node tail(Edge) const { return INVALID; }
 | 
| 
alpar@52
 | 
   144  | 
  
  | 
| 
alpar@163
 | 
   145  | 
    //   Node aNode(InEdgeIt) const {}
 | 
| 
alpar@163
 | 
   146  | 
    //   Node aNode(OutEdgeIt) const {}
 | 
| 
alpar@163
 | 
   147  | 
    //   Node aNode(SymEdgeIt) const {}
 | 
| 
alpar@163
 | 
   148  | 
  | 
| 
alpar@163
 | 
   149  | 
    //   Node bNode(InEdgeIt) const {}
 | 
| 
alpar@163
 | 
   150  | 
    //   Node bNode(OutEdgeIt) const {}
 | 
| 
alpar@163
 | 
   151  | 
    //   Node bNode(SymEdgeIt) const {}
 | 
| 
alpar@163
 | 
   152  | 
  | 
| 
alpar@163
 | 
   153  | 
    /// Checks if a node iterator is valid
  | 
| 
marci@174
 | 
   154  | 
    bool valid(const Node) const { return true;}
 | 
| 
alpar@163
 | 
   155  | 
    /// Checks if an edge iterator is valid
  | 
| 
marci@174
 | 
   156  | 
    bool valid(const Edge) const { return true;}
 | 
| 
alpar@163
 | 
   157  | 
  | 
| 
alpar@163
 | 
   158  | 
    ///Gives back the \e id of a node.
  | 
| 
marci@174
 | 
   159  | 
    int id(const Node) const { return 0;}
 | 
| 
alpar@163
 | 
   160  | 
    ///Gives back the \e id of an edge.
  | 
| 
marci@174
 | 
   161  | 
    int id(const Edge) const { return 0;}
 | 
| 
alpar@163
 | 
   162  | 
  | 
| 
alpar@163
 | 
   163  | 
    //void setInvalid(Node &) const {};
 | 
| 
alpar@163
 | 
   164  | 
    //void setInvalid(Edge &) const {};
 | 
| 
alpar@163
 | 
   165  | 
  
  | 
| 
alpar@163
 | 
   166  | 
    Node addNode() { return INVALID;}
 | 
| 
alpar@163
 | 
   167  | 
    Edge addEdge(Node tail, Node head) { return INVALID;}
 | 
| 
alpar@163
 | 
   168  | 
    
  | 
| 
alpar@163
 | 
   169  | 
    void erase(Node n) {}
 | 
| 
alpar@163
 | 
   170  | 
    void erase(Edge e) {}
 | 
| 
alpar@163
 | 
   171  | 
  | 
| 
alpar@163
 | 
   172  | 
    void clear() {}
 | 
| 
alpar@163
 | 
   173  | 
  | 
| 
alpar@163
 | 
   174  | 
    int nodeNum() { return 0;}
 | 
| 
alpar@163
 | 
   175  | 
    int edgeNum() { return 0;}
 | 
| 
alpar@163
 | 
   176  | 
  | 
| 
marci@174
 | 
   177  | 
    EmptyGraph() {}
 | 
| 
marci@174
 | 
   178  | 
    EmptyGraph(const EmptyGraph &G) {}
 | 
| 
alpar@163
 | 
   179  | 
  
  | 
| 
alpar@163
 | 
   180  | 
  
  | 
| 
alpar@163
 | 
   181  | 
  | 
| 
alpar@163
 | 
   182  | 
    ///Read/write map from the nodes to type \c T.
  | 
| 
alpar@163
 | 
   183  | 
    template<class T> class NodeMap
  | 
| 
alpar@163
 | 
   184  | 
    {
 | 
| 
alpar@163
 | 
   185  | 
    public:
  | 
| 
alpar@163
 | 
   186  | 
      typedef T ValueType;
  | 
| 
alpar@163
 | 
   187  | 
      typedef Node KeyType;
  | 
| 
alpar@163
 | 
   188  | 
  | 
| 
alpar@163
 | 
   189  | 
      NodeMap(const EmptyGraph &G) {}
 | 
| 
alpar@163
 | 
   190  | 
      NodeMap(const EmptyGraph &G, T t) {}
 | 
| 
alpar@163
 | 
   191  | 
  | 
| 
alpar@163
 | 
   192  | 
      void set(Node i, T t) {}
 | 
| 
alpar@163
 | 
   193  | 
      T get(Node i) const {return *(T*)NULL;}  //FIXME: Is it necessary
 | 
| 
alpar@163
 | 
   194  | 
      T &operator[](Node i) {return *(T*)NULL;}
 | 
| 
alpar@163
 | 
   195  | 
      const T &operator[](Node i) const {return *(T*)NULL;}
 | 
| 
alpar@163
 | 
   196  | 
  | 
| 
alpar@163
 | 
   197  | 
      void update() {}
 | 
| 
alpar@163
 | 
   198  | 
      void update(T a) {}   //FIXME: Is it necessary
 | 
| 
alpar@163
 | 
   199  | 
    };
  | 
| 
alpar@163
 | 
   200  | 
  | 
| 
alpar@163
 | 
   201  | 
    ///Read/write map from the edges to type \c T.
  | 
| 
alpar@163
 | 
   202  | 
    template<class T> class EdgeMap
  | 
| 
alpar@163
 | 
   203  | 
    {
 | 
| 
alpar@163
 | 
   204  | 
    public:
  | 
| 
alpar@163
 | 
   205  | 
      typedef T ValueType;
  | 
| 
alpar@163
 | 
   206  | 
      typedef Edge KeyType;
  | 
| 
alpar@163
 | 
   207  | 
  | 
| 
alpar@163
 | 
   208  | 
      EdgeMap(const EmptyGraph &G) {}
 | 
| 
alpar@163
 | 
   209  | 
      EdgeMap(const EmptyGraph &G, T t) {}
 | 
| 
alpar@163
 | 
   210  | 
    
  | 
| 
alpar@163
 | 
   211  | 
      void set(Edge i, T t) {}
 | 
| 
alpar@163
 | 
   212  | 
      T get(Edge i) const {return *(T*)NULL;}
 | 
| 
alpar@163
 | 
   213  | 
      T &operator[](Edge i) {return *(T*)NULL;}
 | 
| 
alpar@163
 | 
   214  | 
    
  | 
| 
alpar@163
 | 
   215  | 
      void update() {}
 | 
| 
alpar@163
 | 
   216  | 
      void update(T a) {}   //FIXME: Is it necessary
 | 
| 
alpar@163
 | 
   217  | 
    };
  | 
| 
alpar@147
 | 
   218  | 
  };
  | 
| 
alpar@52
 | 
   219  | 
  | 
| 
alpar@163
 | 
   220  | 
  // @}
  | 
| 
alpar@147
 | 
   221  | 
  | 
| 
marci@174
 | 
   222  | 
} //namespace hugo
  | 
| 
alpar@52
 | 
   223  | 
  | 
| 
alpar@145
 | 
   224  | 
  | 
| 
alpar@145
 | 
   225  | 
  | 
| 
alpar@147
 | 
   226  | 
// class EmptyBipGraph : public EmptyGraph
  | 
| 
alpar@147
 | 
   227  | 
// {
 | 
| 
alpar@163
 | 
   228  | 
//   class ANode {};
 | 
| 
alpar@163
 | 
   229  | 
//   class BNode {};
 | 
| 
alpar@145
 | 
   230  | 
  | 
| 
alpar@163
 | 
   231  | 
//   ANode &next(ANode &) {}
 | 
| 
alpar@163
 | 
   232  | 
//   BNode &next(BNode &) {}
 | 
| 
alpar@145
 | 
   233  | 
  | 
| 
alpar@163
 | 
   234  | 
//   ANode &getFirst(ANode &) const {}
 | 
| 
alpar@163
 | 
   235  | 
//   BNode &getFirst(BNode &) const {}
 | 
| 
alpar@145
 | 
   236  | 
  | 
| 
alpar@147
 | 
   237  | 
//   enum NodeClass { A = 0, B = 1 };
 | 
| 
alpar@163
 | 
   238  | 
//   NodeClass getClass(Node n) {}
 | 
| 
alpar@147
 | 
   239  | 
  | 
| 
alpar@147
 | 
   240  | 
// }
  | 
| 
marci@174
 | 
   241  | 
  | 
| 
marci@174
 | 
   242  | 
#endif // EMPTYGRAPH_H
  |