[Lemon-commits] [lemon_svn] alpar: r532 - hugo/trunk/src/work/alpar
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:40:01 CET 2006
Author: alpar
Date: Mon Apr 26 00:26:19 2004
New Revision: 532
Modified:
hugo/trunk/src/work/alpar/list_graph.h
hugo/trunk/src/work/alpar/list_graph_demo.cc
Log:
Some bugfixes.
Some more docs.
Modified: hugo/trunk/src/work/alpar/list_graph.h
==============================================================================
--- hugo/trunk/src/work/alpar/list_graph.h (original)
+++ hugo/trunk/src/work/alpar/list_graph.h Mon Apr 26 00:26:19 2004
@@ -15,7 +15,7 @@
class SymListGraph;
- ///A smart graph class.
+ ///A list graph class.
///This is a simple and fast erasable graph implementation.
///
@@ -723,13 +723,18 @@
};
- ///A smart graph class.
+ ///A graph class containing only nodes.
- ///This is a simple and fast erasable graph implementation.
+ ///This class implements a graph structure without edges.
+ ///The most useful application of this class is to be the node set of an
+ ///\ref EdgeSet class.
///
///It conforms to the graph interface documented under
- ///the description of \ref GraphSkeleton.
- ///\sa \ref GraphSkeleton.
+ ///the description of \ref GraphSkeleton with the exception that you cannot
+ ///add (or delete) edges. The usual edge iterators are exists, but they are
+ ///always \ref INVALID.
+ ///\sa \ref GraphSkeleton
+ ///\se \ref EdgeSet
class NodeSet {
//Nodes are double linked.
@@ -1114,11 +1119,20 @@
- ///This is a simple and fast erasable graph implementation.
+ ///Graph structure using a node set of another graph.
+
+ ///This structure can be used to establish another graph over a node set
+ /// of an existing one. The node iterator will go through the nodes of the
+ /// original graph, and the NodeMap's of both graphs will convert to
+ /// each other.
+ ///
+ ///\param GG The type of the graph which shares its node set with this class.
+ ///Its interface must conform with \ref GraphSkeleton.
///
///It conforms to the graph interface documented under
///the description of \ref GraphSkeleton.
///\sa \ref GraphSkeleton.
+ ///\sa \ref NodeSet.
template<typename GG>
class EdgeSet {
@@ -1191,11 +1205,11 @@
public:
- EdgeSet(const NodeGraphType &_G) : G(_G),
- nodes(_G), edges(),
- first_free_edge(-1) {}
+ EdgeSet(NodeGraphType &_G) : G(_G),
+ nodes(_G), edges(),
+ first_free_edge(-1) { }
EdgeSet(const EdgeSet &_g) : G(_g.G), nodes(_g.G), edges(_g.edges),
- first_free_edge(_g.first_free_edge) {}
+ first_free_edge(_g.first_free_edge) { }
~EdgeSet()
{
@@ -1287,15 +1301,15 @@
first_free_edge = edges[n].next_in;
}
- edges[n].tail = u.n; edges[n].head = v.n;
+ edges[n].tail = u; edges[n].head = v;
- edges[n].next_out = nodes[u.n].first_out;
- if(nodes[u.n].first_out != -1) edges[nodes[u.n].first_out].prev_out = n;
- edges[n].next_in = nodes[v.n].first_in;
- if(nodes[v.n].first_in != -1) edges[nodes[v.n].first_in].prev_in = n;
+ edges[n].next_out = nodes[u].first_out;
+ if(nodes[u].first_out != -1) edges[nodes[u].first_out].prev_out = n;
+ edges[n].next_in = nodes[v].first_in;
+ if(nodes[v].first_in != -1) edges[nodes[v].first_in].prev_in = n;
edges[n].prev_in = edges[n].prev_out = -1;
- nodes[u.n].first_out = nodes[v.n].first_in = n;
+ nodes[u].first_out = nodes[v].first_in = n;
Edge e; e.n=n;
@@ -1373,7 +1387,7 @@
public:
NodeIt() : NodeGraphType::NodeIt() { }
NodeIt (Invalid i) : NodeGraphType::NodeIt(i) {}
- NodeIt(const EdgeSet& _G) : NodeGraphType::Node(_G.G) { }
+ NodeIt(const EdgeSet& _G) : NodeGraphType::NodeIt(_G.G) { }
NodeIt(const typename NodeGraphType::NodeIt &n)
: NodeGraphType::NodeIt(n) {}
operator Node() { return Node(*this);}
@@ -1451,7 +1465,7 @@
///\todo It can copy between different types.
///
- template<typename TT> friend class NodeMap;
+ template<typename TT>
NodeMap(const typename NodeGraphType::NodeMap<TT> &m)
: NodeGraphType::NodeMap<T>(m) { }
};
Modified: hugo/trunk/src/work/alpar/list_graph_demo.cc
==============================================================================
--- hugo/trunk/src/work/alpar/list_graph_demo.cc (original)
+++ hugo/trunk/src/work/alpar/list_graph_demo.cc Mon Apr 26 00:26:19 2004
@@ -120,5 +120,32 @@
<< " sm=" << sm[e] << "\n";
}
+
+ // Tests for NodeSet and EdgeSet
+
+ {
+ NodeSet N;
+
+ typedef EdgeSet<NodeSet> ES;
+
+ ES E(N);
+ ES F(N);
+ for(int i=0;i<10;i++) G.addNode();
+
+ for(ES::NodeIt n(E);E.valid(n);E.next(n))
+ for(ES::NodeIt m(E);E.valid(m);E.next(m))
+ if(n!=m) F.addEdge(n,m);
+ for(ES::NodeIt n(F);F.valid(n);F.next(n))
+ for(ES::NodeIt m(F);F.valid(m);F.next(m))
+ if(n<m) F.addEdge(n,m);
+
+
+ NodeSet::NodeMap<int> nm1(N);
+ ES::NodeMap<int> nm2(E);
+ ES::EdgeMap<int> eme(E);
+ ES::EdgeMap<int> emf(F);
+
+
+ }
}
More information about the Lemon-commits
mailing list