# HG changeset patch # User alpar # Date 1082931979 0 # Node ID 2d0cccf7cc949a36a1de2983bac8399adeea70d0 # Parent cb377609cf1d50be72339861acbe2a765824912e Some bugfixes. Some more docs. diff -r cb377609cf1d -r 2d0cccf7cc94 src/work/alpar/list_graph.h --- a/src/work/alpar/list_graph.h Sun Apr 25 20:16:16 2004 +0000 +++ b/src/work/alpar/list_graph.h Sun Apr 25 22:26:19 2004 +0000 @@ -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 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 friend class NodeMap; + template NodeMap(const typename NodeGraphType::NodeMap &m) : NodeGraphType::NodeMap(m) { } }; diff -r cb377609cf1d -r 2d0cccf7cc94 src/work/alpar/list_graph_demo.cc --- a/src/work/alpar/list_graph_demo.cc Sun Apr 25 20:16:16 2004 +0000 +++ b/src/work/alpar/list_graph_demo.cc Sun Apr 25 22:26:19 2004 +0000 @@ -120,5 +120,32 @@ << " sm=" << sm[e] << "\n"; } + + // Tests for NodeSet and EdgeSet + + { + NodeSet N; + + typedef EdgeSet 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 nm1(N); + ES::NodeMap nm2(E); + ES::EdgeMap eme(E); + ES::EdgeMap emf(F); + + + } }