1.1 --- a/doc/Doxyfile Wed Apr 14 16:16:40 2004 +0000
1.2 +++ b/doc/Doxyfile Wed Apr 14 20:57:58 2004 +0000
1.3 @@ -400,6 +400,7 @@
1.4 ../src/include/fib_heap.h \
1.5 ../src/work/athos/xy/xy.h \
1.6 ../src/work/athos/minlengthpaths.h \
1.7 + ../src/work/marci/graph_concept.h \
1.8 maps.dox
1.9
1.10 # If the value of the INPUT tag contains directories, you can use the
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/src/work/marci/graph_concept.h Wed Apr 14 20:57:58 2004 +0000
2.3 @@ -0,0 +1,422 @@
2.4 +// -*- c++ -*-
2.5 +#ifndef HUGO_GRAPH_H
2.6 +#define HUGO_GRAPH_H
2.7 +
2.8 +///\file
2.9 +///\brief Declaration of GraphSkeleton.
2.10 +
2.11 +#include <invalid.h>
2.12 +
2.13 +/// The namespace of HugoLib
2.14 +namespace hugo {
2.15 +
2.16 + // @defgroup empty_graph The GraphSkeleton class
2.17 + // @{
2.18 +
2.19 + /// An empty graph class.
2.20 +
2.21 + /// This class provides all the common features of a graph structure,
2.22 + /// however completely without implementations and real data structures
2.23 + /// behind the interface.
2.24 + /// All graph algorithms should compile with this class, but it will not
2.25 + /// run properly, of course.
2.26 + ///
2.27 + /// It can be used for checking the interface compatibility,
2.28 + /// or it can serve as a skeleton of a new graph structure.
2.29 + ///
2.30 + /// Also, you will find here the full documentation of a certain graph
2.31 + /// feature, the documentation of a real graph imlementation
2.32 + /// like @ref ListGraph or
2.33 + /// @ref SmartGraph will just refer to this structure.
2.34 + class GraphSkeleton
2.35 + {
2.36 + public:
2.37 + /// Defalult constructor.
2.38 + GraphSkeleton() {}
2.39 + ///Copy consructor.
2.40 +
2.41 + ///\todo It is not clear, what we expect from a copy constructor.
2.42 + ///E.g. How to assign the nodes/edges to each other? What about maps?
2.43 + GraphSkeleton(const GraphSkeleton &G) {}
2.44 +
2.45 + /// The base type of the node iterators.
2.46 +
2.47 + /// This is the base type of each node iterators,
2.48 + /// thus each kind of node iterator will convert to this.
2.49 + class Node {
2.50 + public:
2.51 + /// @warning The default constructor sets the iterator
2.52 + /// to an undefined value.
2.53 + Node() {} //FIXME
2.54 + /// Invalid constructor \& conversion.
2.55 +
2.56 + /// This constructor initializes the iterator to be invalid.
2.57 + /// \sa Invalid for more details.
2.58 +
2.59 + Node(Invalid) {}
2.60 + //Node(const Node &) {}
2.61 +
2.62 + /// Two iterators are equal if and only if they point to the
2.63 + /// same object or both are invalid.
2.64 + bool operator==(Node n) const { return true; }
2.65 +
2.66 + /// \sa \ref operator==(Node n)
2.67 + ///
2.68 + bool operator!=(Node n) const { return true; }
2.69 +
2.70 + bool operator<(Node n) const { return true; }
2.71 + };
2.72 +
2.73 + /// This iterator goes through each node.
2.74 +
2.75 + /// This iterator goes through each node.
2.76 + /// Its usage is quite simple, for example you can count the number
2.77 + /// of nodes in graph \c G of type \c Graph like this:
2.78 + /// \code
2.79 + ///int count=0;
2.80 + ///for(Graph::NodeIt n(G);G.valid(n);G.next(n)) count++;
2.81 + /// \endcode
2.82 + class NodeIt : public Node {
2.83 + public:
2.84 + /// @warning The default constructor sets the iterator
2.85 + /// to an undefined value.
2.86 + NodeIt() {} //FIXME
2.87 + /// Invalid constructor \& conversion.
2.88 +
2.89 + /// Initialize the iterator to be invalid
2.90 + /// \sa Invalid for more details.
2.91 + NodeIt(Invalid) {}
2.92 + /// Sets the iterator to the first node of \c G.
2.93 + NodeIt(const GraphSkeleton &G) {}
2.94 + /// @warning The default constructor sets the iterator
2.95 + /// to an undefined value.
2.96 + NodeIt(const NodeIt &) {}
2.97 + };
2.98 +
2.99 +
2.100 + /// The base type of the edge iterators.
2.101 + class Edge {
2.102 + public:
2.103 + /// @warning The default constructor sets the iterator
2.104 + /// to an undefined value.
2.105 + Edge() {} //FIXME
2.106 + /// Initialize the iterator to be invalid
2.107 + Edge(Invalid) {}
2.108 + /// Two iterators are equal if and only if they point to the
2.109 + /// same object or both are invalid.
2.110 + bool operator==(Edge n) const { return true; }
2.111 + bool operator!=(Edge n) const { return true; }
2.112 + bool operator<(Edge n) const { return true; }
2.113 + };
2.114 +
2.115 + /// This iterator goes trough the outgoing edges of a node.
2.116 +
2.117 + /// This iterator goes trough the \e outgoing edges of a certain node
2.118 + /// of a graph.
2.119 + /// Its usage is quite simple, for example you can count the number
2.120 + /// of outgoing edges of a node \c n
2.121 + /// in graph \c G of type \c Graph as follows.
2.122 + /// \code
2.123 + ///int count=0;
2.124 + ///for(Graph::OutEdgeIt e(G,n);G.valid(e);G.next(e)) count++;
2.125 + /// \endcode
2.126 +
2.127 + class OutEdgeIt : public Edge {
2.128 + public:
2.129 + /// @warning The default constructor sets the iterator
2.130 + /// to an undefined value.
2.131 + OutEdgeIt() {}
2.132 + /// Initialize the iterator to be invalid
2.133 + OutEdgeIt(Invalid) {}
2.134 + /// This constructor sets the iterator to first outgoing edge.
2.135 +
2.136 + /// This constructor set the iterator to the first outgoing edge of
2.137 + /// node
2.138 + ///@param n the node
2.139 + ///@param G the graph
2.140 + OutEdgeIt(const GraphSkeleton & G, Node n) {}
2.141 + };
2.142 +
2.143 + /// This iterator goes trough the incoming edges of a node.
2.144 +
2.145 + /// This iterator goes trough the \e incoming edges of a certain node
2.146 + /// of a graph.
2.147 + /// Its usage is quite simple, for example you can count the number
2.148 + /// of outgoing edges of a node \c n
2.149 + /// in graph \c G of type \c Graph as follows.
2.150 + /// \code
2.151 + ///int count=0;
2.152 + ///for(Graph::InEdgeIt e(G,n);G.valid(e);G.next(e)) count++;
2.153 + /// \endcode
2.154 +
2.155 + class InEdgeIt : public Edge {
2.156 + public:
2.157 + /// @warning The default constructor sets the iterator
2.158 + /// to an undefined value.
2.159 + InEdgeIt() {}
2.160 + /// Initialize the iterator to be invalid
2.161 + InEdgeIt(Invalid) {}
2.162 + InEdgeIt(const GraphSkeleton &, Node) {}
2.163 + };
2.164 + // class SymEdgeIt : public Edge {};
2.165 +
2.166 + /// This iterator goes through each edge.
2.167 +
2.168 + /// This iterator goes through each edge of a graph.
2.169 + /// Its usage is quite simple, for example you can count the number
2.170 + /// of edges in a graph \c G of type \c Graph as follows:
2.171 + /// \code
2.172 + ///int count=0;
2.173 + ///for(Graph::EdgeIt e(G);G.valid(e);G.next(e)) count++;
2.174 + /// \endcode
2.175 + class EdgeIt : public Edge {
2.176 + public:
2.177 + /// @warning The default constructor sets the iterator
2.178 + /// to an undefined value.
2.179 + EdgeIt() {}
2.180 + /// Initialize the iterator to be invalid
2.181 + EdgeIt(Invalid) {}
2.182 + EdgeIt(const GraphSkeleton &) {}
2.183 + };
2.184 +
2.185 + /// First node of the graph.
2.186 +
2.187 + /// \post \c i and the return value will be the first node.
2.188 + ///
2.189 + NodeIt &first(NodeIt &i) const { return i;}
2.190 +
2.191 + /// The first incoming edge.
2.192 + InEdgeIt &first(InEdgeIt &i, Node n) const { return i;}
2.193 + /// The first outgoing edge.
2.194 + OutEdgeIt &first(OutEdgeIt &i, Node n) const { return i;}
2.195 + // SymEdgeIt &first(SymEdgeIt &, Node) const { return i;}
2.196 + /// The first edge of the Graph.
2.197 + EdgeIt &first(EdgeIt &i) const { return i;}
2.198 +
2.199 +// Node getNext(Node) const {}
2.200 +// InEdgeIt getNext(InEdgeIt) const {}
2.201 +// OutEdgeIt getNext(OutEdgeIt) const {}
2.202 +// //SymEdgeIt getNext(SymEdgeIt) const {}
2.203 +// EdgeIt getNext(EdgeIt) const {}
2.204 +
2.205 + /// Go to the next node.
2.206 + NodeIt &next(NodeIt &i) const { return i;}
2.207 + /// Go to the next incoming edge.
2.208 + InEdgeIt &next(InEdgeIt &i) const { return i;}
2.209 + /// Go to the next outgoing edge.
2.210 + OutEdgeIt &next(OutEdgeIt &i) const { return i;}
2.211 + //SymEdgeIt &next(SymEdgeIt &) const {}
2.212 + /// Go to the next edge.
2.213 + EdgeIt &next(EdgeIt &i) const { return i;}
2.214 +
2.215 + ///Gives back the head node of an edge.
2.216 + Node head(Edge) const { return INVALID; }
2.217 + ///Gives back the tail node of an edge.
2.218 + Node tail(Edge) const { return INVALID; }
2.219 +
2.220 + // Node aNode(InEdgeIt) const {}
2.221 + // Node aNode(OutEdgeIt) const {}
2.222 + // Node aNode(SymEdgeIt) const {}
2.223 +
2.224 + // Node bNode(InEdgeIt) const {}
2.225 + // Node bNode(OutEdgeIt) const {}
2.226 + // Node bNode(SymEdgeIt) const {}
2.227 +
2.228 + /// Checks if a node iterator is valid
2.229 +
2.230 + ///\todo Maybe, it would be better if iterator converted to
2.231 + ///bool directly, as Jacint prefers.
2.232 + bool valid(const Node&) const { return true;}
2.233 + /// Checks if an edge iterator is valid
2.234 +
2.235 + ///\todo Maybe, it would be better if iterator converted to
2.236 + ///bool directly, as Jacint prefers.
2.237 + bool valid(const Edge&) const { return true;}
2.238 +
2.239 + ///Gives back the \e id of a node.
2.240 +
2.241 + ///\warning Not all graph structures provide this feature.
2.242 + ///
2.243 + int id(const Node&) const { return 0;}
2.244 + ///Gives back the \e id of an edge.
2.245 +
2.246 + ///\warning Not all graph structures provide this feature.
2.247 + ///
2.248 + int id(const Edge&) const { return 0;}
2.249 +
2.250 + //void setInvalid(Node &) const {};
2.251 + //void setInvalid(Edge &) const {};
2.252 +
2.253 + ///Add a new node to the graph.
2.254 +
2.255 + /// \return the new node.
2.256 + ///
2.257 + Node addNode() { return INVALID;}
2.258 + ///Add a new edge to the graph.
2.259 +
2.260 + ///Add a new edge to the graph with tail node \c tail
2.261 + ///and head node \c head.
2.262 + ///\return the new edge.
2.263 + Edge addEdge(Node tail, Node head) { return INVALID;}
2.264 +
2.265 + /// Resets the graph.
2.266 +
2.267 + /// This function deletes all edges and nodes of the graph.
2.268 + /// It also frees the memory allocated to store them.
2.269 + void clear() {}
2.270 +
2.271 + ///Read/write/reference map of the nodes to type \c T.
2.272 +
2.273 + ///Read/write/reference map of the nodes to type \c T.
2.274 + /// \sa MemoryMapSkeleton
2.275 + /// \todo We may need copy constructor
2.276 + /// \todo We may need conversion from other nodetype
2.277 + /// \todo We may need operator=
2.278 + /// \warning Making maps that can handle bool type (NodeMap<bool>)
2.279 + /// needs extra attention!
2.280 +
2.281 + template<class T> class NodeMap
2.282 + {
2.283 + public:
2.284 + typedef T ValueType;
2.285 + typedef Node KeyType;
2.286 +
2.287 + NodeMap(const GraphSkeleton &G) {}
2.288 + NodeMap(const GraphSkeleton &G, T t) {}
2.289 +
2.290 + template<typename TT> NodeMap(const NodeMap<TT> &m) {}
2.291 +
2.292 + /// Sets the value of a node.
2.293 +
2.294 + /// Sets the value associated with node \c i to the value \c t.
2.295 + ///
2.296 + void set(Node i, T t) {}
2.297 + /// Gets the value of a node.
2.298 + T get(Node i) const {return *(T*)0;} //FIXME: Is it necessary
2.299 + T &operator[](Node i) {return *(T*)0;}
2.300 + const T &operator[](Node i) const {return *(T*)0;}
2.301 +
2.302 + /// Updates the map if the graph has been changed
2.303 +
2.304 + /// \todo Do we need this?
2.305 + ///
2.306 + void update() {}
2.307 + void update(T a) {} //FIXME: Is it necessary
2.308 + };
2.309 +
2.310 + ///Read/write/reference map of the edges to type \c T.
2.311 +
2.312 + ///Read/write/reference map of the edges to type \c T.
2.313 + ///It behaves exactly in the same way as \ref NodeMap.
2.314 + /// \sa NodeMap
2.315 + /// \sa MemoryMapSkeleton
2.316 + /// \todo We may need copy constructor
2.317 + /// \todo We may need conversion from other edgetype
2.318 + /// \todo We may need operator=
2.319 + template<class T> class EdgeMap
2.320 + {
2.321 + public:
2.322 + typedef T ValueType;
2.323 + typedef Edge KeyType;
2.324 +
2.325 + EdgeMap(const GraphSkeleton &G) {}
2.326 + EdgeMap(const GraphSkeleton &G, T t) {}
2.327 +
2.328 + void set(Edge i, T t) {}
2.329 + T get(Edge i) const {return *(T*)0;}
2.330 + T &operator[](Edge i) {return *(T*)0;}
2.331 +
2.332 + void update() {}
2.333 + void update(T a) {} //FIXME: Is it necessary
2.334 + };
2.335 + };
2.336 +
2.337 + /// An empty eraseable graph class.
2.338 +
2.339 + /// This class provides all the common features of an \e eraseable graph
2.340 + /// structure,
2.341 + /// however completely without implementations and real data structures
2.342 + /// behind the interface.
2.343 + /// All graph algorithms should compile with this class, but it will not
2.344 + /// run properly, of course.
2.345 + ///
2.346 + /// \todo This blabla could be replaced by a sepatate description about
2.347 + /// Skeletons.
2.348 + ///
2.349 + /// It can be used for checking the interface compatibility,
2.350 + /// or it can serve as a skeleton of a new graph structure.
2.351 + ///
2.352 + /// Also, you will find here the full documentation of a certain graph
2.353 + /// feature, the documentation of a real graph imlementation
2.354 + /// like @ref ListGraph or
2.355 + /// @ref SmartGraph will just refer to this structure.
2.356 + class EraseableGraphSkeleton : public GraphSkeleton
2.357 + {
2.358 + public:
2.359 + /// Deletes a node.
2.360 + void erase(Node n) {}
2.361 + /// Deletes an edge.
2.362 + void erase(Edge e) {}
2.363 +
2.364 + /// Defalult constructor.
2.365 + GraphSkeleton() {}
2.366 + ///Copy consructor.
2.367 + GraphSkeleton(const GraphSkeleton &G) {}
2.368 + };
2.369 +
2.370 +
2.371 + // @}
2.372 +
2.373 +
2.374 + /// An empty graph class which provides a function to get the number
2.375 + /// of its nodes.
2.376 +
2.377 + /// This graph class provides a function for getting the number of its
2.378 + /// nodes.
2.379 + /// Clearly, for physical graph structures it can be expected to have such a
2.380 + /// function. For wrappers or graphs which are given in an implicit way,
2.381 + /// the implementation can be circumstantial, that is why this composes a
2.382 + /// separate concept.
2.383 + class NodeCountingGraphSkeleton
2.384 + {
2.385 + public:
2.386 + /// Returns the number of nodes.
2.387 + int nodeNum() const { return 0;}
2.388 + };
2.389 +
2.390 + /// An empty graph class which provides a function to get the number of its
2.391 + /// edges.
2.392 +
2.393 + /// This graph class provides a function for getting the number of its
2.394 + /// edges.
2.395 + /// Clearly, for physical graph structures it can be expected to have such a
2.396 + /// function. For wrappers or graphs which are given in an implicit way,
2.397 + /// the implementation can be circumstantial, that is why this composes a
2.398 + /// separate concept.
2.399 + class EdgeCountingGraphSkeleton
2.400 + {
2.401 + public:
2.402 + /// Returns the number of edges.
2.403 + int edgeNum() const { return 0;}
2.404 + };
2.405 +
2.406 +} //namespace hugo
2.407 +
2.408 +
2.409 +// class EmptyBipGraph : public Graph Skeleton
2.410 +// {
2.411 +// class ANode {};
2.412 +// class BNode {};
2.413 +
2.414 +// ANode &next(ANode &) {}
2.415 +// BNode &next(BNode &) {}
2.416 +
2.417 +// ANode &getFirst(ANode &) const {}
2.418 +// BNode &getFirst(BNode &) const {}
2.419 +
2.420 +// enum NodeClass { A = 0, B = 1 };
2.421 +// NodeClass getClass(Node n) {}
2.422 +
2.423 +// }
2.424 +
2.425 +#endif // HUGO_GRAPH_H