[Lemon-commits] [lemon_svn] deba: r1297 - in hugo/branches/graph_factory/src: lemon test
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:44:27 CET 2006
Author: deba
Date: Thu Oct 21 01:10:47 2004
New Revision: 1297
Added:
hugo/branches/graph_factory/src/lemon/list_graph.h
- copied, changed from r1295, /hugo/branches/graph_factory/src/lemon/test_graph.h
Removed:
hugo/branches/graph_factory/src/lemon/test_graph.h
Modified:
hugo/branches/graph_factory/src/lemon/Makefile.am
hugo/branches/graph_factory/src/lemon/alteration_observer_registry.h
hugo/branches/graph_factory/src/lemon/smart_graph.h
hugo/branches/graph_factory/src/lemon/vector_map.h
hugo/branches/graph_factory/src/test/extended_graph_test.cc
hugo/branches/graph_factory/src/test/graph_test.cc
Log:
ListGraph and SmartGraph are close to be ready.
Its pass the bfs, dijkstra and min_cost_flow tests.
Some incompatibility with dfs.
Modified: hugo/branches/graph_factory/src/lemon/Makefile.am
==============================================================================
--- hugo/branches/graph_factory/src/lemon/Makefile.am (original)
+++ hugo/branches/graph_factory/src/lemon/Makefile.am Thu Oct 21 01:10:47 2004
@@ -14,7 +14,7 @@
kruskal.h \
list_graph.h \
map_iterator.h \
- map_registry.h \
+ alteration_observer_registry.h \
maps.h \
min_cost_flow.h \
suurballe.h \
@@ -22,16 +22,14 @@
path.h \
smart_graph.h \
time_measure.h \
- test_graph.h \
unionfind.h \
vector_map.h \
xy.h \
- iterator_graph_extension.h \
- id_map_graph_extension.h \
- map_graph_extension.h \
- extend_graph_extension.h \
- clear_graph_extension.h \
- erase_graph_extension.h
+ iterable_graph_extender.h \
+ idmappable_graph_extender.h \
+ extendable_graph_extender.h \
+ clearable_graph_extender.h \
+ erasable_graph_extender.h
noinst_HEADERS = \
skeletons/graph.h \
Modified: hugo/branches/graph_factory/src/lemon/alteration_observer_registry.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/alteration_observer_registry.h (original)
+++ hugo/branches/graph_factory/src/lemon/alteration_observer_registry.h Thu Oct 21 01:10:47 2004
@@ -14,8 +14,8 @@
*
*/
-#ifndef LEMON_OBSERVER_REGISTRY_H
-#define LEMON_OBSERVER_REGISTRY_H
+#ifndef LEMON_ALTERATION_OBSERVER_REGISTRY_H
+#define LEMON_ALTERATION_OBSERVER_REGISTRY_H
#include <vector>
#include <algorithm>
@@ -85,6 +85,8 @@
/// observer registry. This calls also the build() member
/// to notify the observer about it is registered.
+ virtual ~ObserverBase() {}
+
void attach(AlterationObserverRegistry& r) {
if (registry) {
registry->detach(*this);
Copied: hugo/branches/graph_factory/src/lemon/list_graph.h (from r1295, /hugo/branches/graph_factory/src/lemon/test_graph.h)
==============================================================================
--- /hugo/branches/graph_factory/src/lemon/test_graph.h (original)
+++ hugo/branches/graph_factory/src/lemon/list_graph.h Thu Oct 21 01:10:47 2004
@@ -11,7 +11,7 @@
#include <lemon/iterable_graph_extender.h>
-#include <lemon/alteration_registry.h>
+#include <lemon/alteration_observer_registry.h>
#include <lemon/vector_map.h>
Modified: hugo/branches/graph_factory/src/lemon/smart_graph.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/smart_graph.h (original)
+++ hugo/branches/graph_factory/src/lemon/smart_graph.h Thu Oct 21 01:10:47 2004
@@ -22,22 +22,25 @@
///\brief SmartGraph and SymSmartGraph classes.
#include <vector>
-#include <climits>
#include <lemon/invalid.h>
+#include <lemon/erasable_graph_extender.h>
+#include <lemon/clearable_graph_extender.h>
+#include <lemon/extendable_graph_extender.h>
-#include <lemon/array_map.h>
+#include <lemon/idmappable_graph_extender.h>
-#include <lemon/map_registry.h>
+#include <lemon/iterable_graph_extender.h>
+
+#include <lemon/alteration_observer_registry.h>
+#include <lemon/vector_map.h>
-#include <lemon/map_defines.h>
namespace lemon {
-/// \addtogroup graphs
-/// @{
-// class SymSmartGraph;
+ /// \addtogroup graphs
+ /// @{
///A smart graph class.
@@ -56,7 +59,7 @@
///Of course it should be used as a stack. (Maybe X is not necessary.)
///
///\author Alpar Juttner
- class SmartGraph {
+ class SmartGraphBase {
struct NodeT
{
@@ -77,25 +80,16 @@
public:
- typedef SmartGraph Graph;
+ typedef SmartGraphBase Graph;
class Node;
class Edge;
- class NodeIt;
- class EdgeIt;
- class OutEdgeIt;
- class InEdgeIt;
-
- // Create map registries.
- CREATE_MAP_REGISTRIES;
- // Create node and edge maps.
- CREATE_MAPS(ArrayMap);
public:
- SmartGraph() : nodes(), edges() { }
- SmartGraph(const SmartGraph &_g) : nodes(_g.nodes), edges(_g.edges) { }
+ SmartGraphBase() : nodes(), edges() { }
+ SmartGraphBase(const SmartGraphBase &_g) : nodes(_g.nodes), edges(_g.edges) { }
///Number of nodes.
int nodeNum() const { return nodes.size(); }
@@ -116,15 +110,6 @@
Node tail(Edge e) const { return edges[e.n].tail; }
Node head(Edge e) const { return edges[e.n].head; }
- NodeIt& first(NodeIt& v) const {
- v=NodeIt(*this); return v; }
- EdgeIt& first(EdgeIt& e) const {
- e=EdgeIt(*this); return e; }
- OutEdgeIt& first(OutEdgeIt& e, const Node v) const {
- e=OutEdgeIt(*this,v); return e; }
- InEdgeIt& first(InEdgeIt& e, const Node v) const {
- e=InEdgeIt(*this,v); return e; }
-
/// Node ID.
/// The ID of a valid Node is a nonnegative integer not greater than
@@ -147,9 +132,6 @@
Node addNode() {
Node n; n.n=nodes.size();
nodes.push_back(NodeT()); //FIXME: Hmmm...
-
-
- node_maps.add(n);
return n;
}
@@ -160,8 +142,6 @@
edges[e.n].next_in=nodes[v.n].first_in;
nodes[u.n].first_out=nodes[v.n].first_in=e.n;
- edge_maps.add(e);
-
return e;
}
@@ -182,25 +162,18 @@
}
void clear() {
- edge_maps.clear();
edges.clear();
- node_maps.clear();
nodes.clear();
}
class Node {
- friend class SmartGraph;
- template <typename T> friend class NodeMap;
-
- friend class Edge;
- friend class OutEdgeIt;
- friend class InEdgeIt;
- friend class SymEdge;
+ friend class SmartGraphBase;
protected:
+
int n;
- friend int SmartGraph::id(Node v);
Node(int nn) {n=nn;}
+
public:
Node() {}
Node (Invalid) { n=-1; }
@@ -211,33 +184,12 @@
// operator bool() { return n!=-1; }
};
- class NodeIt : public Node {
- const SmartGraph *G;
- friend class SmartGraph;
- public:
- NodeIt() : Node() { }
- NodeIt(const SmartGraph& _G,Node n) : Node(n), G(&_G) { }
- NodeIt(Invalid i) : Node(i) { }
- NodeIt(const SmartGraph& _G) : Node(_G.nodes.size()?0:-1), G(&_G) { }
- NodeIt &operator++() {
- n=(n+2)%(G->nodes.size()+1)-1;
- return *this;
- }
-// ///Validity check
-// operator bool() { return Node::operator bool(); }
- };
class Edge {
- friend class SmartGraph;
- template <typename T> friend class EdgeMap;
+ friend class SmartGraphBase;
- friend class SymSmartGraph;
-
- friend class Node;
- friend class NodeIt;
protected:
int n;
- friend int SmartGraph::id(Edge e);
Edge(int nn) {n=nn;}
public:
/// An Edge with id \c n.
@@ -247,489 +199,57 @@
bool operator==(const Edge i) const {return n==i.n;}
bool operator!=(const Edge i) const {return n!=i.n;}
bool operator<(const Edge i) const {return n<i.n;}
-// ///Validity check
-// operator bool() { return n!=-1; }
-
- ///Set the edge to that have ID \c ID.
- void setToId(int id) { n=id; }
- };
-
- class EdgeIt : public Edge {
- const SmartGraph *G;
- friend class SmartGraph;
- public:
- EdgeIt(const SmartGraph& _G) : Edge(_G.edges.size()-1), G(&_G) { }
- EdgeIt(const SmartGraph& _G, Edge e) : Edge(e), G(&_G) { }
- EdgeIt (Invalid i) : Edge(i) { }
- EdgeIt() : Edge() { }
- EdgeIt &operator++() { --n; return *this; }
-// ///Validity check
-// operator bool() { return Edge::operator bool(); }
- };
-
- class OutEdgeIt : public Edge {
- const SmartGraph *G;
- friend class SmartGraph;
- public:
- OutEdgeIt() : Edge() { }
- OutEdgeIt(const SmartGraph& _G, Edge e) : Edge(e), G(&_G) { }
- OutEdgeIt (Invalid i) : Edge(i) { }
-
- OutEdgeIt(const SmartGraph& _G,const Node v)
- : Edge(_G.nodes[v.n].first_out), G(&_G) {}
- OutEdgeIt &operator++() { n=G->edges[n].next_out; return *this; }
-// ///Validity check
-// operator bool() { return Edge::operator bool(); }
- };
-
- class InEdgeIt : public Edge {
- const SmartGraph *G;
- friend class SmartGraph;
- public:
- InEdgeIt() : Edge() { }
- InEdgeIt(const SmartGraph& _G, Edge e) : Edge(e), G(&_G) { }
- InEdgeIt (Invalid i) : Edge(i) { }
- InEdgeIt(const SmartGraph& _G,Node v)
- : Edge(_G.nodes[v.n].first_in), G(&_G) { }
- InEdgeIt &operator++() { n=G->edges[n].next_in; return *this; }
-// ///Validity check
-// operator bool() { return Edge::operator bool(); }
- };
-
- };
-
-
-
- class SymSmartGraph : public SmartGraph {
- typedef SmartGraph Parent;
- public:
-
- typedef SymSmartGraph Graph;
-
- typedef SmartGraph::Node Node;
- typedef SmartGraph::NodeIt NodeIt;
-
- class SymEdge;
- class SymEdgeIt;
-
- class Edge;
- class EdgeIt;
- class OutEdgeIt;
- class InEdgeIt;
-
- template <typename Value>
- class NodeMap : public Parent::NodeMap<Value> {
- public:
- NodeMap(const SymSmartGraph& g)
- : SymSmartGraph::Parent::NodeMap<Value>(g) {}
- NodeMap(const SymSmartGraph& g, Value v)
- : SymSmartGraph::Parent::NodeMap<Value>(g, v) {}
- template<typename TT>
- NodeMap(const NodeMap<TT>& copy)
- : SymSmartGraph::Parent::NodeMap<Value>(copy) { }
- };
-
- template <typename Value>
- class SymEdgeMap : public Parent::EdgeMap<Value> {
- public:
- typedef SymEdge KeyType;
-
- SymEdgeMap(const SymSmartGraph& g)
- : SymSmartGraph::Parent::EdgeMap<Value>(g) {}
- SymEdgeMap(const SymSmartGraph& g, Value v)
- : SymSmartGraph::Parent::EdgeMap<Value>(g, v) {}
- template<typename TT>
- SymEdgeMap(const SymEdgeMap<TT>& copy)
- : SymSmartGraph::Parent::EdgeMap<Value>(copy) { }
-
- };
+ // ///Validity check
+ // operator bool() { return n!=-1; }
- // Create edge map registry.
- CREATE_EDGE_MAP_REGISTRY;
- // Create edge maps.
- CREATE_EDGE_MAP(ArrayMap);
-
- class Edge {
- friend class SymSmartGraph;
- friend class SymSmartGraph::EdgeIt;
- friend class SymSmartGraph::OutEdgeIt;
- friend class SymSmartGraph::InEdgeIt;
-
- protected:
- int id;
-
- Edge(int pid) { id = pid; }
-
- public:
- /// An Edge with id \c n.
-
- Edge() { }
- Edge (Invalid) { id = -1; }
-
- operator SymEdge(){ return SymEdge(id >> 1);}
-
- bool operator==(const Edge i) const {return id == i.id;}
- bool operator!=(const Edge i) const {return id != i.id;}
- bool operator<(const Edge i) const {return id < i.id;}
- // ///Validity check
- // operator bool() { return n!=-1; }
- };
-
- class SymEdge : public SmartGraph::Edge {
- friend class SymSmartGraph;
- friend class SymSmartGraph::Edge;
- typedef SmartGraph::Edge Parent;
-
- protected:
- SymEdge(int pid) : Parent(pid) {}
- public:
-
- SymEdge() { }
- SymEdge(const SmartGraph::Edge& i) : Parent(i) {}
- SymEdge (Invalid) : Parent(INVALID) {}
};
- class OutEdgeIt {
- Parent::OutEdgeIt out;
- Parent::InEdgeIt in;
- public:
- OutEdgeIt() {}
- OutEdgeIt(const SymSmartGraph& g, Edge e) {
- if ((e.id & 1) == 0) {
- out = Parent::OutEdgeIt(g, SymEdge(e));
- in = Parent::InEdgeIt(g, g.tail(e));
- } else {
- out = Parent::OutEdgeIt(INVALID);
- in = Parent::InEdgeIt(g, SymEdge(e));
- }
- }
- OutEdgeIt (Invalid i) : out(INVALID), in(INVALID) { }
-
- OutEdgeIt(const SymSmartGraph& g, const Node v)
- : out(g, v), in(g, v) {}
- OutEdgeIt &operator++() {
- if (out != INVALID) {
- ++out;
- } else {
- ++in;
- }
- return *this;
- }
-
- operator Edge() const {
- if (out == INVALID && in == INVALID) return INVALID;
- return out != INVALID ? forward(out) : backward(in);
- }
-
- bool operator==(const Edge i) const {return Edge(*this) == i;}
- bool operator!=(const Edge i) const {return Edge(*this) != i;}
- bool operator<(const Edge i) const {return Edge(*this) < i;}
- };
-
- class InEdgeIt {
- Parent::OutEdgeIt out;
- Parent::InEdgeIt in;
- public:
- InEdgeIt() {}
- InEdgeIt(const SymSmartGraph& g, Edge e) {
- if ((e.id & 1) == 0) {
- out = Parent::OutEdgeIt(g, SymEdge(e));
- in = Parent::InEdgeIt(g, g.tail(e));
- } else {
- out = Parent::OutEdgeIt(INVALID);
- in = Parent::InEdgeIt(g, SymEdge(e));
- }
- }
- InEdgeIt (Invalid i) : out(INVALID), in(INVALID) { }
-
- InEdgeIt(const SymSmartGraph& g, const Node v)
- : out(g, v), in(g, v) {}
-
- InEdgeIt &operator++() {
- if (out != INVALID) {
- ++out;
- } else {
- ++in;
- }
- return *this;
- }
-
- operator Edge() const {
- if (out == INVALID && in == INVALID) return INVALID;
- return out != INVALID ? backward(out) : forward(in);
- }
-
- bool operator==(const Edge i) const {return Edge(*this) == i;}
- bool operator!=(const Edge i) const {return Edge(*this) != i;}
- bool operator<(const Edge i) const {return Edge(*this) < i;}
- };
-
- class SymEdgeIt : public Parent::EdgeIt {
-
- public:
- SymEdgeIt() {}
-
- SymEdgeIt(const SymSmartGraph& g)
- : SymSmartGraph::Parent::EdgeIt(g) {}
-
- SymEdgeIt(const SymSmartGraph& g, SymEdge e)
- : SymSmartGraph::Parent::EdgeIt(g, e) {}
-
- SymEdgeIt(Invalid i)
- : SymSmartGraph::Parent::EdgeIt(INVALID) {}
-
- SymEdgeIt& operator++() {
- SymSmartGraph::Parent::EdgeIt::operator++();
- return *this;
- }
-
- operator SymEdge() const {
- return SymEdge
- (static_cast<const SymSmartGraph::Parent::EdgeIt&>(*this));
- }
- bool operator==(const SymEdge i) const {return SymEdge(*this) == i;}
- bool operator!=(const SymEdge i) const {return SymEdge(*this) != i;}
- bool operator<(const SymEdge i) const {return SymEdge(*this) < i;}
- };
-
- class EdgeIt {
- SymEdgeIt it;
- bool fw;
- public:
- EdgeIt(const SymSmartGraph& g) : it(g), fw(true) {}
- EdgeIt (Invalid i) : it(i) { }
- EdgeIt(const SymSmartGraph& g, Edge e)
- : it(g, SymEdge(e)), fw(id(e) & 1 == 0) { }
- EdgeIt() { }
- EdgeIt& operator++() {
- fw = !fw;
- if (fw) ++it;
- return *this;
- }
- operator Edge() const {
- if (it == INVALID) return INVALID;
- return fw ? forward(it) : backward(it);
- }
- bool operator==(const Edge i) const {return Edge(*this) == i;}
- bool operator!=(const Edge i) const {return Edge(*this) != i;}
- bool operator<(const Edge i) const {return Edge(*this) < i;}
-
- };
-
- ///Number of nodes.
- int nodeNum() const { return Parent::nodeNum(); }
- ///Number of edges.
- int edgeNum() const { return 2*Parent::edgeNum(); }
- ///Number of symmetric edges.
- int symEdgeNum() const { return Parent::edgeNum(); }
-
- /// Maximum node ID.
-
- /// Maximum node ID.
- ///\sa id(Node)
- int maxNodeId() const { return Parent::maxNodeId(); }
- /// Maximum edge ID.
-
- /// Maximum edge ID.
- ///\sa id(Edge)
- int maxEdgeId() const { return 2*Parent::maxEdgeId(); }
- /// Maximum symmetric edge ID.
-
- /// Maximum symmetric edge ID.
- ///\sa id(SymEdge)
- int maxSymEdgeId() const { return Parent::maxEdgeId(); }
-
-
- Node tail(Edge e) const {
- return (e.id & 1) == 0 ?
- Parent::tail(SymEdge(e)) : Parent::head(SymEdge(e));
+ void first(Node& node) const {
+ node.n = nodes.size() - 1;
}
- Node head(Edge e) const {
- return (e.id & 1) == 0 ?
- Parent::head(SymEdge(e)) : Parent::tail(SymEdge(e));
+ static void next(Node& node) {
+ --node.n;
}
- Node tail(SymEdge e) const {
- return Parent::tail(e);
+ void first(Edge& edge) const {
+ edge.n = edges.size() - 1;
}
- Node head(SymEdge e) const {
- return Parent::head(e);
+ static void next(Edge& edge) {
+ --edge.n;
}
- NodeIt& first(NodeIt& v) const {
- v=NodeIt(*this); return v; }
- EdgeIt& first(EdgeIt& e) const {
- e=EdgeIt(*this); return e; }
- SymEdgeIt& first(SymEdgeIt& e) const {
- e=SymEdgeIt(*this); return e; }
- OutEdgeIt& first(OutEdgeIt& e, const Node v) const {
- e=OutEdgeIt(*this,v); return e; }
- InEdgeIt& first(InEdgeIt& e, const Node v) const {
- e=InEdgeIt(*this,v); return e; }
-
- /// 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 Parent::id(v); }
- /// 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; }
-
- /// The ID of a valid SymEdge is a nonnegative integer not greater than
- /// \ref maxSymEdgeId(). The range of the ID's is not surely continuous
- /// and the greatest edge ID can be actually less then \ref maxSymEdgeId().
- ///
- /// The ID of the \ref INVALID symmetric edge is -1.
- ///\return The ID of the edge \c e.
- static int id(SymEdge e) { return Parent::id(e); }
-
- /// Adds a new node to the graph.
-
- /// \warning It adds the new node to the front of the list.
- /// (i.e. the lastly added node becomes the first.)
- Node addNode() {
- return Parent::addNode();
- }
-
- SymEdge addEdge(Node u, Node v) {
- SymEdge se = Parent::addEdge(u, v);
- edge_maps.add(forward(se));
- edge_maps.add(backward(se));
- return se;
- }
-
- /// Finds an edge between two nodes.
-
- /// Finds an edge from node \c u to node \c v.
- ///
- /// If \c prev is \ref INVALID (this is the default value), then
- /// It finds the first edge from \c u to \c v. Otherwise it looks for
- /// the next edge from \c u to \c v after \c prev.
- /// \return The found edge or INVALID if there is no such an edge.
- Edge findEdge(Node u, Node v, Edge prev = INVALID)
- {
- if (prev == INVALID || id(prev) & 1 == 0) {
- SymEdge se = Parent::findEdge(u, v, SymEdge(prev));
- if (se != INVALID) return forward(se);
- } else {
- SymEdge se = Parent::findEdge(v, u, SymEdge(prev));
- if (se != INVALID) return backward(se);
- }
- return INVALID;
- }
-
-// /// Finds an symmetric edge between two nodes.
-
-// /// Finds an symmetric edge from node \c u to node \c v.
-// ///
-// /// If \c prev is \ref INVALID (this is the default value), then
-// /// It finds the first edge from \c u to \c v. Otherwise it looks for
-// /// the next edge from \c u to \c v after \c prev.
-// /// \return The found edge or INVALID if there is no such an edge.
-
-// SymEdge findEdge(Node u, Node v, SymEdge prev = INVALID)
-// {
-// if (prev == INVALID || id(prev) & 1 == 0) {
-// SymEdge se = Parent::findEdge(u, v, SymEdge(prev));
-// if (se != INVALID) return se;
-// } else {
-// SymEdge se = Parent::findEdge(v, u, SymEdge(prev));
-// if (se != INVALID) return se;
-// }
-// return INVALID;
-// }
-
- public:
-
- void clear() {
- edge_maps.clear();
- Parent::clear();
+ void firstOut(Edge& edge, const Node& node) const {
+ edge.n = nodes[node.n].first_out;
}
- static Edge opposite(Edge e) {
- return Edge(id(e) ^ 1);
+ void nextOut(Edge& edge) const {
+ edge.n = edges[edge.n].next_out;
}
- static Edge forward(SymEdge e) {
- return Edge(id(e) << 1);
+ void firstIn(Edge& edge, const Node& node) const {
+ edge.n = nodes[node.n].first_in;
}
-
- static Edge backward(SymEdge e) {
- return Edge((id(e) << 1) | 1);
+
+ void nextIn(Edge& edge) const {
+ edge.n = edges[edge.n].next_in;
}
};
- ///Graph for bidirectional edges.
-
- ///The purpose of this graph structure is to handle graphs
- ///having bidirectional edges. Here the function \c addEdge(u,v) adds a pair
- ///of oppositely directed edges.
- ///There is a new edge map type called
- ///\ref SymSmartGraph::SymEdgeMap "SymEdgeMap"
- ///that complements this
- ///feature by
- ///storing shared values for the edge pairs. The usual
- ///\ref Graph::EdgeMap "EdgeMap"
- ///can be used
- ///as well.
- ///
- ///The oppositely directed edge can also be obtained easily
- ///using \ref opposite.
- ///\warning It shares the similarity with \ref SmartGraph that
- ///it is not possible to delete edges or nodes from the graph.
- //\sa SmartGraph.
-
- /* class SymSmartGraph : public SmartGraph
- {
- public:
- typedef SymSmartGraph Graph;
-
- // Create symmetric map registry.
- CREATE_SYM_EDGE_MAP_REGISTRY;
- // Create symmetric edge map.
- CREATE_SYM_EDGE_MAP(ArrayMap);
- SymSmartGraph() : SmartGraph() { }
- SymSmartGraph(const SmartGraph &_g) : SmartGraph(_g) { }
- ///Adds a pair of oppositely directed edges to the graph.
- Edge addEdge(Node u, Node v)
- {
- Edge e = SmartGraph::addEdge(u,v);
- Edge f = SmartGraph::addEdge(v,u);
- sym_edge_maps.add(e);
- sym_edge_maps.add(f);
- return e;
- }
- ///The oppositely directed edge.
+ typedef AlterableGraphExtender<SmartGraphBase> AlterableSmartGraphBase;
+ typedef IterableGraphExtender<AlterableSmartGraphBase> IterableSmartGraphBase;
+ typedef IdMappableGraphExtender<IterableSmartGraphBase> IdMappableSmartGraphBase;
+ typedef VectorMappableGraphExtender<IdMappableSmartGraphBase> MappableSmartGraphBase;
+ typedef ExtendableGraphExtender<MappableSmartGraphBase> ExtendableSmartGraphBase;
+ typedef ClearableGraphExtender<ExtendableSmartGraphBase> ClearableSmartGraphBase;
- ///Returns the oppositely directed
- ///pair of the edge \c e.
- static Edge opposite(Edge e)
- {
- Edge f;
- f.n = e.n - 2*(e.n%2) + 1;
- return f;
- }
-
+ typedef ClearableSmartGraphBase SmartGraph;
- };*/
-
/// @}
} //namespace lemon
Modified: hugo/branches/graph_factory/src/lemon/vector_map.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/vector_map.h (original)
+++ hugo/branches/graph_factory/src/lemon/vector_map.h Thu Oct 21 01:10:47 2004
@@ -20,7 +20,7 @@
#include <vector>
#include <algorithm>
-#include <lemon/alteration_registry.h>
+#include <lemon/alteration_observer_registry.h>
///\ingroup graphmaps
///\file
@@ -150,7 +150,7 @@
/// It the same as operator[](key) = value expression.
///
- void set(const KeyType& key, const ValueType& value) const {
+ void set(const KeyType& key, const ValueType& value) {
(*this)[key] = value;
}
Modified: hugo/branches/graph_factory/src/test/extended_graph_test.cc
==============================================================================
--- hugo/branches/graph_factory/src/test/extended_graph_test.cc (original)
+++ hugo/branches/graph_factory/src/test/extended_graph_test.cc Thu Oct 21 01:10:47 2004
@@ -4,7 +4,8 @@
#include <vector>
#include <lemon/skeletons/extended_graph.h>
-#include <lemon/test_graph.h>
+#include <lemon/list_graph.h>
+#include <lemon/smart_graph.h>
#include "test_tools.h"
#include "graph_test.h"
@@ -52,6 +53,24 @@
+
+template void lemon::skeleton::checkIterableExtendedGraph
+<SmartGraph>(SmartGraph &);
+
+template void lemon::skeleton::checkIdMappableExtendedGraph
+<SmartGraph>(SmartGraph &);
+
+template void lemon::skeleton::checkMappableExtendedGraph
+<SmartGraph>(SmartGraph &);
+
+template void lemon::skeleton::checkExtendableExtendedGraph
+<SmartGraph>(SmartGraph &);
+
+template void lemon::skeleton::checkClearableExtendedGraph
+<SmartGraph>(SmartGraph &);
+
+
+
template<class Graph> void bidirPetersen(Graph &G)
{
typedef typename Graph::Edge Edge;
@@ -93,6 +112,13 @@
checkPetersen(G);
}
+ {
+ SmartGraph G;
+ addPetersen(G);
+ bidirPetersen(G);
+ checkPetersen(G);
+ }
+
std::cout << __FILE__ ": All tests passed.\n";
return 0;
Modified: hugo/branches/graph_factory/src/test/graph_test.cc
==============================================================================
--- hugo/branches/graph_factory/src/test/graph_test.cc (original)
+++ hugo/branches/graph_factory/src/test/graph_test.cc Thu Oct 21 01:10:47 2004
@@ -18,7 +18,7 @@
#include<lemon/smart_graph.h>
#include<lemon/skeletons/graph.h>
#include<lemon/list_graph.h>
-#include<lemon/full_graph.h>
+//#include<lemon/full_graph.h>
#include"test_tools.h"
#include"graph_test.h"
@@ -103,25 +103,25 @@
//template void hugo::checkCompileGraphFindEdge<SymListGraph>(SymListGraph &);
//Compile FullGraph
-template void lemon::skeleton::checkCompileStaticGraph<FullGraph>(FullGraph &);
-template
-void lemon::skeleton::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
+//template void lemon::skeleton::checkCompileStaticGraph<FullGraph>(FullGraph &);
+//template
+//void lemon::skeleton::checkCompileGraphFindEdge<FullGraph>(FullGraph &);
//Compile EdgeSet <ListGraph>
-template void lemon::skeleton::checkCompileExtendableGraph<EdgeSet <ListGraph> >
-(EdgeSet <ListGraph> &);
-template void lemon::skeleton::checkCompileGraphEraseEdge<EdgeSet <ListGraph> >
-(EdgeSet <ListGraph> &);
-template void lemon::skeleton::checkCompileGraphFindEdge<EdgeSet <ListGraph> >
-(EdgeSet <ListGraph> &);
+//template void lemon::skeleton::checkCompileExtendableGraph<EdgeSet <ListGraph> >
+//(EdgeSet <ListGraph> &);
+//template void lemon::skeleton::checkCompileGraphEraseEdge<EdgeSet <ListGraph> >
+//(EdgeSet <ListGraph> &);
+//template void lemon::skeleton::checkCompileGraphFindEdge<EdgeSet <ListGraph> >
+//(EdgeSet <ListGraph> &);
//Compile EdgeSet <NodeSet>
-template void lemon::skeleton::checkCompileExtendableGraph<EdgeSet <NodeSet> >
-(EdgeSet <NodeSet> &);
-template void lemon::skeleton::checkCompileGraphEraseEdge<EdgeSet <NodeSet> >
-(EdgeSet <NodeSet> &);
-template void lemon::skeleton::checkCompileGraphFindEdge<EdgeSet <NodeSet> >
-(EdgeSet <NodeSet> &);
+//template void lemon::skeleton::checkCompileExtendableGraph<EdgeSet <NodeSet> >
+//(EdgeSet <NodeSet> &);
+//template void lemon::skeleton::checkCompileGraphEraseEdge<EdgeSet <NodeSet> >
+//(EdgeSet <NodeSet> &);
+//template void lemon::skeleton::checkCompileGraphFindEdge<EdgeSet <NodeSet> >
+//(EdgeSet <NodeSet> &);
int main()
More information about the Lemon-commits
mailing list