Some bugfixes.
authoralpar
Sun, 25 Apr 2004 22:26:19 +0000
changeset 4012d0cccf7cc94
parent 400 cb377609cf1d
child 402 f90f65ba21d5
Some bugfixes.
Some more docs.
src/work/alpar/list_graph.h
src/work/alpar/list_graph_demo.cc
     1.1 --- a/src/work/alpar/list_graph.h	Sun Apr 25 20:16:16 2004 +0000
     1.2 +++ b/src/work/alpar/list_graph.h	Sun Apr 25 22:26:19 2004 +0000
     1.3 @@ -15,7 +15,7 @@
     1.4  
     1.5    class SymListGraph;
     1.6  
     1.7 -  ///A smart graph class.
     1.8 +  ///A list graph class.
     1.9  
    1.10    ///This is a simple and fast erasable graph implementation.
    1.11    ///
    1.12 @@ -723,13 +723,18 @@
    1.13    };
    1.14    
    1.15  
    1.16 -  ///A smart graph class.
    1.17 +  ///A graph class containing only nodes.
    1.18  
    1.19 -  ///This is a simple and fast erasable graph implementation.
    1.20 +  ///This class implements a graph structure without edges.
    1.21 +  ///The most useful application of this class is to be the node set of an
    1.22 +  ///\ref EdgeSet class.
    1.23    ///
    1.24    ///It conforms to the graph interface documented under
    1.25 -  ///the description of \ref GraphSkeleton.
    1.26 -  ///\sa \ref GraphSkeleton.
    1.27 +  ///the description of \ref GraphSkeleton with the exception that you cannot
    1.28 +  ///add (or delete) edges. The usual edge iterators are exists, but they are
    1.29 +  ///always \ref INVALID.
    1.30 +  ///\sa \ref GraphSkeleton
    1.31 +  ///\se \ref EdgeSet
    1.32    class NodeSet {
    1.33  
    1.34      //Nodes are double linked.
    1.35 @@ -1114,11 +1119,20 @@
    1.36  
    1.37  
    1.38  
    1.39 -  ///This is a simple and fast erasable graph implementation.
    1.40 +  ///Graph structure using a node set of another graph.
    1.41 +
    1.42 +  ///This structure can be used to establish another graph over a node set
    1.43 +  /// of an existing one. The node iterator will go through the nodes of the
    1.44 +  /// original graph, and the NodeMap's of both graphs will convert to
    1.45 +  /// each other.
    1.46 +  ///
    1.47 +  ///\param GG The type of the graph which shares its node set with this class.
    1.48 +  ///Its interface must conform with \ref GraphSkeleton.
    1.49    ///
    1.50    ///It conforms to the graph interface documented under
    1.51    ///the description of \ref GraphSkeleton.
    1.52    ///\sa \ref GraphSkeleton.
    1.53 +  ///\sa \ref NodeSet.
    1.54    template<typename GG>
    1.55    class EdgeSet {
    1.56  
    1.57 @@ -1191,11 +1205,11 @@
    1.58      
    1.59    public:
    1.60  
    1.61 -    EdgeSet(const NodeGraphType &_G) : G(_G),
    1.62 -				       nodes(_G), edges(),
    1.63 -				       first_free_edge(-1) {}
    1.64 +    EdgeSet(NodeGraphType &_G) : G(_G),
    1.65 +				 nodes(_G), edges(),
    1.66 +				 first_free_edge(-1) { }
    1.67      EdgeSet(const EdgeSet &_g) : G(_g.G), nodes(_g.G), edges(_g.edges),
    1.68 -				 first_free_edge(_g.first_free_edge) {}
    1.69 +				 first_free_edge(_g.first_free_edge) { }
    1.70      
    1.71      ~EdgeSet()
    1.72      {
    1.73 @@ -1287,15 +1301,15 @@
    1.74  	first_free_edge = edges[n].next_in;
    1.75        }
    1.76        
    1.77 -      edges[n].tail = u.n; edges[n].head = v.n;
    1.78 +      edges[n].tail = u; edges[n].head = v;
    1.79  
    1.80 -      edges[n].next_out = nodes[u.n].first_out;
    1.81 -      if(nodes[u.n].first_out != -1) edges[nodes[u.n].first_out].prev_out = n;
    1.82 -      edges[n].next_in = nodes[v.n].first_in;
    1.83 -      if(nodes[v.n].first_in != -1) edges[nodes[v.n].first_in].prev_in = n;
    1.84 +      edges[n].next_out = nodes[u].first_out;
    1.85 +      if(nodes[u].first_out != -1) edges[nodes[u].first_out].prev_out = n;
    1.86 +      edges[n].next_in = nodes[v].first_in;
    1.87 +      if(nodes[v].first_in != -1) edges[nodes[v].first_in].prev_in = n;
    1.88        edges[n].prev_in = edges[n].prev_out = -1;
    1.89  	
    1.90 -      nodes[u.n].first_out = nodes[v.n].first_in = n;
    1.91 +      nodes[u].first_out = nodes[v].first_in = n;
    1.92  
    1.93        Edge e; e.n=n;
    1.94  
    1.95 @@ -1373,7 +1387,7 @@
    1.96      public:
    1.97        NodeIt() : NodeGraphType::NodeIt() { }
    1.98        NodeIt (Invalid i) : NodeGraphType::NodeIt(i) {}
    1.99 -      NodeIt(const EdgeSet& _G) : NodeGraphType::Node(_G.G) { }
   1.100 +      NodeIt(const EdgeSet& _G) : NodeGraphType::NodeIt(_G.G) { }
   1.101        NodeIt(const typename NodeGraphType::NodeIt &n)
   1.102  	: NodeGraphType::NodeIt(n) {}
   1.103        operator Node() { return Node(*this);}
   1.104 @@ -1451,7 +1465,7 @@
   1.105  
   1.106        ///\todo It can copy between different types.
   1.107        ///
   1.108 -      template<typename TT> friend class NodeMap;
   1.109 +      template<typename TT>
   1.110        NodeMap(const typename NodeGraphType::NodeMap<TT> &m)
   1.111  	: NodeGraphType::NodeMap<T>(m) { }
   1.112      };
     2.1 --- a/src/work/alpar/list_graph_demo.cc	Sun Apr 25 20:16:16 2004 +0000
     2.2 +++ b/src/work/alpar/list_graph_demo.cc	Sun Apr 25 22:26:19 2004 +0000
     2.3 @@ -120,5 +120,32 @@
     2.4  		<< " sm=" << sm[e] << "\n";
     2.5      
     2.6    }
     2.7 +
     2.8 +  // Tests for NodeSet and EdgeSet
     2.9 +  
    2.10 +  {
    2.11 +    NodeSet N;
    2.12 +    
    2.13 +    typedef EdgeSet<NodeSet> ES;
    2.14 +    
    2.15 +    ES E(N);
    2.16 +    ES F(N);
    2.17 +    for(int i=0;i<10;i++) G.addNode();
    2.18 +    
    2.19 +    for(ES::NodeIt n(E);E.valid(n);E.next(n))
    2.20 +      for(ES::NodeIt m(E);E.valid(m);E.next(m))
    2.21 +	if(n!=m) F.addEdge(n,m);
    2.22 +    for(ES::NodeIt n(F);F.valid(n);F.next(n))
    2.23 +      for(ES::NodeIt m(F);F.valid(m);F.next(m))
    2.24 +	if(n<m) F.addEdge(n,m);
    2.25 +    
    2.26 +
    2.27 +    NodeSet::NodeMap<int> nm1(N);
    2.28 +    ES::NodeMap<int> nm2(E);
    2.29 +    ES::EdgeMap<int> eme(E);
    2.30 +    ES::EdgeMap<int> emf(F);
    2.31 +    
    2.32 +       
    2.33 +  }
    2.34    
    2.35  }