# HG changeset patch # User alpar # Date 1079217636 0 # Node ID c59e450712d8a9e8dc152e0565c9c5c64cba5a73 # Parent 96f647f568c718802dcd9eed6dca2f9faf14f4a7 More comments, bug fixes, and copy constructors diff -r 96f647f568c7 -r c59e450712d8 src/work/alpar/emptygraph.h --- a/src/work/alpar/emptygraph.h Fri Mar 12 20:11:31 2004 +0000 +++ b/src/work/alpar/emptygraph.h Sat Mar 13 22:40:36 2004 +0000 @@ -7,7 +7,7 @@ /// The namespace of HugoLib namespace hugo { - // @defgroup empty_graph The EmptyGraph class + // @defgroup empty_graph The GraphSkeleton class // @{ /// An empty graph class. @@ -25,21 +25,36 @@ /// feature, the documentation of a real graph imlementation /// like @ref ListGraph or /// @ref SmartGraph will just refer to this structure. - class EmptyGraph + class GraphSkeleton { public: /// The base type of the node iterators. + + /// This \c Node is the base type of each node iterators, + /// thus each kind of node iterator will convert to this. class Node { public: /// @warning The default constructor sets the iterator /// to an undefined value. Node() {} //FIXME - /// Initialize the iterator to be invalid + /// Invalid constructor \& conversion. + + /// This constructor initializes the iterator to be invalid. + /// \sa Invalid for more details. + Node(Invalid) {} - //Node(const Node &) {} - bool operator==(Node n) const { return true; } //FIXME - bool operator!=(Node n) const { return true; } //FIXME + //Node(const Node &) {} + + /// Two iterators are equal if and only if they point to the + /// same object or both are invalid. + bool operator==(Node n) const { return true; } + + /// \sa \ref operator==(Node n) + /// + bool operator!=(Node n) const { return true; } + + bool operator<(Node n) const { return true; } }; /// This iterator goes through each node. @@ -48,11 +63,16 @@ /// @warning The default constructor sets the iterator /// to an undefined value. NodeIt() {} //FIXME + /// Invalid constructor \& conversion. + /// Initialize the iterator to be invalid + /// \sa Invalid for more details. NodeIt(Invalid) {} /// Sets the iterator to the first node of \c G. - NodeIt(const EmptyGraph &G) {} - NodeIt(const NodeIt &) {} //FIXME + NodeIt(const GraphSkeleton &G) {} + /// @warning The default constructor sets the iterator + /// to an undefined value. + NodeIt(const NodeIt &) {} }; @@ -64,9 +84,11 @@ Edge() {} //FIXME /// Initialize the iterator to be invalid Edge(Invalid) {} - //Edge(const Edge &) {} - bool operator==(Edge n) const { return true; } //FIXME - bool operator!=(Edge n) const { return true; } //FIXME + /// Two iterators are equal if and only if they point to the + /// same object or both are invalid. + bool operator==(Edge n) const { return true; } + bool operator!=(Edge n) const { return true; } + bool operator<(Edge n) const { return true; } }; /// This iterator goes trought the outgoing edges of a certain graph. @@ -84,7 +106,7 @@ /// node ///@param n the node ///@param G the graph - OutEdgeIt(const EmptyGraph & G, Node n) {} + OutEdgeIt(const GraphSkeleton & G, Node n) {} }; class InEdgeIt : public Edge { @@ -94,7 +116,7 @@ InEdgeIt() {} /// Initialize the iterator to be invalid InEdgeIt(Invalid) {} - InEdgeIt(const EmptyGraph &, Node) {} + InEdgeIt(const GraphSkeleton &, Node) {} }; // class SymEdgeIt : public Edge {}; class EdgeIt : public Edge { @@ -104,7 +126,7 @@ EdgeIt() {} /// Initialize the iterator to be invalid EdgeIt(Invalid) {} - EdgeIt(const EmptyGraph &) {} + EdgeIt(const GraphSkeleton &) {} }; /// First node of the graph. @@ -156,61 +178,106 @@ bool valid(const Edge) const { return true;} ///Gives back the \e id of a node. + + ///\warning Not all graph structure provide this feature. + /// int id(const Node) const { return 0;} ///Gives back the \e id of an edge. + + ///\warning Not all graph structure provide this feature. + /// int id(const Edge) const { return 0;} //void setInvalid(Node &) const {}; //void setInvalid(Edge &) const {}; + ///Add a new node to the graph. + + /// \return the new node. Node addNode() { return INVALID;} + ///Add a new edge to the graph. + + ///Add a new edge to the graph with tail node \c tail + ///and head node \c head. + ///\return the new edge. Edge addEdge(Node tail, Node head) { return INVALID;} + /// Deletes a node. + + ///\warning Not all graph structure provide this feature. + /// void erase(Node n) {} + /// Deletes an edge. + + ///\warning Not all graph structure provide this feature. + /// void erase(Edge e) {} + /// Reset the graph. + + /// This function deletes all edges and nodes of the graph. + /// It also frees the memory allocated to store them. void clear() {} int nodeNum() const { return 0;} int edgeNum() const { return 0;} - EmptyGraph() {} - EmptyGraph(const EmptyGraph &G) {} + GraphSkeleton() {} + GraphSkeleton(const GraphSkeleton &G) {} - ///Read/write map from the nodes to type \c T. + ///Read/write map of the nodes to type \c T. + + /// \todo We may need copy constructor + /// \todo We may need conversion from other nodetype + /// \todo We may need operator= + template class NodeMap { public: typedef T ValueType; typedef Node KeyType; - NodeMap(const EmptyGraph &G) {} - NodeMap(const EmptyGraph &G, T t) {} + NodeMap(const GraphSkeleton &G) {} + NodeMap(const GraphSkeleton &G, T t) {} + template NodeMap(const NodeMap &m) {} + + /// Sets the value of a node. + + /// Sets the value associated with node \c i to the value \c t. + /// void set(Node i, T t) {} - T get(Node i) const {return *(T*)NULL;} //FIXME: Is it necessary - T &operator[](Node i) {return *(T*)NULL;} - const T &operator[](Node i) const {return *(T*)NULL;} + /// Gets the value of a node. + T get(Node i) const {return *(T*)0;} //FIXME: Is it necessary + T &operator[](Node i) {return *(T*)0;} + const T &operator[](Node i) const {return *(T*)0;} + /// Updates the map if the graph has been changed + + /// \todo Do we need this? + /// void update() {} void update(T a) {} //FIXME: Is it necessary }; - ///Read/write map from the edges to type \c T. + ///Read/write map of the edges to type \c T. + + ///Read/write map of the edges to type \c T. + ///It behaves exactly the same way as \ref NodeMap. template class EdgeMap { public: typedef T ValueType; typedef Edge KeyType; - EdgeMap(const EmptyGraph &G) {} - EdgeMap(const EmptyGraph &G, T t) {} + EdgeMap(const GraphSkeleton &G) {} + EdgeMap(const GraphSkeleton &G, T t) {} void set(Edge i, T t) {} - T get(Edge i) const {return *(T*)NULL;} - T &operator[](Edge i) {return *(T*)NULL;} + T get(Edge i) const {return *(T*)0;} + T &operator[](Edge i) {return *(T*)0;} void update() {} void update(T a) {} //FIXME: Is it necessary @@ -223,7 +290,7 @@ -// class EmptyBipGraph : public EmptyGraph +// class EmptyBipGraph : public Graph Skeleton // { // class ANode {}; // class BNode {};