1.1 --- a/lemon/static_graph.h Tue Aug 25 16:32:47 2009 +0200
1.2 +++ b/lemon/static_graph.h Tue Sep 29 10:39:20 2009 +0200
1.3 @@ -239,6 +239,14 @@
1.4 /// However it only provides build() and clear() functions and does not
1.5 /// support any other modification of the digraph.
1.6 ///
1.7 + /// Since this digraph structure is completely static, its nodes and arcs
1.8 + /// can be indexed with integers from the ranges <tt>[0..nodeNum()-1]</tt>
1.9 + /// and <tt>[0..arcNum()-1]</tt>, respectively.
1.10 + /// The index of an item is the same as its ID, it can be obtained
1.11 + /// using the corresponding \ref index() or \ref concepts::Digraph::id()
1.12 + /// "id()" function. A node or arc with a certain index can be obtained
1.13 + /// using node() or arc().
1.14 + ///
1.15 /// This type fully conforms to the \ref concepts::Digraph "Digraph concept".
1.16 /// Most of its member functions and nested classes are documented
1.17 /// only in the concept class.
1.18 @@ -251,13 +259,45 @@
1.19
1.20 public:
1.21
1.22 - /// \brief Clear the digraph.
1.23 + /// \brief Constructor
1.24 ///
1.25 - /// This function erases all nodes and arcs from the digraph.
1.26 - void clear() {
1.27 - Parent::clear();
1.28 - }
1.29 -
1.30 + /// Default constructor.
1.31 + StaticDigraph() : Parent() {}
1.32 +
1.33 + /// \brief The node with the given index.
1.34 + ///
1.35 + /// This function returns the node with the given index.
1.36 + /// \sa index()
1.37 + Node node(int ix) const { return Parent::nodeFromId(ix); }
1.38 +
1.39 + /// \brief The arc with the given index.
1.40 + ///
1.41 + /// This function returns the arc with the given index.
1.42 + /// \sa index()
1.43 + Arc arc(int ix) const { return Parent::arcFromId(ix); }
1.44 +
1.45 + /// \brief The index of the given node.
1.46 + ///
1.47 + /// This function returns the index of the the given node.
1.48 + /// \sa node()
1.49 + int index(Node node) const { return Parent::id(node); }
1.50 +
1.51 + /// \brief The index of the given arc.
1.52 + ///
1.53 + /// This function returns the index of the the given arc.
1.54 + /// \sa arc()
1.55 + int index(Arc arc) const { return Parent::id(arc); }
1.56 +
1.57 + /// \brief Number of nodes.
1.58 + ///
1.59 + /// This function returns the number of nodes.
1.60 + int nodeNum() const { return node_num; }
1.61 +
1.62 + /// \brief Number of arcs.
1.63 + ///
1.64 + /// This function returns the number of arcs.
1.65 + int arcNum() const { return arc_num; }
1.66 +
1.67 /// \brief Build the digraph copying another digraph.
1.68 ///
1.69 /// This function builds the digraph copying another digraph of any
1.70 @@ -288,6 +328,12 @@
1.71 Parent::build(digraph, nodeRef, arcRef);
1.72 }
1.73
1.74 + /// \brief Clear the digraph.
1.75 + ///
1.76 + /// This function erases all nodes and arcs from the digraph.
1.77 + void clear() {
1.78 + Parent::clear();
1.79 + }
1.80
1.81 protected:
1.82
2.1 --- a/test/digraph_test.cc Tue Aug 25 16:32:47 2009 +0200
2.2 +++ b/test/digraph_test.cc Tue Sep 29 10:39:20 2009 +0200
2.3 @@ -445,6 +445,11 @@
2.4 checkArcIds(G);
2.5 checkGraphNodeMap(G);
2.6 checkGraphArcMap(G);
2.7 +
2.8 + int n = G.nodeNum();
2.9 + int m = G.arcNum();
2.10 + check(G.index(G.node(n-1)) == n-1, "Wrong index.");
2.11 + check(G.index(G.arc(m-1)) == m-1, "Wrong index.");
2.12 }
2.13
2.14 void checkFullDigraph(int num) {