diff --git a/lemon/smart_graph.h b/lemon/smart_graph.h
--- a/lemon/smart_graph.h
+++ b/lemon/smart_graph.h
@@ -2,7 +2,7 @@
*
* This file is a part of LEMON, a generic C++ optimization library.
*
- * Copyright (C) 2003-2008
+ * Copyright (C) 2003-2009
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
* (Egervary Research Group on Combinatorial Optimization, EGRES).
*
@@ -55,7 +55,7 @@
public:
- typedef SmartDigraphBase Graph;
+ typedef SmartDigraphBase Digraph;
class Node;
class Arc;
@@ -67,7 +67,7 @@
: nodes(_g.nodes), arcs(_g.arcs) { }
typedef True NodeNumTag;
- typedef True EdgeNumTag;
+ typedef True ArcNumTag;
int nodeNum() const { return nodes.size(); }
int arcNum() const { return arcs.size(); }
@@ -191,14 +191,10 @@
///It is also quite memory efficient, but at the price
///that it does support only limited (only stack-like)
///node and arc deletions.
- ///It conforms to the \ref concepts::Digraph "Digraph concept" with
- ///an important extra feature that its maps are real \ref
- ///concepts::ReferenceMap "reference map"s.
+ ///It fully conforms to the \ref concepts::Digraph "Digraph concept".
///
///\sa concepts::Digraph.
class SmartDigraph : public ExtendedSmartDigraphBase {
- public:
-
typedef ExtendedSmartDigraphBase Parent;
private:
@@ -225,15 +221,15 @@
///Add a new node to the digraph.
- /// \return the new node.
- ///
+ /// Add a new node to the digraph.
+ /// \return The new node.
Node addNode() { return Parent::addNode(); }
///Add a new arc to the digraph.
///Add a new arc to the digraph with source node \c s
///and target node \c t.
- ///\return the new arc.
+ ///\return The new arc.
Arc addArc(const Node& s, const Node& t) {
return Parent::addArc(s, t);
}
@@ -305,7 +301,9 @@
Node b = addNode();
nodes[b._id].first_out=nodes[n._id].first_out;
nodes[n._id].first_out=-1;
- for(int i=nodes[b._id].first_out;i!=-1;i++) arcs[i].source=b._id;
+ for(int i=nodes[b._id].first_out; i!=-1; i=arcs[i].next_out) {
+ arcs[i].source=b._id;
+ }
if(connect) addArc(n,b);
return b;
}
@@ -420,7 +418,7 @@
public:
- typedef SmartGraphBase Digraph;
+ typedef SmartGraphBase Graph;
class Node;
class Arc;
@@ -464,8 +462,8 @@
explicit Arc(int id) { _id = id;}
public:
- operator Edge() const {
- return _id != -1 ? edgeFromId(_id / 2) : INVALID;
+ operator Edge() const {
+ return _id != -1 ? edgeFromId(_id / 2) : INVALID;
}
Arc() {}
@@ -480,6 +478,13 @@
SmartGraphBase()
: nodes(), arcs() {}
+ typedef True NodeNumTag;
+ typedef True EdgeNumTag;
+ typedef True ArcNumTag;
+
+ int nodeNum() const { return nodes.size(); }
+ int edgeNum() const { return arcs.size() / 2; }
+ int arcNum() const { return arcs.size(); }
int maxNodeId() const { return nodes.size()-1; }
int maxEdgeId() const { return arcs.size() / 2 - 1; }
@@ -620,16 +625,12 @@
/// It is also quite memory efficient, but at the price
/// that it does support only limited (only stack-like)
/// node and arc deletions.
- /// Except from this it conforms to
- /// the \ref concepts::Graph "Graph concept".
- ///
- /// It also has an
- /// important extra feature that
- /// its maps are real \ref concepts::ReferenceMap "reference map"s.
+ /// It fully conforms to the \ref concepts::Graph "Graph concept".
///
/// \sa concepts::Graph.
- ///
class SmartGraph : public ExtendedSmartGraphBase {
+ typedef ExtendedSmartGraphBase Parent;
+
private:
///SmartGraph is \e not copy constructible. Use GraphCopy() instead.
@@ -647,8 +648,6 @@
public:
- typedef ExtendedSmartGraphBase Parent;
-
/// Constructor
/// Constructor.
@@ -657,15 +656,15 @@
///Add a new node to the graph.
- /// \return the new node.
- ///
+ /// Add a new node to the graph.
+ /// \return The new node.
Node addNode() { return Parent::addNode(); }
///Add a new edge to the graph.
///Add a new edge to the graph with node \c s
///and \c t.
- ///\return the new edge.
+ ///\return The new edge.
Edge addEdge(const Node& s, const Node& t) {
return Parent::addEdge(s, t);
}
@@ -728,8 +727,8 @@
dir.push_back(arcFromId(n));
dir.push_back(arcFromId(n-1));
Parent::notifier(Arc()).erase(dir);
- nodes[arcs[n].target].first_out=arcs[n].next_out;
- nodes[arcs[n-1].target].first_out=arcs[n-1].next_out;
+ nodes[arcs[n-1].target].first_out=arcs[n].next_out;
+ nodes[arcs[n].target].first_out=arcs[n-1].next_out;
arcs.pop_back();
arcs.pop_back();
}