[Lemon-commits] [lemon_svn] alpar: r1044 - in hugo/branches/hugo++/src: hugo test
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:42:55 CET 2006
Author: alpar
Date: Thu Aug 26 15:32:59 2004
New Revision: 1044
Modified:
hugo/branches/hugo++/src/hugo/full_graph.h
hugo/branches/hugo++/src/hugo/list_graph.h
hugo/branches/hugo++/src/hugo/smart_graph.h
hugo/branches/hugo++/src/test/graph_test.cc
Log:
- Node->NodeIt, Edge->{|In|Out}EdgeIt conversion added.
- CAUTION: EdgeSet::EdgeIt::operator++() is still unimplemented.
Modified: hugo/branches/hugo++/src/hugo/full_graph.h
==============================================================================
--- hugo/branches/hugo++/src/hugo/full_graph.h (original)
+++ hugo/branches/hugo++/src/hugo/full_graph.h Thu Aug 26 15:32:59 2004
@@ -115,10 +115,10 @@
friend class FullGraph;
public:
NodeIt() : Node() { }
+ NodeIt(const FullGraph& _G,Node n) : Node(n), G(&_G) { }
NodeIt(Invalid i) : Node(i) { }
NodeIt(const FullGraph& _G) : Node(_G.NodeNum?0:-1), G(&_G) { }
///\todo Undocumented conversion Node -\> NodeIt.
- NodeIt(const FullGraph& _G, const Node &n) : Node(n), G(&_G) { }
NodeIt& operator++() { n=(n+2)%(G->NodeNum+1)-1;return *this; }
};
@@ -150,6 +150,7 @@
friend class FullGraph;
public:
EdgeIt(const FullGraph& _G) : Edge(_G.EdgeNum-1) { }
+ EdgeIt(const FullGraph&, Edge e) : Edge(e) { }
EdgeIt (Invalid i) : Edge(i) { }
EdgeIt() : Edge() { }
EdgeIt& operator++() { --n; return *this; }
@@ -164,6 +165,7 @@
friend class FullGraph;
public:
OutEdgeIt() : Edge() { }
+ OutEdgeIt(const FullGraph& _G, Edge e) : Edge(e), G(&_G) { }
OutEdgeIt (Invalid i) : Edge(i) { }
OutEdgeIt(const FullGraph& _G,const Node v) : Edge(v.n), G(&_G) {}
@@ -178,6 +180,7 @@
friend class FullGraph;
public:
InEdgeIt() : Edge() { }
+ InEdgeIt(const FullGraph& _G, Edge e) : Edge(e), G(&_G) { }
InEdgeIt (Invalid i) : Edge(i) { }
InEdgeIt(const FullGraph& _G,Node v) : Edge(v.n*_G.NodeNum), G(&_G) {}
InEdgeIt& operator++()
Modified: hugo/branches/hugo++/src/hugo/list_graph.h
==============================================================================
--- hugo/branches/hugo++/src/hugo/list_graph.h (original)
+++ hugo/branches/hugo++/src/hugo/list_graph.h Thu Aug 26 15:32:59 2004
@@ -309,7 +309,7 @@
NodeIt(Invalid i) : Node(i) { }
NodeIt(const ListGraph& _G) : Node(_G.first_node), G(&_G) { }
///\todo Undocumented conversion Node -\> NodeIt.
- NodeIt(const ListGraph& _G, const Node &n) : Node(n), G(&_G) { }
+ NodeIt(const ListGraph& _G,Node n) : Node(n), G(&_G) { }
NodeIt &operator++() {
n=G->nodes[n].next;
return *this;
@@ -362,6 +362,7 @@
n = (m==-1)?-1:_G.nodes[m].first_in;
}
EdgeIt (Invalid i) : Edge(i) { }
+ EdgeIt(const ListGraph& _G, Edge e) : Edge(e), G(&_G) { }
EdgeIt() : Edge() { }
///\bug This is a workaround until somebody tells me how to
///make class \c SymListGraph::SymEdgeMap friend of Edge
@@ -386,6 +387,7 @@
friend class ListGraph;
public:
OutEdgeIt() : Edge() { }
+ OutEdgeIt(const ListGraph& _G, Edge e) : Edge(e), G(&_G) { }
OutEdgeIt (Invalid i) : Edge(i) { }
OutEdgeIt(const ListGraph& _G,const Node v)
@@ -400,6 +402,7 @@
friend class ListGraph;
public:
InEdgeIt() : Edge() { }
+ InEdgeIt(const ListGraph& _G, Edge e) : Edge(e), G(&_G) { }
InEdgeIt (Invalid i) : Edge(i) { }
InEdgeIt(const ListGraph& _G,Node v)
: Edge(_G.nodes[v.n].first_in), G(&_G) { }
@@ -943,10 +946,9 @@
friend class NodeSet;
public:
NodeIt() : Node() { }
+ NodeIt(const NodeSet& _G,Node n) : Node(n), G(&_G) { }
NodeIt(Invalid i) : Node(i) { }
NodeIt(const NodeSet& _G) : Node(_G.first_node), G(&_G) { }
- ///\todo Undocumented conversion Node -\> NodeIt.
- NodeIt(const NodeSet& _G, const Node &n) : Node(n), G(&_G) { }
NodeIt &operator++() {
n=G->nodes[n].next;
return *this;
@@ -981,6 +983,7 @@
//friend class NodeSet;
public:
EdgeIt(const NodeSet& G) : Edge() { }
+ EdgeIt(const NodeSet&, Edge) : Edge() { }
EdgeIt (Invalid i) : Edge(i) { }
EdgeIt() : Edge() { }
///\bug This is a workaround until somebody tells me how to
@@ -993,6 +996,7 @@
friend class NodeSet;
public:
OutEdgeIt() : Edge() { }
+ OutEdgeIt(const NodeSet&, Edge) : Edge() { }
OutEdgeIt (Invalid i) : Edge(i) { }
OutEdgeIt(const NodeSet& G,const Node v) : Edge() {}
OutEdgeIt operator++() { return INVALID; }
@@ -1002,6 +1006,7 @@
friend class NodeSet;
public:
InEdgeIt() : Edge() { }
+ InEdgeIt(const NodeSet&, Edge) : Edge() { }
InEdgeIt (Invalid i) : Edge(i) { }
InEdgeIt(const NodeSet& G,Node v) :Edge() {}
InEdgeIt operator++() { return INVALID; }
@@ -1190,13 +1195,11 @@
friend class EdgeSet;
public:
NodeIt() : NodeGraphType::NodeIt() { }
+ NodeIt(const EdgeSet& _G,Node n) : NodeGraphType::NodeIt(_G.G,n) { }
NodeIt (Invalid i) : NodeGraphType::NodeIt(i) {}
NodeIt(const EdgeSet& _G) : NodeGraphType::NodeIt(_G.G) { }
NodeIt(const typename NodeGraphType::NodeIt &n)
: NodeGraphType::NodeIt(n) {}
- ///\todo Undocumented conversion Node -\> NodeIt.
- NodeIt(const EdgeSet& _G, const Node &n)
- : NodeGraphType::NodeIt(_G.G,n) { }
operator Node() { return Node(*this);}
NodeIt &operator++()
@@ -1452,16 +1455,17 @@
friend class EdgeSet;
template <typename T> friend class EdgeMap;
-
+ const EdgeSet *G;
public:
- EdgeIt(const EdgeSet& G) : Edge() {
+ EdgeIt(const EdgeSet& _G) : Edge(), G(&_G) {
// typename NodeGraphType::Node m;
NodeIt m;
- for(G.first(m);
- m!=INVALID && G.nodes[m].first_in == -1; ++m);
+ for(G->first(m);
+ m!=INVALID && G->nodes[m].first_in == -1; ++m);
///\bug AJJAJ! This is a non sense!!!!!!!
- this->n = m!=INVALID?-1:G.nodes[m].first_in;
+ this->n = m!=INVALID?-1:G->nodes[m].first_in;
}
+ EdgeIt(const EdgeSet& _G, Edge e) : Edge(e), G(&_G) { }
EdgeIt (Invalid i) : Edge(i) { }
EdgeIt() : Edge() { }
///.
@@ -1482,6 +1486,7 @@
public:
OutEdgeIt() : Edge() { }
OutEdgeIt (Invalid i) : Edge(i) { }
+ OutEdgeIt(const EdgeSet& _G, Edge e) : Edge(e), G(&_G) { }
OutEdgeIt(const EdgeSet& _G,const Node v) :
Edge(_G.nodes[v].first_out), G(&_G) { }
@@ -1494,6 +1499,7 @@
public:
InEdgeIt() : Edge() { }
InEdgeIt (Invalid i) : Edge(i) { }
+ InEdgeIt(const EdgeSet& _G, Edge e) : Edge(e), G(&_G) { }
InEdgeIt(const EdgeSet& _G,Node v)
: Edge(_G.nodes[v].first_in), G(&_G) { }
InEdgeIt &operator++() { n=G->edges[n].next_in; return *this; }
Modified: hugo/branches/hugo++/src/hugo/smart_graph.h
==============================================================================
--- hugo/branches/hugo++/src/hugo/smart_graph.h (original)
+++ hugo/branches/hugo++/src/hugo/smart_graph.h Thu Aug 26 15:32:59 2004
@@ -202,10 +202,9 @@
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) { }
- ///\todo Undocumented conversion Node -\> NodeIt.
- NodeIt(const SmartGraph& _G, const Node &n) : Node(n), G(&_G) { }
NodeIt &operator++() {
n=(n+2)%(G->nodes.size()+1)-1;
return *this;
@@ -251,6 +250,7 @@
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() { }
///\bug This is a workaround until somebody tells me how to
@@ -266,6 +266,7 @@
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)
@@ -280,6 +281,7 @@
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) { }
Modified: hugo/branches/hugo++/src/test/graph_test.cc
==============================================================================
--- hugo/branches/hugo++/src/test/graph_test.cc (original)
+++ hugo/branches/hugo++/src/test/graph_test.cc Thu Aug 26 15:32:59 2004
@@ -48,6 +48,8 @@
Node n(i);
n=i;
b=(i==j); b=(i!=j); b=(i<j);
+ //Node ->NodeIt conversion
+ NodeIt ni(G,n);
}
{
Edge i; Edge j(i); Edge k(INVALID);
@@ -68,6 +70,8 @@
Edge e(i);
e=i;
b=(i==j); b=(i!=j); b=(i<j);
+ //Edge ->EdgeIt conversion
+ EdgeIt ei(G,e);
}
{
Node n;
@@ -81,6 +85,8 @@
Edge e(i);
e=i;
b=(i==j); b=(i!=j); b=(i<j);
+ //Edge ->InEdgeIt conversion
+ InEdgeIt ei(G,e);
}
{
Node n;
@@ -94,32 +100,32 @@
Edge e(i);
e=i;
b=(i==j); b=(i!=j); b=(i<j);
+ //Edge ->OutEdgeIt conversion
+ OutEdgeIt ei(G,e);
+ }
+ {
+ Node n,m;
+ n=m=INVALID;
+ Edge e;
+ e=INVALID;
+ n=G.tail(e);
+ n=G.head(e);
}
-
- Node n,m;
- n=m=INVALID;
- Edge e;
- e=INVALID;
- n=G.tail(e);
- n=G.head(e);
-
- //aNode, bNode ?
-
// id tests
- { int i=G.id(n); i=i; }
- { int i=G.id(e); i=i; }
-
- // G.clear();
-
+ { Node n; int i=G.id(n); i=i; }
+ { Edge e; int i=G.id(e); i=i; }
//NodeMap tests
{
Node k;
typename Graph::template NodeMap<int> m(G);
- typename Graph::template NodeMap<int> const &cm = m; //Const map
+ //Const map
+ typename Graph::template NodeMap<int> const &cm = m;
//Inicialize with default value
typename Graph::template NodeMap<int> mdef(G,12);
- typename Graph::template NodeMap<int> mm(cm); //Copy
- typename Graph::template NodeMap<double> dm(cm); //Copy from another type
+ //Copy
+ typename Graph::template NodeMap<int> mm(cm);
+ //Copy from another type
+ typename Graph::template NodeMap<double> dm(cm);
int v;
v=m[k]; m[k]=v; m.set(k,v);
v=cm[k];
@@ -175,10 +181,6 @@
dm=cm; //Copy from another type
m=dm; //Copy to another type
}
-
- //check findEdge
- //G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G)));
-
}
template<class Graph> void checkCompile(Graph &G)
@@ -195,8 +197,36 @@
Node n,m;
n=G.addNode();
m=G.addNode();
+ Edge e;
+ e=G.addEdge(n,m);
- G.addEdge(n,m);
+ // G.clear();
+}
+
+template<class Graph> void checkCompileErase(Graph &G)
+{
+ typedef typename Graph::Node Node;
+ typedef typename Graph::Edge Edge;
+ Node n;
+ Edge e;
+ G.erase(n);
+ G.erase(e);
+}
+
+template<class Graph> void checkCompileEraseEdge(Graph &G)
+{
+ typedef typename Graph::Edge Edge;
+ Edge e;
+ G.erase(e);
+}
+
+template<class Graph> void checkCompileFindEdge(Graph &G)
+{
+ typedef typename Graph::NodeIt Node;
+ typedef typename Graph::NodeIt NodeIt;
+
+ G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G)));
+ G.findEdge(Node(),Node(),G.findEdge(Node(),Node()));
}
@@ -235,8 +265,8 @@
}
template<class Graph> void checkInEdgeList(Graph &G,
- typename Graph::Node n,
- int nn)
+ typename Graph::Node n,
+ int nn)
{
typename Graph::InEdgeIt e(G,n);
for(int i=0;i<nn;i++) {
@@ -281,18 +311,45 @@
}
}
+//Compile GraphSkeleton
template
void checkCompileStaticGraph<StaticGraphSkeleton>(StaticGraphSkeleton &);
template void checkCompile<GraphSkeleton>(GraphSkeleton &);
+template
+void checkCompileErase<EraseableGraphSkeleton>(EraseableGraphSkeleton &);
+//Compile SmartGraph
template void checkCompile<SmartGraph>(SmartGraph &);
+//Compile SymSmartGraph
template void checkCompile<SymSmartGraph>(SymSmartGraph &);
+
+//Compile ListGraph
template void checkCompile<ListGraph>(ListGraph &);
+template void checkCompileErase<ListGraph>(ListGraph &);
+template void checkCompileFindEdge<ListGraph>(ListGraph &);
+
+//Compile SymListGraph
template void checkCompile<SymListGraph>(SymListGraph &);
+template void checkCompileErase<SymListGraph>(SymListGraph &);
+template void checkCompileFindEdge<SymListGraph>(SymListGraph &);
+
+//Compile FullGraph
template void checkCompileStaticGraph<FullGraph>(FullGraph &);
+template void checkCompileFindEdge<FullGraph>(FullGraph &);
+//Compile EdgeSet <ListGraph>
template void checkCompile<EdgeSet <ListGraph> >(EdgeSet <ListGraph> &);
+template
+void checkCompileEraseEdge<EdgeSet <ListGraph> >(EdgeSet <ListGraph> &);
+template
+void checkCompileFindEdge<EdgeSet <ListGraph> >(EdgeSet <ListGraph> &);
+
+//Compile EdgeSet <NodeSet>
template void checkCompile<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &);
+template
+void checkCompileEraseEdge<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &);
+template void checkCompileFindEdge<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &);
+
int main()
{
More information about the Lemon-commits
mailing list