alpar@52: // -*-mode: c++; -*- alpar@52: alpar@163: #include alpar@145: alpar@163: /// The namespace of HugoLib alpar@163: namespace hugo { alpar@163: alpar@163: // @defgroup empty_graph The EmptyGraph class alpar@163: // @{ alpar@163: alpar@163: /// An empty graph class. alpar@163: alpar@163: /// This class provides all the common features of a grapf structure, alpar@163: /// however completely without implementations or real data structures alpar@163: /// behind the interface. alpar@163: /// All graph algorithms should compile with this class, but it will not alpar@163: /// run properly, of course. alpar@163: /// alpar@163: /// It can be used for checking the interface compatibility, alpar@163: /// or it can serve as a skeleton of a new graph structure. alpar@163: alpar@163: class EmptyGraph alpar@163: { alpar@147: public: alpar@147: alpar@163: /// The base type of the node iterators. alpar@163: class Node { alpar@163: public: alpar@163: /// @warning The default constructor sets the iterator alpar@163: /// to an undefined value. alpar@163: Node() {} //FIXME alpar@163: /// Initialize the iterator to be invalid alpar@163: Node(Invalid) {}; alpar@163: //Node(const Node &) {} alpar@163: bool operator==(Node n) const { return true; } //FIXME alpar@163: bool operator!=(Node n) const { return true; } //FIXME alpar@163: }; alpar@147: alpar@163: /// This iterator goes through each node. alpar@163: class NodeIt : public Node { alpar@163: public: alpar@163: /// @warning The default constructor sets the iterator alpar@163: /// to an undefined value. alpar@163: NodeIt() {} //FIXME alpar@163: /// Initialize the iterator to be invalid alpar@163: NodeIt(Invalid) {}; alpar@163: /// Sets the iterator to the first node of \c G. alpar@163: NodeIt(const EmptyGraph &G) {} alpar@163: NodeIt(const NodeIt &) {} //FIXME alpar@163: }; alpar@163: alpar@163: alpar@163: /// The base type of the edge iterators. alpar@163: class Edge { alpar@163: public: alpar@163: /// @warning The default constructor sets the iterator alpar@163: /// to an undefined value. alpar@163: Edge() {} //FIXME alpar@163: /// Initialize the iterator to be invalid alpar@163: Edge(Invalid) {}; alpar@163: //Edge(const Edge &) {} alpar@163: bool operator==(Edge n) const { return true; } //FIXME alpar@163: bool operator!=(Edge n) const { return true; } //FIXME alpar@163: }; alpar@163: alpar@163: /// This iterator goes trought the outgoing edges of a certain graph. alpar@163: alpar@163: class OutEdgeIt : public Edge { alpar@163: public: alpar@163: /// @warning The default constructor sets the iterator alpar@163: /// to an undefined value. alpar@163: OutEdgeIt() {} alpar@163: /// Initialize the iterator to be invalid alpar@163: OutEdgeIt(Invalid) {}; alpar@163: /// This constructor sets the iterator to first outgoing edge. alpar@163: alpar@163: /// This constructor set the iterator to the first outgoing edge of alpar@163: /// node alpar@163: ///@param n the node alpar@163: ///@param G the graph alpar@163: OutEdgeIt(const EmptyGraph & G, Node n) {} alpar@163: }; alpar@163: alpar@163: class InEdgeIt : public Edge { alpar@163: public: alpar@163: /// @warning The default constructor sets the iterator alpar@163: /// to an undefined value. alpar@163: InEdgeIt() {} alpar@163: /// Initialize the iterator to be invalid alpar@163: InEdgeIt(Invalid) {}; alpar@163: InEdgeIt(const EmptyGraph &, Node) {} alpar@163: }; alpar@163: // class SymEdgeIt : public Edge {}; alpar@163: class EdgeIt : public Edge { alpar@163: public: alpar@163: /// @warning The default constructor sets the iterator alpar@163: /// to an undefined value. alpar@163: EdgeIt() {} alpar@163: /// Initialize the iterator to be invalid alpar@163: EdgeIt(Invalid) {}; alpar@163: EdgeIt(const EmptyGraph &) {} alpar@163: }; alpar@163: alpar@163: /// First node of the graph. alpar@163: alpar@163: /// \post \c i and the return value will be the first node. alpar@163: /// alpar@163: NodeIt &first(NodeIt &i) const { return i;} alpar@163: alpar@163: /// The first outgoing edge. alpar@163: InEdgeIt &first(InEdgeIt &i, Node n) const { return i;} alpar@163: /// The first incoming edge. alpar@163: OutEdgeIt &first(OutEdgeIt &i, Node n) const { return i;} alpar@163: // SymEdgeIt &first(SymEdgeIt &, Node) const { return i;} alpar@163: /// The first edge of the Graph. alpar@163: EdgeIt &first(EdgeIt &i) const { return i;} alpar@163: alpar@163: // Node getNext(Node) const {} alpar@163: // InEdgeIt getNext(InEdgeIt) const {} alpar@163: // OutEdgeIt getNext(OutEdgeIt) const {} alpar@163: // //SymEdgeIt getNext(SymEdgeIt) const {} alpar@163: // EdgeIt getNext(EdgeIt) const {} alpar@163: alpar@163: /// Go to the next node. alpar@163: Node &next(Node &i) const { return i;} alpar@163: /// Go to the next incoming edge. alpar@163: InEdgeIt &next(InEdgeIt &i) const { return i;} alpar@163: /// Go to the next outgoing edge. alpar@163: OutEdgeIt &next(OutEdgeIt &i) const { return i;} alpar@163: //SymEdgeIt &next(SymEdgeIt &) const {} alpar@163: /// Go to the next edge. alpar@163: EdgeIt &next(EdgeIt &i) const { return i;} alpar@163: alpar@163: ///Gives back the head node of an edge. alpar@163: Node head(Edge) const { return INVALID; } alpar@163: ///Gives back the tail node of an edge. alpar@163: Node tail(Edge) const { return INVALID; } alpar@52: alpar@163: // Node aNode(InEdgeIt) const {} alpar@163: // Node aNode(OutEdgeIt) const {} alpar@163: // Node aNode(SymEdgeIt) const {} alpar@163: alpar@163: // Node bNode(InEdgeIt) const {} alpar@163: // Node bNode(OutEdgeIt) const {} alpar@163: // Node bNode(SymEdgeIt) const {} alpar@163: alpar@163: /// Checks if a node iterator is valid alpar@163: bool valid(const Node) const { return true;}; alpar@163: /// Checks if an edge iterator is valid alpar@163: bool valid(const Edge) const { return true;}; alpar@163: alpar@163: ///Gives back the \e id of a node. alpar@163: int id(const Node) const { return 0;}; alpar@163: ///Gives back the \e id of an edge. alpar@163: int id(const Edge) const { return 0;}; alpar@163: alpar@163: //void setInvalid(Node &) const {}; alpar@163: //void setInvalid(Edge &) const {}; alpar@163: alpar@163: Node addNode() { return INVALID;} alpar@163: Edge addEdge(Node tail, Node head) { return INVALID;} alpar@163: alpar@163: void erase(Node n) {} alpar@163: void erase(Edge e) {} alpar@163: alpar@163: void clear() {} alpar@163: alpar@163: int nodeNum() { return 0;} alpar@163: int edgeNum() { return 0;} alpar@163: alpar@163: EmptyGraph() {}; alpar@163: EmptyGraph(const EmptyGraph &G) {}; alpar@163: alpar@163: alpar@163: alpar@163: ///Read/write map from the nodes to type \c T. alpar@163: template class NodeMap alpar@163: { alpar@163: public: alpar@163: typedef T ValueType; alpar@163: typedef Node KeyType; alpar@163: alpar@163: NodeMap(const EmptyGraph &G) {} alpar@163: NodeMap(const EmptyGraph &G, T t) {} alpar@163: alpar@163: void set(Node i, T t) {} alpar@163: T get(Node i) const {return *(T*)NULL;} //FIXME: Is it necessary alpar@163: T &operator[](Node i) {return *(T*)NULL;} alpar@163: const T &operator[](Node i) const {return *(T*)NULL;} alpar@163: alpar@163: void update() {} alpar@163: void update(T a) {} //FIXME: Is it necessary alpar@163: }; alpar@163: alpar@163: ///Read/write map from the edges to type \c T. alpar@163: template class EdgeMap alpar@163: { alpar@163: public: alpar@163: typedef T ValueType; alpar@163: typedef Edge KeyType; alpar@163: alpar@163: EdgeMap(const EmptyGraph &G) {} alpar@163: EdgeMap(const EmptyGraph &G, T t) {} alpar@163: alpar@163: void set(Edge i, T t) {} alpar@163: T get(Edge i) const {return *(T*)NULL;} alpar@163: T &operator[](Edge i) {return *(T*)NULL;} alpar@163: alpar@163: void update() {} alpar@163: void update(T a) {} //FIXME: Is it necessary alpar@163: }; alpar@147: }; alpar@52: alpar@163: // @} alpar@147: alpar@163: }; alpar@52: alpar@145: alpar@145: alpar@147: // class EmptyBipGraph : public EmptyGraph alpar@147: // { alpar@163: // class ANode {}; alpar@163: // class BNode {}; alpar@145: alpar@163: // ANode &next(ANode &) {} alpar@163: // BNode &next(BNode &) {} alpar@145: alpar@163: // ANode &getFirst(ANode &) const {} alpar@163: // BNode &getFirst(BNode &) const {} alpar@145: alpar@147: // enum NodeClass { A = 0, B = 1 }; alpar@163: // NodeClass getClass(Node n) {} alpar@147: alpar@147: // }