# Changeset 2223:590c1b663a27 in lemon-0.x for lemon/hypercube_graph.h

Ignore:
Timestamp:
09/29/06 13:25:27 (16 years ago)
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2963
Message:

Exporting interface to the Graph class
Some documentation improvements

File:
1 edited

### Legend:

Unmodified
 r2207 namespace lemon { /// \brief Base graph for HyperCubeGraph. /// /// Base graph for hyper-cube graph. It describes some member functions /// which can be used in the HyperCubeGraph. /// /// \warning Always use the HyperCubeGraph instead of this. /// \see HyperCubeGraph class HyperCubeGraphBase { protected: /// \brief Creates a hypercube graph with the given size. /// /// Creates a hypercube graph with the given size. void construct(int dim) { _dim = dim; typedef True EdgeNumTag; ///Number of nodes. int nodeNum() const { return _nodeNum; } ///Number of edges. int edgeNum() const { return _nodeNum * _dim; } /// Maximum node ID. /// Maximum node ID. ///\sa id(Node) int maxNodeId() const { return nodeNum() - 1; } /// Maximum edge ID. /// Maximum edge ID. ///\sa id(Edge) int maxEdgeId() const { return edgeNum() - 1; } /// \brief Gives back the source node of an edge. /// /// Gives back the source node of an edge. Node source(Edge e) const { return e.id / _dim; } /// \brief Gives back the target node of an edge. /// /// Gives back the target node of an edge. Node target(Edge e) const { return (e.id / _dim) ^ ( 1 << (e.id % _dim)); } /// Node ID. /// The ID of a valid Node is a nonnegative integer not greater than /// \ref maxNodeId(). The range of the ID's is not surely continuous /// and the greatest node ID can be actually less then \ref maxNodeId(). /// /// The ID of the \ref INVALID node is -1. ///\return The ID of the node \c v. static int id(Node v) { return v.id; } /// Edge ID. /// The ID of a valid Edge is a nonnegative integer not greater than /// \ref maxEdgeId(). The range of the ID's is not surely continuous /// and the greatest edge ID can be actually less then \ref maxEdgeId(). /// /// The ID of the \ref INVALID edge is -1. ///\return The ID of the edge \c e. static int id(Edge e) { return e.id; } } /// \brief Gives back the number of the dimensions. /// /// Gives back the number of the dimensions. int dimension() const { return _dim; } /// \brief Returns true if the n'th bit of the node is one. /// /// Returns true if the n'th bit of the node is one. bool projection(Node node, int n) const { return (bool)(node.id & (1 << n)); } /// \brief The dimension id of the edge. /// /// It returns the dimension id of the edge. It can /// be in the ${0, 1, dim-1}$ intervall. int dimension(Edge edge) const { return edge.id % _dim; } /// \brief Gives back the index of the node. /// /// Gives back the index of the node. The lower bits of the /// integer describe the node. int index(Node node) const { return node.id; } /// \brief Gives back the node by its index. /// ///  Gives back the node by its index. Node operator()(int index) const { return Node(index); /// concept but it does not conform to the \ref concept::UGraph. /// /// \see HyperCubeGraphBase /// \author Balazs Dezso class HyperCubeGraph : public ExtendedHyperCubeGraphBase { public: typedef ExtendedHyperCubeGraphBase Parent; /// \brief Construct a graph with \c dim dimension. /// /// Construct a graph with \c dim dimension. HyperCubeGraph(int dim) { construct(dim); } /// \brief Gives back the number of the dimensions. /// /// Gives back the number of the dimensions. int dimension() const { return Parent::dimension(); } /// \brief Returns true if the n'th bit of the node is one. /// /// Returns true if the n'th bit of the node is one. bool projection(Node node, int n) const { return Parent::projection(node, n); } /// \brief The dimension id of the edge. /// /// It returns the dimension id of the edge. It can /// be in the \f$\{0, 1, \dots, dim-1\} \f$ intervall. int dimension(Edge edge) const { return Parent::dimension(edge); } /// \brief Gives back the index of the node. /// /// Gives back the index of the node. The lower bits of the /// integer describes the node. int index(Node node) const { return Parent::index(node); } /// \brief Gives back the node by its index. /// /// Gives back the node by its index. Node operator()(int index) const { return Parent::operator()(index); } /// \brief Number of nodes. int nodeNum() const { return Parent::nodeNum(); } /// \brief Number of edges. int edgeNum() const { return Parent::edgeNum(); } /// \brief Linear combination map.