COIN-OR::LEMON - Graph Library

Changeset 401:2d0cccf7cc94 in lemon-0.x for src/work


Ignore:
Timestamp:
04/26/04 00:26:19 (21 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@532
Message:

Some bugfixes.
Some more docs.

Location:
src/work/alpar
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/work/alpar/list_graph.h

    r400 r401  
    1616  class SymListGraph;
    1717
    18   ///A smart graph class.
     18  ///A list graph class.
    1919
    2020  ///This is a simple and fast erasable graph implementation.
     
    724724 
    725725
    726   ///A smart graph class.
    727 
    728   ///This is a simple and fast erasable graph implementation.
     726  ///A graph class containing only nodes.
     727
     728  ///This class implements a graph structure without edges.
     729  ///The most useful application of this class is to be the node set of an
     730  ///\ref EdgeSet class.
    729731  ///
    730732  ///It conforms to the graph interface documented under
    731   ///the description of \ref GraphSkeleton.
    732   ///\sa \ref GraphSkeleton.
     733  ///the description of \ref GraphSkeleton with the exception that you cannot
     734  ///add (or delete) edges. The usual edge iterators are exists, but they are
     735  ///always \ref INVALID.
     736  ///\sa \ref GraphSkeleton
     737  ///\se \ref EdgeSet
    733738  class NodeSet {
    734739
     
    11151120
    11161121
    1117   ///This is a simple and fast erasable graph implementation.
     1122  ///Graph structure using a node set of another graph.
     1123
     1124  ///This structure can be used to establish another graph over a node set
     1125  /// of an existing one. The node iterator will go through the nodes of the
     1126  /// original graph, and the NodeMap's of both graphs will convert to
     1127  /// each other.
     1128  ///
     1129  ///\param GG The type of the graph which shares its node set with this class.
     1130  ///Its interface must conform with \ref GraphSkeleton.
    11181131  ///
    11191132  ///It conforms to the graph interface documented under
    11201133  ///the description of \ref GraphSkeleton.
    11211134  ///\sa \ref GraphSkeleton.
     1135  ///\sa \ref NodeSet.
    11221136  template<typename GG>
    11231137  class EdgeSet {
     
    11921206  public:
    11931207
    1194     EdgeSet(const NodeGraphType &_G) : G(_G),
    1195                                        nodes(_G), edges(),
    1196                                        first_free_edge(-1) {}
     1208    EdgeSet(NodeGraphType &_G) : G(_G),
     1209                                 nodes(_G), edges(),
     1210                                 first_free_edge(-1) { }
    11971211    EdgeSet(const EdgeSet &_g) : G(_g.G), nodes(_g.G), edges(_g.edges),
    1198                                  first_free_edge(_g.first_free_edge) {}
     1212                                 first_free_edge(_g.first_free_edge) { }
    11991213   
    12001214    ~EdgeSet()
     
    12881302      }
    12891303     
    1290       edges[n].tail = u.n; edges[n].head = v.n;
    1291 
    1292       edges[n].next_out = nodes[u.n].first_out;
    1293       if(nodes[u.n].first_out != -1) edges[nodes[u.n].first_out].prev_out = n;
    1294       edges[n].next_in = nodes[v.n].first_in;
    1295       if(nodes[v.n].first_in != -1) edges[nodes[v.n].first_in].prev_in = n;
     1304      edges[n].tail = u; edges[n].head = v;
     1305
     1306      edges[n].next_out = nodes[u].first_out;
     1307      if(nodes[u].first_out != -1) edges[nodes[u].first_out].prev_out = n;
     1308      edges[n].next_in = nodes[v].first_in;
     1309      if(nodes[v].first_in != -1) edges[nodes[v].first_in].prev_in = n;
    12961310      edges[n].prev_in = edges[n].prev_out = -1;
    12971311       
    1298       nodes[u.n].first_out = nodes[v.n].first_in = n;
     1312      nodes[u].first_out = nodes[v].first_in = n;
    12991313
    13001314      Edge e; e.n=n;
     
    13741388      NodeIt() : NodeGraphType::NodeIt() { }
    13751389      NodeIt (Invalid i) : NodeGraphType::NodeIt(i) {}
    1376       NodeIt(const EdgeSet& _G) : NodeGraphType::Node(_G.G) { }
     1390      NodeIt(const EdgeSet& _G) : NodeGraphType::NodeIt(_G.G) { }
    13771391      NodeIt(const typename NodeGraphType::NodeIt &n)
    13781392        : NodeGraphType::NodeIt(n) {}
     
    14521466      ///\todo It can copy between different types.
    14531467      ///
    1454       template<typename TT> friend class NodeMap;
     1468      template<typename TT>
    14551469      NodeMap(const typename NodeGraphType::NodeMap<TT> &m)
    14561470        : NodeGraphType::NodeMap<T>(m) { }
  • src/work/alpar/list_graph_demo.cc

    r397 r401  
    121121   
    122122  }
     123
     124  // Tests for NodeSet and EdgeSet
     125 
     126  {
     127    NodeSet N;
     128   
     129    typedef EdgeSet<NodeSet> ES;
     130   
     131    ES E(N);
     132    ES F(N);
     133    for(int i=0;i<10;i++) G.addNode();
     134   
     135    for(ES::NodeIt n(E);E.valid(n);E.next(n))
     136      for(ES::NodeIt m(E);E.valid(m);E.next(m))
     137        if(n!=m) F.addEdge(n,m);
     138    for(ES::NodeIt n(F);F.valid(n);F.next(n))
     139      for(ES::NodeIt m(F);F.valid(m);F.next(m))
     140        if(n<m) F.addEdge(n,m);
     141   
     142
     143    NodeSet::NodeMap<int> nm1(N);
     144    ES::NodeMap<int> nm2(E);
     145    ES::EdgeMap<int> eme(E);
     146    ES::EdgeMap<int> emf(F);
     147   
     148       
     149  }
    123150 
    124151}
Note: See TracChangeset for help on using the changeset viewer.